Reusable Synoptic code

Discussions concerning programming of SOFTIMAGE©
User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Reusable Synoptic code

Post by sirdavid32 » 24 Aug 2010, 04:47

Hello, I´ve been trying to setup a simple synoptic code setup that I can later reuse in other
synoptic components.

so the code it´s like this for a first hotspot called: round_area.

Hello, I´ve been trying to setup a simple script in jscript to select an object inside a model from a synpptic view setup un in javascript:

<html>
<body version="2">
<script language="JavaScript">
function round_area(in_obj,in_mousebutton,in_keymodifier)
{
SelectObj ("sphere, , True);
};

But I know that in order for making this re-usable I need to create some sort of variable?

I´m not a programmer guy, just a simple animator who´s a little confused by jscript syntax.
Anyone help?

Thanks.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Re: Reusable Synoptic code

Post by sirdavid32 » 24 Aug 2010, 18:02

So far I got this:

<html>
<body version="2">
<script language="JavaScript">

function ball(in_obj,in_mousebutton,in_keymodifier)
{
SelectObj ("sphere"," ", True);
}

But it returns an error on line 2. I´m using xsi 2011 sp1.

Could you help me out with this simple thing, please?

Someone mentioned the syntax..I corrected on the select object line. But that still is causing an error 2
Why is it doing it not passing even the "body version" line, then??

craft
Posts: 107
Joined: 02 Jan 2010, 23:40
Location: Portugal

Re: Reusable Synoptic code

Post by craft » 24 Aug 2010, 18:46

line count is relative to the script itself, not the html structure. so, it addresses to the SelectObj line.

the " " part is the problem now. Specially with a space character inside... that means you're inputing a valid string saying: " ", when it expects either nothing or one of the following values: "ASITIS", "NODE", BRANCH", "TREE", "MODEL" (you really should check the SDK documentation, it's very helpfull)
So either replace that with the word null (no ""'s), or just remove the space character (the command's expecting a string, anyway) Also, use the word true, not True, or you'll get another error.

Code: Select all

function ball(in_obj,in_mousebutton,in_keymodifier)
{
SelectObj ("sphere", null, true);
}

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Re: Reusable Synoptic code

Post by sirdavid32 » 24 Aug 2010, 19:01

Marvelous!! It works now!

<html>
<body version="2">
<script language="JavaScript">

function ball(in_obj,in_mousebutton,in_keymodifier)
{
SelectObj ("sphere",null, null);
}

I really would like to learn the SDK on this subject. What´s the subject search for this as jscript?
Thank you very much Thiago.

craft
Posts: 107
Joined: 02 Jan 2010, 23:40
Location: Portugal

Re: Reusable Synoptic code

Post by craft » 25 Aug 2010, 00:16

it's easy, really.
just type whatever command/object/method you want to read about in the script editor. double click the word and press F1 on the keyboard. Also works with incomplete words.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Re: Reusable Synoptic code

Post by sirdavid32 » 25 Aug 2010, 01:57

Wonderful TIP Tiago! The syntax for objects will be so clear from now on.
But what if I need to make the "reset" actor and the "keyframe" all parameters from the pose?
How would I code this in Js? I´ll be posting here my tries.
Thanks.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Re: Reusable Synoptic code

Post by sirdavid32 » 01 Sep 2010, 19:04

Tiago, in JS in order to create a Keyframe button for a selected object
what would be the syntax? I´ve been trying To erase the number here:
SaveKey("sphere.kine.local.posx,sphere.kine.local.posy,sphere.kine.local.posz", 1, null, null, null, false, null);

And then it DOES save a keyframe wherever I am.
Since I´d like the script button to check if an object is selected, and if it´s so, then
keyframe on keyable attributes...how to organize this in a method that doesn´t involve all the names in all the transforms and rots in the model? Because writting them, would be madness, there are a gazillion names.

Thanks.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Re: Reusable Synoptic code

Post by sirdavid32 » 01 Sep 2010, 20:15

So far I got this:


function keyfram(in_obj,in_mousebutton,in_keymodifier)
{
SaveKey("sphere.kine.local.posx,sphere.kine.local.posy,sphere.kine.local.posz", null, null, null, false, null);
SaveKey("sphere.kine.local.rotx,sphere.kine.local.roty,sphere.kine.local.rotz", null, null, null, false, null);
}

and it works perfectly, keying on any frame I move to.

But my question is: is there a method to "GetCurrentSelection at Object" to name this like:

SaveKey("CurrentSelectedObject.kine.local.posx,sphere.kine.local.posy,sphere.kine.local.posz", null, null, null, false, null);
SaveKey("CurrentSelectedObject.kine....x)
SaveKey("CurrentSelectedObject.kine....y)

?

luceric
Posts: 1252
Joined: 21 Jun 2009, 22:08

Re: Reusable Synoptic code

Post by luceric » 01 Sep 2010, 21:08

Just properly define the parameters as keyable or not and just call
SaveKeyOnKeyable
no need to specify any parameters

Or use a relative path
SaveKey "/kine.local.pos"

this is all in the documentation example of the SaveKey command.

User avatar
sirdavid32
Posts: 309
Joined: 10 Feb 2010, 03:36
Location: Ecuador

Re: Reusable Synoptic code

Post by sirdavid32 » 01 Sep 2010, 23:22

St.Blair, Lucernic, thanks:
SaveKey( "/kine.local.pos,kine.local.ori,kine.local.scl" );

This worked perfectly!!