PDA

View Full Version : Layout Command SelectByName



ernpchan
01-05-2015, 08:06 PM
What's the proper way to call the Layout Command SelectByName? I feel like I've tried every variation of string creation and it's not working.


item = 'Null'

lwCmd = 'SelectByName("' + item + '")'
print lwCmd
lwsdk.command(lwCmd)

ernpchan
01-05-2015, 08:11 PM
Or should I be using SelectItem instead?

Either way I can't figure out the syntax. :stumped:

Ryan Roye
01-05-2015, 08:17 PM
You may have discovered that when performing "commands", everything needs to be treated as a string. With that mindset, here's a sample script that would select a null called "MyNull" using a variable.



myvariable = "MyNull"
lwsdk.command("SelectByName " + myvariable)


In more elaborate scripts, you may have a series of strings contained in both the item name and as variables. My massmotion plugin, for example, has this:


lwsdk.command("SelectByName RR_MassMotion_" + MassMotionItem + "_" + itemSelect[x])

Keep in mind that you need to be very aware of any spacing regarding ALL layout commands, especially when you start delving into things like creating and hooking up expressions. If things start getting confusing, it may be helpful to use the "print" function so you can see what your string looks like so it matches the syntax expected.

- - - Updated - - -


Or should I be using SelectItem instead?

SelectItem should be used in place of SelectByName if you need your script to remember what the user had selected and eventually re-select items.

ernpchan
01-05-2015, 08:23 PM
Thanks!

Sensei
01-06-2015, 07:33 AM
Press Utilities > Cmd History..
and then do something in Layout.
And you will see which command does what.
You can experiment by entering command in string field.

See this video how I am using this feature to call TrueArt's Modeling Pack (http://modelingpack.trueart.eu) commands
https://www.youtube.com/watch?v=tRgfbGryUYo

SelectItem xID
is accepting hex 8 digits.
LWItemID