CGTalk > Software > Autodesk 3ds max > 3dsMax SDK and MaxScript
Login register
Thread Closed share thread « Previous Thread | Next Thread »
 
Thread Tools Search this Thread Display Modes
Old 06-09-2013, 12:53 AM   #1
lucky6969c
Frequenter
portfolio
Jack
Hong Kong, Hong Kong
 
Join Date: Oct 2009
Posts: 103
How to pick a group object?

I need to pick a group object in order to create a custom primitive.
It's called primitive maker
http://www.scriptspot.com/3ds-max/s...r#comment-22661
The problem with this is you can't pick a group object. How can I overcome it?
Thanks
Jack
 
Old 06-09-2013, 07:51 AM   #2
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by lucky6969c
I need to pick a group object in order to create a custom primitive.
It's called primitive maker
http://www.scriptspot.com/3ds-max/s...r#comment-22661
The problem with this is you can't pick a group object. How can I overcome it?
Thanks
Jack

For this tool you need single node, so attach all nodes and then use primitive maker.
__________________
Looking in the right side. [bgaTools]
 
Old 06-09-2013, 08:47 AM   #3
lucky6969c
Frequenter
portfolio
Jack
Hong Kong, Hong Kong
 
Join Date: Oct 2009
Posts: 103
Quote:
Originally Posted by gazybara
For this tool you need single node, so attach all nodes and then use primitive maker.


As indicated by another forum poster, I think it's the correct way of doing it.
But I'd like to run circles after discovering this.

This coding has a thingy called superClassOf GeometryClass, anywhere I can turn it to a group object and exclude GeometryClass?

I am looking everywhere for a reference to no avail.

Let me know.

Jack
 
Old 06-09-2013, 09:09 AM   #4
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by lucky6969c
As indicated by another forum poster, I think it's the correct way of doing it.
But I'd like to run circles after discovering this.

This coding has a thingy called superClassOf GeometryClass, anywhere I can turn it to a group object and exclude GeometryClass?

I am looking everywhere for a reference to no avail.

Let me know.

Jack

Group object is the helper object.Also it is the parent of all geometries (group members)
You can use many different methods to isolate only group object

Code:
--this will collect all groups inside selection for o in selection where isGroupHead o collect o for o in selection where not isGroupMember o collect o --if you try to isolate only top-most group then for o in selection where isGroupHead o and o.parent == undefined collect o --to collect all top-most groups in the scene for o in helpers where isGroupHead o and o.parent == undefined collect o

There is more but I think this is good for the start
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 06-09-2013 at 09:15 AM.
 
Old 06-09-2013, 10:00 AM   #5
lucky6969c
Frequenter
portfolio
Jack
Hong Kong, Hong Kong
 
