Center Selection Filter

Discussions concerning programming of SOFTIMAGE©
Post Reply
User avatar
gaboraa
Posts: 314
Joined: 16 Apr 2010, 23:14

Center Selection Filter

Post by gaboraa » 28 May 2022, 19:02

Is there any way to get the CenterSelectionFilter command on Python? It is not reported in the output log when executed. Also, is there any place where I can look for all the commands that are not reported in the output log?

User avatar
Kolya
Posts: 39
Joined: 03 Oct 2017, 19:17

Re: Center Selection Filter

Post by Kolya » 30 May 2022, 09:06

to check if center mode is enabled: Application.GetUserPref("SI3D_SRT_CENTER")
to toggle between: Application.SetUserPref("SI3D_SRT_CENTER", not Application.GetUserPref("SI3D_SRT_CENTER"))

User avatar
myara
Posts: 403
Joined: 28 Sep 2011, 10:33

Re: Center Selection Filter

Post by myara » 30 May 2022, 09:59

As Kolya mentioned, selection filters are preferences, not commands. The command is SelectAllUsingFilter from which you have a log.

As for a way to list all commands, you just need to iterate Application.Commands.

Ex:

Code: Select all

for x in Application.Commands:
	LogMessage ( '%s | %s | %s' % ( x.Name, x.Category, x.ScriptingName ) )

If it helps, this is a code I was writing to find some commands a long time ago. I never quite finished but it works:

Code: Select all

# Find Commands
# 2016
# myara
#------------------------------------------
xsi = Application
log = xsi.Logmessage
from win32com.client import constants as c
#------------------------------------------

oPSet = XSIFactory.CreateObject("CustomProperty")
oPSet.Name = 'Search Command'
oPSet.AddParameter2( 'keyword', c.siString )
oPSet.AddParameter2( 'allkeys', c.siBool )
oGridParam = oPSet.AddGridParameter( 'resultsGrid' )

oLay = oPSet.PPGLayout

oLay.AddRow()
oLay.AddGroup("",0,90)
oLay.AddItem('keyword', 'Search' )
oLay.EndGroup()
oLay.AddGroup("",0,10)
oLay.AddItem('allkeys')
oLay.EndGroup()
oLay.EndRow()

oGridParam.Value.RowCount = 1
oGridParam.Value.ColumnCount = 3

oGridDataOnPSet = oGridParam.Value
oGridDataOnPSet.SetColumnLabel(0, "Command Name" )
oGridDataOnPSet.SetColumnLabel(1, "Category" )
oGridDataOnPSet.SetColumnLabel(2, "Scripting Name" )

oPPGItem = oLay.AddItem( "resultsGrid", "", c.siControlGrid )
oPPGItem.SetAttribute( "NoLabel", True  )

oLay.Language = 'Python'

sLogic='''
xsi = Application
log = xsi.Logmessage

def keyword_OnChanged():
    ppg_kw = PPG.keyword.Value
    allkeys = PPG.allkeys.Value
    cmds = Application.Commands
    
    kws=[]
    #get KeyWords
    if len(ppg_kw.split(" "))>1:
        kws = ppg_kw.split(" ")
    elif len(ppg_kw.split(","))>1:
        kws = ppg_kw.split(",")
    else:
        kws.append( ppg_kw )
    
    filteredList = []
    filteredListG = []
    filteredListS = []
    
    for c in cmds:
        if allkeys:
            flag = 1
            for kw in kws:
                if c.Name.lower().find(kw.lower())== -1:
                    flag = 0
            
            if flag == 1:
                filteredList.append( str(c.Name) )
                filteredList.append( str(c.Name) )
                filteredListG.append( str(c.Category) )
                filteredListG.append( str(c.Category) )
                filteredListS.append( str(c.ScriptingName) )
                filteredListS.append( str(c.ScriptingName) )
        else:
            for kw in kws:
                if c.Name.lower().find(kw.lower())!= -1 or c.ScriptingName.lower().find(kw.lower())!= -1:
                    if str(c.Name) not in filteredList:
                        filteredList.append( str(c.Name) )
                        filteredList.append( str(c.Name) )
                        filteredListG.append( str(c.Category) )
                        filteredListG.append( str(c.Category) )
                        filteredListS.append( str(c.ScriptingName) )
                        filteredListS.append( str(c.ScriptingName) )

    PPGResults = PPG.resultsGrid.Value
    
    PPGResults.BeginEdit()
   
    PPGResults.RowCount = len(filteredList)/2
    for i in range(len(filteredList)/2):
        a = i *2
        PPGResults.SetRowValues( a/2, [filteredList[a], filteredListG[a], filteredListS[a]] ) ;
        
    PPGResults.EndEdit()
    
def allkeys_OnChanged():
    ppgkw = PPG.keyword.Value
    if ppgkw != "":
        keyword_OnChanged()
'''

oLay.Logic = sLogic
    
xsi.InspectObj( oPSet, "", "", 3 )
Image
M.Yara
Character Modeler | Softimage Generalist (sort of)

User avatar
gaboraa
Posts: 314
Joined: 16 Apr 2010, 23:14

Re: Center Selection Filter

Post by gaboraa » 02 Jun 2022, 15:57

Thank you so much for the help! Also, you are so generous myara, I'm a noob in scripting but I was able to finish my first script thanks to you guys, much appreciated!

Post Reply

Who is online

Users browsing this forum: No registered users and 55 guests