PDA

View Full Version : Dropdownlist problem


carlos_ramiro
06-26-2006, 07:09 AM
Hi

I'm quite new with maxscript, so here is my problem.

I want to use dropdownlist, so when i select first item on the dropdownlist, 2 objects in my scene are linked and selecting the second item on the dropdownlist, these 2 objects are unlinked.

I have 2 problems;

First, going back to dropdownlist always shows first item selected, never stays on second item.

Second, i don't know what is the argument i have to use on the event "on <dropdownlist> selected <arg> do <expr>"

This is what i have for now

ca=attributes parentto
(
rollout parentroll "Parent to"
(
dropdownlist parentdrop "Parent to:" items:#("World", "Body")
on parentdrop selected i do
$.parent = $Sphere01
)
)
custattributes.add $.modifiers[1] ca

thanks

Jeff_hanna
06-26-2006, 02:40 PM
Your event handler code for the dropdownlist isn't using the selection. It's always parenting the selected object(s) to $Sphere01. You need to use the selection to determine the action.


dropdownlist parentdrop "Parent to:" items:#("World", "Body")
on parentdrop selected i do
(
case i of (
-- the user picked "World"
1: for obj in selection do (
obj.parent = undefined
)

-- the user picked "Body"
2: for i = 2 to selection.count do (
selection[i].parent = selection[i - 1]
)
)
)


In that example if the user picks "World" then any/all selected objects will be come unparented. If the user picks "Body" then every object in the selection will be parented to whichever object comes before it.

selection is a system array that holds the currently selected item(s) in the viewport. The size of the array will always be equal to the number of currently selected objects.

CGTalk Moderation
06-26-2006, 02:40 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.