Notifications
Clear all

[Closed] 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/scripts/primitive-maker#comment-22661
The problem with this is you can’t pick a group object. How can I overcome it?
Thanks
Jack

88 Replies

For this tool you need single node, so attach all nodes and then use primitive maker.

1 Reply
(@lucky6969c)
Joined: 11 months ago

Posts: 0

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

 --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

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?

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

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

1 Reply
(@gazybara)
Joined: 11 months ago

Posts: 0

ok let me try

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.


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 = %
GroupNodes = %
" topGroup groupNodes
			)					
		)
	)
)
createDialog rltPrimitiveMaker 162 75 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow) 

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

4 Replies
(@gazybara)
Joined: 11 months ago

Posts: 0

You think of this function?

	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 	)
(@gazybara)
Joined: 11 months ago

Posts: 0

You think of this function?

   
 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.

(@gazybara)
Joined: 11 months ago

Posts: 0

Example that I mentioned

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]
(@denist)
Joined: 11 months ago

Posts: 0

no. i was wrong… there are three mistakes
the third mistake in the way how you collect geometry objects

:argh: I give up. Please show me what you have
How my solution not works when throws correct result?

i will make you a test scene… wait a little

1 Reply
(@denist)
Joined: 11 months ago

Posts: 0

here is it:


 delete objects
 
 b0 = box pos:[40,0,0] wirecolor:orange
 b1 = box pos:[80,0,0] wirecolor:orange
 
 g0 = group #(b0,b1)
 
 b2 = box pos:[40,40,0] wirecolor:green
 b3 = box pos:[80,40,0] wirecolor:green
 
 g1 = group #(b2,b3)
 g2 = group #(g0,g1)
 
 in (box pos:[0,0,40] wirecolor:blue) (g2.parent = box pos:[0,0,80] wirecolor:red)
 for g in #(g0,g1,g2) do setGroupOpen g on
 

I agree about that.

Page 1 / 6