Convert to JS

General questions and troubleshooting SOFTIMAGE©
Falam

Convert to JS

Post by Falam » 04 Jul 2013, 14:00

I would appreciate if someone could convert this to JS, I'm hoping to extend it's ability.
si=Application
mdl = si.Dictionary.GetObject( 'Man_Character' )

import win32com.client
mats = win32com.client.Dispatch( "XSI.Collection" )
mats.Items = '{0}.{1},{0}.{2}'.format(mdl.Name, "*.cls.*.material", "*.material")

for m in mats:
print (m)

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 00:41

Re: Convert to JS

Post by EricTRocks » 04 Jul 2013, 14:12

In my opinion, you're not going to get many volunteers for this type of stuff and are better off trying to convert it yourself and posting in the programming forum with your progress and maybe someone will be more inclined to help.
Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken

Falam

Re: Convert to JS

Post by Falam » 04 Jul 2013, 14:17

You have to understand the language to convert it. If you knew Russian and I told you to translate what someone said in Japanese, how well would that turn out ?

Besides the last time you mentioned for me to post Gobbledegook to humiliate myself, which I'm not going to do again, I rather take a stab at something I have a stronger understanding then something I don't.

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: Convert to JS

Post by xsisupport » 04 Jul 2013, 14:29

I would go with the FindObjects way of getting the materials myself, or the various FindChildren snippets that others posted.
Using string expressions is old school :)

Here's a hint:

Code: Select all

si=Application
mdl = si.Dictionary.GetObject( 'Man_Character' )

import win32com.client
mats = win32com.client.Dispatch( "XSI.Collection" )
s = '{0}.{1},{0}.{2}'.format(mdl.Name, "*.cls.*.material", "*.material")
print s
mats.Items = s

for m in mats:
   print (m)
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 00:41

Re: Convert to JS

Post by EricTRocks » 04 Jul 2013, 14:32

Why is it humiliating? I did it when I first started learning. Probably made some really silly mistakes and if XSIBase was still up there would be evidence of that. However I wasn't embarrassed.

What are you taking a stab at here? All I see is that you're asking someone to do something for you, for free. You need to really dig into learning the languages instead of just asking for someone to write this bit of code, and that bit of code for you.

Buy some books on jscript and python and really learn them.
Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: Convert to JS

Post by xsisupport » 04 Jul 2013, 14:45

EricTRocks wrote:Why is it humiliating? I did it when I first started learning. Probably made some really silly mistakes and if XSIBase was still up there would be evidence of that. However I wasn't embarrassed.

What are you taking a stab at here? All I see is that you're asking someone to do something for you, for free. You need to really dig into learning the languages instead of just asking for someone to write this bit of code, and that bit of code for you.

Buy some books on jscript and python and really learn them.
Yes, I'm so old I can remember when EricTRocks was asking newbie questions :) And now those days are a distant memory.
Anyways, learning scripting takes some time and some googling/reading and experimenting. In this case, if you google "python format" you'll see that that has something to do with strings. So, print the string and you'll see enough to understand what you have to do in JScript, or at least have a rough idea of what direction to take.
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

Falam

Re: Convert to JS

Post by Falam » 05 Jul 2013, 00:02

It's not as if I'm not studying JS, it's getting the right commands and the order right, as with everything. I know I have to search the scene, or search within the model, then find all materials that don't contain a specific node within the material which is my goal.

Code: Select all

var oActiveObjects = new ActiveXObject( "XSI.Collection" );
oActiveObjects.Items = ".[obj].";
From The Softimage Support blog.

I know what is happening up to a point, problem is, I wouldn't know that I need to get the ActiveXObject("XSI.Collection"). I can store the string, I would probably have missed the ActiveXObject part.

Stephen it's no challenge for you, you have this mastered, you worked on this when with Softimage, it's like a baker, baking <insert fancy dessert name> you have it memorized. :)

User avatar
xsisupport
Posts: 713
Joined: 09 Jun 2009, 09:02
Location: Montreal Canada

Re: Convert to JS

Post by xsisupport » 05 Jul 2013, 11:33

Falam wrote:It's not as if I'm not studying JS, it's getting the right commands and the order right, as with everything. I know I have to search the scene, or search within the model, then find all materials that don't contain a specific node within the material which is my goal.

Code: Select all

var oActiveObjects = new ActiveXObject( "XSI.Collection" );
oActiveObjects.Items = ".[obj].";
From The Softimage Support blog.

I know what is happening up to a point, problem is, I wouldn't know that I need to get the ActiveXObject("XSI.Collection"). I can store the string, I would probably have missed the ActiveXObject part.

Stephen it's no challenge for you, you have this mastered, you worked on this when with Softimage, it's like a baker, baking <insert fancy dessert name> you have it memorized. :)
You have to look around the docsand sample code. That's how I learned.
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage