Select Materials without Shader from Model

Discussions concerning programming of SOFTIMAGE©
Post Reply
Falam

Select Materials without Shader from Model

Post by Falam » 05 Jul 2013, 19:39

Code: Select all

//JScript
//How do you search within the model for materials that don't have a specfic shader ?
// One thing I realize that X3DObject is strictly any [object] in the scene, similar to DOM.

oRoot =  ActiveProject.ActiveScene.Root
var sphere = Model.FindChildren("model", "#model",);
oRoot = MaterialCollection.find("Material")
I added the comments within the code snippet. The goal of the script is to search within a model, and select any materials that don't contain a specific shader node in the rendertree.

This code is completely separate, debugging test.
---------

Code: Select all

//JScript
oRoot =  ActiveProject.ActiveScene.Root
var oNull = oRoot.addNull( "thenull" );
var oCamera = oNull.AddCamera('camera','mycamera');
var link = ParentObj ("oNull","oCamera");
Root.LogMessage = ("objects parented");
Wondering why the LogMessage isn't displaying the string. I replaced the string in LogMessage with a variable, no message is logged.

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

Re: Select Materials without Shader from Model

Post by xsisupport » 05 Jul 2013, 22:04

I already suggested how to figure out whether a material does or does not contain a certain shader: get all shaders under the material and then search that.

Did you run that debugging snippet? Surely you must have got an error for the ParentObj call???

And since it's Friday:

Code: Select all

var LogMessage=new Object();
LogMessage.LogMessage="LogMessage"
Application.LogMessage( LogMessage.LogMessage )
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

luceric
Posts: 1251
Joined: 22 Jun 2009, 00:08

Re: Select Materials without Shader from Model

Post by luceric » 05 Jul 2013, 23:09

Falam wrote:

Code: Select all

Root.LogMessage = ("objects parented");
what were you thinking when you wrote that?

Falam

Re: Select Materials without Shader from Model

Post by Falam » 06 Jul 2013, 04:27

Code: Select all

oRoot = Application.ActiveSceneRoot
oRoot.addNull( "thenull" );
var oCamera = oRoot.AddCamera('camera','mycamera');
ParentObj ("thenull","mycamera");
Application.LogMessage(oRoot);
Next Select Materials Script.

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

Re: Select Materials without Shader from Model

Post by myara » 30 Jul 2013, 12:49

Falam wrote:

Code: Select all

oRoot = Application.ActiveSceneRoot
Application.LogMessage(oRoot);
Why do you want to log the Scene Root?

Just a tip, if you use a variable when you create "thenull", you'll have it as an object.
Then you can add a camera to this object and ParentObj won't be needed.

Code: Select all

var r = ActiveSceneRoot
var n = r.addNull("theNull")
n.AddCamera("camera","mycamera")
And if you are writing in Jscript and you're not planing to translate it to python, then you don't need to write "Application" all the time. Even then, you could use a variable for that.
M.Yara
Character Modeler | Softimage Generalist (sort of)

Falam

Re: Select Materials without Shader from Model

Post by Falam » 30 Jul 2013, 15:51

myara wrote:
Falam wrote:

Code: Select all

oRoot = Application.ActiveSceneRoot
Application.LogMessage(oRoot);
Why do you want to log the Scene Root?

Just a tip, if you use a variable when you create "thenull", you'll have it as an object.
Then you can add a camera to this object and ParentObj won't be needed.

Code: Select all

var r = ActiveSceneRoot
var n = r.addNull("theNull")
n.AddCamera("camera","mycamera")
And if you are writing in Jscript and you're not planing to translate it to python, then you don't need to write "Application" all the time. Even then, you could use a variable for that.
Your making the Camera a child of the Null, correct ?

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

Re: Select Materials without Shader from Model

Post by myara » 30 Jul 2013, 16:06

Oh, nevermind, I got it wrong.
M.Yara
Character Modeler | Softimage Generalist (sort of)

Post Reply

Who is online

Users browsing this forum: No registered users and 39 guests