need tips on how to get any data from scene

Discussions concerning programming of SOFTIMAGE©
wesserbro
Posts: 165
Joined: 27 Oct 2012, 18:05

need tips on how to get any data from scene

Post by wesserbro » 21 Sep 2016, 19:55

Can some kind people pls explain to me the logic of retrieving data for scripting from logs? For the love of god i cant wrap my head around this. Every time i have some idea for script this is the biggest problem. I can figure out the math for the idea, and im familiar with basic programming constructions, but getting certain values or methods for setting the values is a constant struggle. SDK documentation looks to me like a mess.
For example, i want to get weight values of the clusters of a point. What do i do, i change the weight through the weight editor and look at the logs to see data path.

Application.SIModifyFlexEnvWght("sphere.polymsh.cls.DeformBySpineWeightCls.Envelope_Weights", "crvlist", "sphere.pnt[0]", 0, 82, False)

Ok, so what i can tell from this is that weight not a point attribute. Probably i can get some array or set via something like

myobj = Application.GetValue('sphere')
myaaray = myobj.polymsh.cls.DeformBySpineWeightCls.Envelope_Weights


but no, thats an error.
From this point im starting just lurking blindly through SDK docs, finding some C++ descriptions of an object model (which is no help for me) and some examples exposing something similar but not quite what i need, and at this point i'm stuck//
HELP! ))

Edit: Already done my task with ICE. But as i said that weight thing is just an example, and there are many tasks where scripting is more comprehensive solution over ICE.

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

Re: need tips on how to get any data from scene

Post by myara » 22 Sep 2016, 17:12

If you want to script something more advanced than just executing commands in sequence, you'll need to learn the Object Model. Not that easy though becuase for that the log isn't very useful.

The SDK Manual is quite good, but not very newbie friendly and some valuable scripting info is mixed with C++.

In your code you are mixing Objects with a string representation that the command is using.
And the Weights Array isn't in the Cluster, it's in the Operator.

For Weights you can do :

Code: Select all

#Python
xsi = Application
obj = xsi.Selection(0)
envelopeOp = obj.Envelopes(0)
weights = envelopeOp.Weights.Array

#To get Clusters:
cls = obj.ActivePrimitive.Geometry.Clusters
If you get the info through the Object Method, everything is an Object with properties, parameters and Nested Objects.
If you get the info through the log, everything is just strings. You can convert those strings to Objects with GetValue or Dictionary.

Although not the best way, but an easy way to convert a string like "sphere.polymsh.cls.DeformBySpineWeightCls.Envelope_Weights" to an object would be with GetValue:

Code: Select all

envProp = xsi.GetValue( "sphere.polymsh.cls.DeformBySpineWeightCls.Envelope_Weights" )
Would give you the Envelope Weights Property as an Object. So from there you could use something like this:

Code: Select all

envProp.deflimit = 3
envProp.Name = "New_Envelope_Weights"
This would change the Deformer Limit to 3 and the Property Name to "New_Envelope_Weights".

You can't get the Weights Array because it isn't there.

The proper way to do it would be to get the Polymesh Object, and dig from there until you get the properties and clusters you need.

If you really need or want to learn how to code in an almost dead Software, I suggest you to read the manual with patience, and study other people's codes.

Good Luck
M.Yara
Character Modeler | Softimage Generalist (sort of)

wesserbro
Posts: 165
Joined: 27 Oct 2012, 18:05

Re: need tips on how to get any data from scene

Post by wesserbro » 22 Sep 2016, 18:26

myara wrote: If you really need or want to learn how to code in an almost dead Software, I suggest you to read the manual with patience, and study other people's codes.
Good Luck
Well, yeah, maybe thats the problem. I dont use softimage at work and script pretty rarely, so my attempts with xsi are like spontaneous diving-ins. But for example with blender such swoops are more productive. Cants say if it large community or more comprehensive structure and docs what counts more.
Anyway thank you very much for such an open answer. I have somewhat unhealthy love to softimage(my god that GUI is so sexy and all the little things like tweak point with lmb-x, mmb - y, rmb - z just drive me crazy) so i'll continue my blitzkriegs despite its deadness :)

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

Re: need tips on how to get any data from scene

Post by myara » 22 Sep 2016, 20:04

The best way to learn is to read other people's code. You also have a few tutorials in videos like Helge's JScript and Raffaelle's Python Course or the free Pooby's scripting intro videos on vimeo.

You can script basic tools using only commands. The problem with commands, besides their limitations, is that a lot of them are very slow.

In Maya's mel or simple Python you don't have Objects. Everything is done by commands and strings but the process is quite fast and you have tons of commands (so many that some of them do almost the same thing).

In Softimage it may take a little more time to understand the Object Method but when you get used to it, it's way faster, easier and fun to write than using only commands.
M.Yara
Character Modeler | Softimage Generalist (sort of)