Join Date: Oct 2009
Posts: 103
Code:
rollout rltPrimitiveMaker "Primitive Maker" width:162 height:112 ( editText editName "Name:" editText editCat "Cat.:" --fn isGeom obj = superClassOf obj == geometryClass or superClassOf obj == shape pickButton pickObj "Pick Template Object" width:140 --filter:isGroup width:140 --this will collect all groups inside selection o += for obj in selection where isGroupHead obj collect obj o += for obj in selection where not isGroupMember obj collect obj --if you try to isolate only top-most group then o += for obj in selection where isGroupHead obj and obj.parent == undefined collect obj --to collect all top-most groups in the scene o += for obj in helpers where isGroupHead obj and obj.parent == undefined collect obj


I don't know if I've done it correctly, I tried to collect all objects into a array called o,
How can I declare it?
 
Old 06-09-2013, 10:31 AM   #6
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by lucky6969c
I don't know if I've done it correctly, I tried to collect all objects into a array called o,
How can I declare it?

No this is a mess
Can you explain what exactly want to achive here.
__________________
Looking in the right side. [bgaTools]
 
Old 06-09-2013, 10:42 AM   #7
lucky6969c
Frequenter
portfolio
Jack
Hong Kong, Hong Kong
 
Join Date: Oct 2009
Posts: 103
Quote:
Originally Posted by gazybara
No this is a mess
Can you explain what exactly want to achive here.


I'd like to pick a group object which contains a set of editable meshes/polys,
Then loop thru each individual mesh/poly inside that group and add to an array of some sort then export the set out to a plugin.
Thanks
Jack
 
Old 06-09-2013, 11:01 AM   #8
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by lucky6969c
I'd like to pick a group object which contains a set of editable meshes/polys,
Then loop thru each individual mesh/poly inside that group and add to an array of some sort then export the set out to a plugin.
Thanks
Jack

ok let me try
__________________
Looking in the right side. [bgaTools]
 
Old 06-09-2013, 11:49 AM   #9
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
With this you can collect all geometries inside top-most group.
Use pick button and select one of the group member then look in the listener for the result.
Now you can combine you another code for "creating geometry plugin" with my code.
Code:
try(destroydialog ::rltPrimitiveMaker)catch() rollout rltPrimitiveMaker "Primitive Maker" ( local groupNodes = #() fn filtobj o = isGroupMember o fn getGrandParentGroup obj = ( while (obj.parent != undefined) do obj = obj.parent if not isGroupHead obj do (for i in obj.children where isGroupHead i do (obj = i ; exit)) obj ) editText editName "Name:" editText editCat "Cat.:" pickButton pickObj "Pick Template Object" width:140 filter:filtobj on pickObj picked obj do ( if obj != undefined do ( local topGroup = getGrandParentGroup obj if topGroup.children.count != 0 do ( for m in topGroup.children where isKindOf m GeometryClass and not isKindOf m Targetobject do append groupNodes m format "TopGroup = %\nGroupNodes = %\n" topGroup groupNodes ) ) ) ) createDialog rltPrimitiveMaker 162 75 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
__________________
Looking in the right side. [bgaTools]
 
Old 06-09-2013, 03:17 PM   #10
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,637
Send a message via ICQ to denisT
there are two mistakes in this code... it doesn't work for groups which are grandchildren of not a group head, and it doesn't work for nested groups
 
Old 06-09-2013, 03:25 PM   #11
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by denisT
there are two mistakes in this code... it doesn't work for groups which are grandchildren of not a group head, and it doesn't work for nested groups

You think of this function?
Code:
fn getGrandParentGroup obj = ( while (obj.parent != undefined) do obj = obj.parent if not isGroupHead obj do (for i in obj.children where isGroupHead i do (obj = i ; exit)) obj )
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 06-10-2013 at 11:08 PM.
 
Old 06-09-2013, 03:27 PM   #12
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by denisT
there are two mistakes in this code... it doesn't work for groups which are grandchildren of not a group head, and it doesn't work for nested groups

You think of this function?
Code:
fn getGrandParentGroup obj = ( while (obj.parent != undefined) do obj = obj.parent if not isGroupHead obj do (for i in obj.children where isGroupHead i do (obj = i ; exit)) obj )

I tested this with 2 nested group and main(top group) are linked to another object.
__________________
Looking in the right side. [bgaTools]
 
Old 06-09-2013, 03:42 PM   #13
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by gazybara
I tested this with 2 nested group and main(top group) are linked to another object.

Example that I mentioned
Code:
for i = 1 to 2 do Sphere pos:(random [0,0,0] [100,100,100]) radius:5 group $Sphere* name:"GroupSpheres" for i = 1 to 2 do Teapot pos:(random [0,0,0] [100,100,100]) radius:5 group $Teapot* name:"GroupTeapots" group $Group* name:"Master" $Master.parent = (point size:10 wirecolor:yellow) fn getGrandParentGroup obj = ( while (obj.parent != undefined) do obj = obj.parent if not isGroupHead obj do (for i in obj.children where isGroupHead i do (obj = i ; exit)) obj ) getGrandParentGroup $Sphere001 --$Dummy:Master @ [83.962059,73.896439,63.433228]
__________________
Looking in the right side. [bgaTools]
 
Old 06-09-2013, 03:44 PM   #14
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,637
Send a message via ICQ to denisT
Quote:
Originally Posted by denisT
there are two mistakes in this code... it doesn't work for groups which are grandchildren of not a group head, and it doesn't work for nested groups

no. i was wrong... there are three mistakes
the third mistake in the way how you collect geometry objects
 
Old 06-09-2013, 03:46 PM   #15
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by denisT
no. i was wrong... there are three mistakes

I give up. Please show me what you have
How my solution not works when throws correct result?
__________________
Looking in the right side. [bgaTools]
 
Thread Closed share thread


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
CGSociety
Society of Digital Artists
www.cgsociety.org

Powered by vBulletin
Copyright ©2000 - 2006,
Jelsoft Enterprises Ltd.
Minimize Ads
Forum Jump
Miscellaneous

All times are GMT. The time now is 05:19 AM.


Powered by vBulletin
Copyright ©2000 - 2016, Jelsoft Enterprises Ltd.