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)
Convert to JS
-
Falam
Convert to JS
I would appreciate if someone could convert this to JS, I'm hoping to extend it's ability.
-
EricTRocks
- Moderator
- Posts: 754
- Joined: 25 Nov 2009, 00:41
Re: Convert to JS
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.
-
Falam
Re: Convert to JS
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.
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.
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: Convert to JS
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:
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)
-
EricTRocks
- Moderator
- Posts: 754
- Joined: 25 Nov 2009, 00:41
Re: Convert to JS
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.
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.
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: Convert to JS
Yes, I'm so old I can remember when EricTRocks was asking newbie questionsEricTRocks 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.
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.
-
Falam
Re: Convert to JS
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.
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.
Code: Select all
var oActiveObjects = new ActiveXObject( "XSI.Collection" );
oActiveObjects.Items = ".[obj].";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.
-
xsisupport
- Posts: 713
- Joined: 09 Jun 2009, 09:02
- Location: Montreal Canada
Re: Convert to JS
You have to look around the docsand sample code. That's how I learned.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.
From The Softimage Support blog.Code: Select all
var oActiveObjects = new ActiveXObject( "XSI.Collection" ); oActiveObjects.Items = ".[obj].";
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.