Inside Sabertooth
Learn how Sabertooth uses 3ds Max to create 3D interactive projects, including HBO Go’s Game of Thrones interactive experience
  • 1/3
You are here: Forum Home / Autodesk 3ds® Max® / MaxScript / Select an object indoors of a group without destroy the group
  RSS 2.0 ATOM  

Select an object indoors of a group without destroy the group
Rate this thread
 
22632
 
Permlink of this thread  
avatar
  • michele71
  • Posted: 11 February 2009 02:42 PM
  • Location: Rome (Italy)
  • Total Posts: 375
  • Joined: 30 August 2006 01:40 AM

Hi to everything!  I hope in a response....

I do not understand how to select an object indoors of a group.

Assume to have 10 Box that form Group01 and 10 Box that form Group02.
I use this array after create and selecting the first 10 box

Array seli_array = $box* as --- take all the present box in the scene
gr_seli_array = group seli_array prefix:GroupBox_” --- assemble the box in GroupBox
I do the same thing with the second group of the box
Now, if I use
a = for the in $Box* collect i.name—array to create a knot taking the name of the box
sel_a = getnodebyname to [1] --- I create the knot from the name and take the first elements of the array
select sel_a--- selects the first element
The my problem: The second group is not calculated by the array and Box01 is always selected.
How to do in the take Box01 from the group 1 and Box11 from the group 2 (the first elements of the array of two groups) or similar ?

Ciao
Michele71



Replies: 0
avatar
  • Location: Quebec City, QC -- Canada
  • Total Posts: 53
  • Joined: 28 August 2006 10:51 PM
  • Permlink of this post

michele71 11 February 2009 05:42 PM

Hi to everything!  I hope in a response....

I do not understand how to select an object indoors of a group.

Assume to have 10 Box that form Group01 and 10 Box that form Group02.
I use this array after create and selecting the first 10 box

Array seli_array = $box* as --- take all the present box in the scene
gr_seli_array = group seli_array prefix:GroupBox_” --- assemble the box in GroupBox
I do the same thing with the second group of the box
Now, if I use
a = for the in $Box* collect i.name—array to create a knot taking the name of the box
sel_a = getnodebyname to [1] --- I create the knot from the name and take the first elements of the array
select sel_a--- selects the first element
The my problem: The second group is not calculated by the array and Box01 is always selected.
How to do in the take Box01 from the group 1 and Box11 from the group 2 (the first elements of the array of two groups) or similar ?

Ciao
Michele71

I just had to deal with this myself, what I did was a multi step thing, first I created an array of all objects, simple enough.

Then I created another array just containing the groups themselves:

fn GroupsOnlyArray messy_array =
    (
    
GroupArray #() -- as always clean it out, just in case
    
    
for obj in messy_array do
        (
        if ( 
isGroupHead obj ) == true do
            (
            
append GroupArray obj
            
)
        )
    if 
GroupArray.count 0 then
        
(
        return 
GroupArray
        
)
    else 
messagebox "There are NO GROUPS in this scene"
    
)

Then I made another array that contains the contents of groups only

fn clearedArray population criminals =
    (
    
clearedList #()
    
loc_isThug
    
    
for ppl in population do
        (
        
loc_isThug false
        
        
for thug 1 to criminals.count do
            ( 
            if 
ppl == criminals[thug] do
                (
                
loc_isThug true
                
)
            )
            
        if 
loc_isThug == false do
            (
                if 
clearedList.count 0 then
                    
(
                    
loc_itshere false -- reinitialize found boolean
                    
for dupes in clearedList do -- check for dupes and set boolean to true if identical entry is found
                        
(
                        if 
ppl == dupes do
                            (
                            
loc_itshere true
                            
)
                        )
                    )
                else
                    (
                    
append clearedList ppl -- append clear list for the very first time
                    
)
                    
                    
                if 
loc_itshere == false do
                    (
                    
append clearedList ppl -- append clearlist if entry is not a dupe
                    
)
                
            ) -- 
appending operations IF ppl is not thug
        
)
    return 
clearedList
    
)

Then I iterated thru the groups-only-array, opened each group, iterated thru the objects-only-array and searched for

isOpenGroupMember

and voila! you get the index entries for all objects contained by that one group, close the group, repeat for next group.

Hope this helps you.

MB



Replies: 0
avatar
  • michele71
  • Posted: 11 February 2009 05:28 PM

....WooWW!! :) :) :) Very , very linear and clear!!  Thanks you so much!!!

I wanted to open a group, select an item and close the group again… I have try this simple script ( remedy the problem) for check the object in the array /

ungroup selection
arr_item = for s in selection collect s.name
min_arr = amin arr_item
se_min_arr = select (getNodeByName min_arr )

/ and now see how close the group again.... Thanks to your help, I have understood the problem more fast and I have spared hours and hours of reading of the Help MAxScript.( ..in really understood from help “group” for me it is tough (:) )

Again a big thank

Ciao
Michele71



Replies: 0