selection list (VBS)

Discussions concerning programming of SOFTIMAGE©
Post Reply
caledonian_tartan
Posts: 253
Joined: 17 Feb 2010, 15:13

selection list (VBS)

Post by caledonian_tartan » 30 May 2013, 11:20

hello
trying to make a little script. atm it's VBS, but it doesn't really matter...

the problem is with multiple selected objects:

Code: Select all

GetValue( "SelectionList" )&".light"
leads to

Code: Select all

"VRay_Light1,VRay_Light.light"
but i'd like to get something like

Code: Select all

"VRay_Light1.light", "VRay_Light.light"
so that the logic gets executed on every object instead of just the last one...
SI 2015 @ WIN7-64

julca
Posts: 145
Joined: 07 Sep 2012, 14:24

Re: selection list (VBS)

Post by julca » 30 May 2013, 12:25

Hello,

You can try this :

Code: Select all

Set mySelection = CreateObject( "XSI.Collection" )
mySelection.AddItems Application.Selection

myText = ""
for i = 0 to mySelection.Count - 1
	myText = myText & """" & mySelection(i) & ".Light" & """"
	
	'If it's the last element, we won't add ','
	if i <> mySelection.Count then
		myText = myText & ", "
	end if
next 

logMessage "myText = " & myText
I don't know if it's the better way but it work well ;;) .

julca
Posts: 145
Joined: 07 Sep 2012, 14:24

Re: selection list (VBS)

Post by julca » 30 May 2013, 12:45

Or you can write this :

Code: Select all

myText = Application.Selection.GetAsText
myText = """" & Replace(myText, ",", ".Light, """) & """"
logMessage "myText = " & myText
Cheers.

caledonian_tartan
Posts: 253
Joined: 17 Feb 2010, 15:13

Re: selection list (VBS)

Post by caledonian_tartan » 30 May 2013, 13:25

arrrghhh.
too easy.
thanks guys!

(also:)

Code: Select all

for each oObj in Selection
LogMessage oObj.fullname
next
SI 2015 @ WIN7-64

julca
Posts: 145
Joined: 07 Sep 2012, 14:24

Re: selection list (VBS)

Post by julca » 30 May 2013, 13:33

Your welcome ;) !

EricTRocks
Moderator
Posts: 754
Joined: 25 Nov 2009, 01:41
Contact:

Re: selection list (VBS)

Post by EricTRocks » 30 May 2013, 15:53

Code: Select all

# Python

xsi = Application
log = xsi.LogMessage
sel = xsi.Selection

# Comma separated list
log(sel.GetAsText())

# Quoted, comma separated list
log(",".join(['"' + x.FullName + '"' for x in sel]))

Eric Thivierge
Lead Kraken Developer, Fabric Engine
http://fabric-engine.github.io/Kraken

Post Reply

Who is online

Users browsing this forum: No registered users and 30 guests