Learning to Script

Discussions concerning programming of SOFTIMAGE©
Post Reply
User avatar
Diurno
Posts: 242
Joined: 10 Jun 2009, 09:50

Learning to Script

Post by Diurno » 21 Jul 2009, 16:31

Hi all, i want to learn a little bit of scripting (i'm triyng VB) and for the first try i want to do a little script that takes the Selected Object and Extract all his polygon in separated object; so i've wrote this:

Code: Select all

i = 1
Do
SelectPolygonFilter
SelectGeometryComponents "sphere.poly[1]"
ExtractFromComponents "ExtractPolygonsOp", , "polymsh_detached", True, siImmediateOperation, siKeepGenOpInputs
i = i + 1
Loop Until i = 100
[/b] (here i can increase the number as i wish)

now the problem is: the script works only if the object name is "sphere", so i ask if you know what is the command for "get the name of the selected object".

edit: I placed the code inbetween

Code: Select all

-tags for optimal readability - HB[/color][/size]

User avatar
origin
Posts: 619
Joined: 09 Jun 2009, 11:59
Location: warsaw

Re: Learning to Script

Post by origin » 21 Jul 2009, 19:33

application.selection

see manual: c# and scripting reference->objects->S->Selection

or

http://softimage.wiki.softimage.com/ind ... :Scripting

or videos about scripting from Letterbox viewtopic.php?f=5&p=993#p993

User avatar
septopus
Posts: 12
Joined: 22 Sep 2009, 23:37
Contact:

Re: Learning to Script

Post by septopus » 25 Sep 2009, 00:29

slow on large objs.....

mad slow

Code: Select all

var oSel = selection(0);
var oPoly = oSel.ActivePrimitive.Geometry.facets;
SetSelFilter("Polygon");
for (var i = 0; i<oPoly.count; i++){
SelectGeometryComponents(oPoly(i));
ExtractFromComponents("ExtractPolygonsOp")
}

User avatar
Hirazi Blue
Administrator
Posts: 5107
Joined: 04 Jun 2009, 12:15

Re: Learning to Script

Post by Hirazi Blue » 27 Sep 2009, 12:16

@septopus - Just a friendly suggestion: when dealing with scripting newbies,
it might be helpful to add the scripting language your code snippet is written in...
In the above case it seems to be javascript, if I am not horribly mistaken... :-ss
;)
Stay safe, sane & healthy!

Post Reply

Who is online

Users browsing this forum: No registered users and 45 guests