Trouble deleting a color at verticies map through scripting.

Discussions concerning programming of SOFTIMAGE©
Post Reply
User avatar
Pete
Posts: 118
Joined: 16 Jun 2009, 09:28

Trouble deleting a color at verticies map through scripting.

Post by Pete » 20 Jun 2013, 08:34

Hi there,

I'm trying make a little script to remove any color at veriticies maps from the selected object.
The trouble I'm running into is that sometimes the vertex map will end up in different clusters so it's hard to pinpoint.

Sometimes it will be in Texture_Coordinates_AUTO.Vertex_Color but not always so it makes my script break sometimes.

Code: Select all

	var OriginalObject = Selection(0);	
	DeleteObj(OriginalObject.FullName+".polymsh.*.Texture_Coordinates_AUTO.Vertex_Color*");
I realise my script is a bit hacky, Anyone know how I could fix this up a little?

Thanks
Pete

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

Re: Trouble deleting a color at verticies map through scripting.

Post by xsisupport » 20 Jun 2013, 15:11

Code: Select all

si = Application
o = si.Selection(0)

for c in o.ActivePrimitive.Geometry.Clusters:
	for p in c.LocalProperties.Filter( "vertexcolor" ):
		print p
// Steve Blair
// "You're not a runner, you're just a guy who runs" -- my wife
//
// My Blogs: Arnold | Softimage

User avatar
Pete
Posts: 118
Joined: 16 Jun 2009, 09:28

Re: Trouble deleting a color at verticies map through scripting.

Post by Pete » 25 Jun 2013, 06:00

Thanks Steve!
That works perfectly, but I'm struggling to make a JScript version of it :(
This is my latest attempt...

Code: Select all

var si = Application
var o = si.Selection(0)
for ( var c = 0; c < o.ActivePrimitive.Geometry.Clusters.count; c++ ){
	logmessage("Bam!");
	for ( var p = 0; p < 2; p++ ){	
		logmessage(o.ActivePrimitive.Geometry.Clusters[p]LocalProperties.Filter( "vertexcolor" ));
	}
}
If you have a sec maybe you could point me in the right direction.
Thanks
Pete

User avatar
csaez
Posts: 253
Joined: 09 Jul 2012, 15:31
Skype: csaezmargotta
Location: Sydney, Australia
Contact:

Re: Trouble deleting a color at verticies map through scripting.

Post by csaez » 25 Jun 2013, 06:49

:)

Code: Select all

var o = Selection(0);
var cls = o.ActivePrimitive.Geometry.Clusters;
for (var i = 0; i < cls.Count; i++){
    var colors = cls(i).LocalProperties.Filter("vertexcolor");
    for (var j = 0; j < colors.Count; j++){
        LogMessage(colors(j));
    }
}

User avatar
Pete
Posts: 118
Joined: 16 Jun 2009, 09:28

Re: Trouble deleting a color at verticies map through scripting.

Post by Pete » 25 Jun 2013, 07:25

Hey csaez, thanks so much for that! Works great :) \m/

Post Reply

Who is online

Users browsing this forum: No registered users and 32 guests