PDA

View Full Version : Synoptic Scripting (adding to selection)


shadowedge
08-28-2006, 09:05 AM
Hi everyone,

just a quick question with the synoptic editor.

I'm really bad at scripting, so I hope someone can help me :sad:

I gave my model a synoptic property that lets me select controllers, apply animation/poses, and lets me keyframe and "un"keyframe.

for selecting purposes > I wanted to multi select 2 controlers by adding to selection through the synoptic viewer (ex. click one controller button, then hold shift and click another controller button to add to selection)

Is this an easy task? or does this demand heavy scripting?

My deepest thanks to you all. :love:

grahamef
08-28-2006, 06:41 PM
If you're using 5.1 or later, it shouldn't be too difficult. XSI passes a variable called in_keymodifier to your synoptic script. You can test this value to see which modifer keys were pressed and then have your script perform different actions accordingly. In the case of Shift, the value of in_keymodifier will be odd.

If you are using an earlier version, I don't think this is possible. You'd have to create different hotspots to perform the AddToSelection command.

matt8
08-29-2006, 07:44 PM
for selecting purposes > I wanted to multi select 2 controlers by adding to selection through the synoptic viewer (ex. click one controller button, then hold shift and click another controller button to add to selection)

Is this an easy task? or does this demand heavy scripting?

My deepest thanks to you all. :love:



When I first started tinkering with the synoptics I found if extremely useful to see how the default xsi synoptic was scripted. I would advise you to check out the source of the default synoptic. On my current workstation it resides here:

C:\Softimage\XSI_5.11\Data\XSI_SAMPLES\Synoptic\Rig\BipedSynoptic_IK1.htm

once open just chose view>source from the windows explorer, this opens the notepad that shows all the scripts associated with the synoptic. Now there are all sorts of cool functions that the guys at softimage wrote that you can re-purpose.

Look for these functions: SynopticSelect, also SynopticSelect2 and checkCollision. That's how the default synoptic checks for keyboard mods and it does work in older versions of xsi. If you copy and paste these functions into your synoptic you should get the same results as long as you call the function instead of just copying and pasting from the script editor. ( hope that makes sense.) My advice to you is check out the default synoptics and how they are scripted, you'll learn loads about scripting... at least I did.

m@

shadowedge
08-30-2006, 06:52 AM
Hey thanks! :thumbsup:

I really appreciate the advice, I'll be looking into it later this afternoon. :scream:

shadowedge
11-14-2006, 01:41 PM
Hi again everyone....

I havent had the chance to try this out up until today... my bad :sad:

anyway matt8:

If you copy and paste these functions into your synoptic you should get the same results as long as you call the function instead of just copying and pasting from the script editor

Im sorry I dont understand :(

this is what im making looks like
sub HEAD(in_obj,in_mousebutton,in_keymodifier)
SelectObj "TITAN1.HEAD1", , True
end sub

where as the default synop in xsi looks like this:
sub head(in_obj)
SynopticSelect in_obj, "head"
end sub

how are they different? and which part is the function?

so sorry, Im not a programmer... still trying to learn.. thanks so far anyway. I really appreciate the help

dwigfor
11-14-2006, 07:49 PM
I'd like to get this to work as well, but haven't been able to set aside time... But I did look at the SI synoptic.. My scripting knowledge is limited......

"which part is the function? "

I think the functions are listed towards the bottom of the htm file -
----------------
Helper Functions
----------
Synoptic Select
--------------
function SynopticSelect(in_obj, inName)


Calling the functions is listed above - such as:
sub globalSRT(in_obj)
SynopticSelect in_obj, "globalSRT"
end sub


What I'm unclear with is how you can call functions without declaring them first... Shouldn't the functions be written at the top of the script? Is it different than variables? You need to declare the variable before referring to it, right?

shadowedge
11-15-2006, 07:12 AM
Hi dave!

Im glad people here have been helpful in pointing to the right direction. :love:

I spent the whole evening blowing my brain cells to bits trying to figure this out. This morning I gave up on continuing my feeble attempts to program, and decided to get help from a friend in the programming dept.

I breifly explained what the synoptic view does, and how the functions work. Thanks to the guys here pointing out the default synoptic script, I was able to show him what he needed to know. so in 20 mins or so, We came up with a well working synoptic viewer with the shift and cntrl modifiers.

heres a sample of the script:



sample selectable element:

sub HEAD(in_obj,in_mousebutton,in_keymodifier)
SynopticSelect in_obj, "HEAD1"
end sub

synoptic select function:

'---------------------------------------------
' Synoptic Select
'---------------------------------------------
function SynopticSelect(in_obj, inName)
set oRoot = Application.ActiveProject.ActiveScene.Root
set myObj = oRoot.FindChild(in_obj)
if IsComponent(myObj & "." & inName) = False then
logmessage "RigSynoptic: " & myObj & " not found"
SynopticSelect = False
else
GetKeyboardState , modKey
select case CByte(modKey)

case 0 ' "Nothing Selected"
SelectObj myObj & "." & inName
case 1 logmessage "Shift"
'check the object isn't already selected
if checkCollision(myObj.FindChild(inName)) = False then
AddToSelection myObj & "." & inName
end if

case 2 ' "Ctrl"
ToggleSelection myObj & "." & inName
case 3 ' "Shift/Ctrl"
RemoveFromSelection myObj & "." & inName
end select

end if
end function
'--------------------------------------
' Is Component
'--------------------------------------
function IsComponent(in_string)

dim oRoot
IsComponent = True
set oRoot = Application.ActiveProject.ActiveScene.Root
if typename(oRoot.FindChild(in_string)) = "Nothing" then IsComponent = False

end function
'--------------------------------------
' Check Selection Collision
'--------------------------------------
function checkCollision(inObj)

dim sel, elem
set sel = GetValue("SelectionList")

SelectChildNodes

for each elem in Selection
if elem = inObj then
checkCollision = True
SelectObj sel
exit function
end if
next

checkCollision = False
SelectObj sel

end function



I dont really memorize everything he changed, but he gave me a general Idea of what I needed to modify. I only needed to take the first 3 cases because I just needed the add to selection and the toggle selection to work.

Still sorry, If I can't find the right way to explain how it works because Im not a programmer, so I decided to paste instead...

I really hope this info will be useful to others....
(Allan, thanks!)

CGTalk Moderation
11-15-2006, 07:12 AM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.