How to pick a group object?

Become a member of the CGSociety

Connect, Share, and Learn with our Large Growing CG Art Community. It's Free!

THREAD CLOSED
 
Thread Tools Search this Thread Display Modes
Old 06 June 2013   #31
Originally Posted by gazybara: Can you tell me why:
> this works

  b0 = box pos:[40,0,0] wirecolor:orange
  b1 = box pos:[80,0,0] wirecolor:orange
  in (g0 = group #(b0,b1)) (box pos:[0,0,40] wirecolor:blue) 
  

> and this not

  b0 = box pos:[40,0,0] wirecolor:orange
  b1 = box pos:[80,0,0] wirecolor:orange
  in (box pos:[0,0,40] wirecolor:blue) (g0 = group #(b0,b1)) 

there is an eternal bug in group messaging system... it sends some sort of a delayed message... so in the second snippet system doesn't link group to box because group "is not created" at that time
 
Old 06 June 2013   #32
Originally Posted by denisT: there is an eternal bug in group messaging system... it sends some sort of a delayed message... so in the second snippet system doesn't link group to box because group "is not created" at that time

That is useful info. Thanks.
So to return to the isRealGeometry topic.
You told me that is ":"search in geometry is too long... there is a better way"
The only way that i know is selection or objects.
Maybe we can select all groups usring helpers
If we named groups correctly then you can use $Group* or $objects/group*
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 06 June 2013 at 05:01 PM.
 
Old 06 June 2013   #33
Originally Posted by gazybara: That is useful info. Thanks.
So to return to the isRealGeometry topic.
You told me that is ":"search in geometry is too long... there is a better way"
The only way that i know is selection or objects.
Maybe we can select all groups usring helpers
If we named groups correctly then you can use $Group* or $objects/group*

you don't have to search at all to know that the node is geometryclass...
 
Old 06 June 2013   #34
Originally Posted by denisT: you don't have to search at all to know that the node is geometryclass...

What do you suggest I not uderstand?
__________________
Looking in the right side. [bgaTools]
 
Old 06 June 2013   #35
just simple as:

iskindof node geometryclass and canconvertto node editable_mesh
 
Old 06 June 2013   #36
Originally Posted by denisT: just simple as:

  iskindof node geometryclass and canconvertto node editable_mesh
  

Ok you talking about "pickObject" node. Now I get it.
Next is getRootGroupHead
I supose that I need to check if group is opened, right?
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 06 June 2013 at 05:26 PM.
 
Old 06 June 2013   #37
Originally Posted by gazybara: I supose that I need to check if group is opened, right?

nope... try again
 
Old 06 June 2013   #38
This freeze max, i not know why
	
fn getGrandParentGroup obj = 
	(
		groupsArr = #()
		while (obj.parent != undefined) do (if isGroupHead (grp=obj.parent) do append groupsArr grp)
		groupsArr[groupsArr.count]
	)
__________________
Looking in the right side. [bgaTools]
 
Old 06 June 2013   #39
Branko, this is infinite while loop. The obj never changes, so its parent never changes and the max continue to execute the while loop.

The function below will return all parents of the selected object. So, for the test scene it will return $Box005. Then can be checked which object in the allObjParents are group head or group member.


(
   (
	local allObjParents = #()
	function FindRootParrent obj =
	(	   
		parent = obj.parent
		if parent != undefined then
		(
			append allObjParents obj
			FindRootParrent parent
		)
		else
		(
			append allObjParents obj
			obj
		)
		--
		objParents
	)
	FindRootParrent $Box001
	format "allObjParents: % \n" allObjParents
)
 
Old 06 June 2013   #40
Originally Posted by miauu: Branko, this is infinite while loop. The obj never changes, so its parent never changes and the max continue to execute the while loop.

The function below will return all parents of the selected object. So, for the test scene it will return $Box005. Then can be checked which object in the allObjParents are group head or group member.


 (
    (
 	local allObjParents = #()
 	function FindRootParrent obj =
 	(	   
 		parent = obj.parent
 		if parent != undefined then
 		(
 			append allObjParents obj
 			FindRootParrent parent
 		)
 		else
 		(
 			append allObjParents obj
 			obj
 		)
 		--
 		objParents
 	)
 	FindRootParrent $Box001
 	format "allObjParents: % \n" allObjParents
 )

I know how to find all parents but are you try to find root group in Denis example ("Group003"). He mentioned one line of code for that
__________________
Looking in the right side. [bgaTools]
 
Old 06 June 2013   #41
Denis have one line solution, I have 100 lines solution - ugly, but I hope my solution to works properly no matter of how big the code is.


(
	 local allObjParents = #()
	 function FindRootParrent obj =
	 (	   
		 parent = obj.parent
		 if parent != undefined then
		 (
			 append allObjParents obj
			 FindRootParrent parent
		 )
		 else
		 (
			 append allObjParents obj
			 obj
		 )
		 --
		 objParents
	 )
	 FindRootParrent $Box001
	 
	notFound = false
	groupHead = undefined
	for i = allObjParents.count to 1 by -1 while notFound == false do
	(
		if (isGroupHead allObjParents[i] or isOpenGroupHead allObjParents[i]) and (not (isGroupMember allObjParents[i])) do
		(
			groupHead = allObjParents[i]
			notFound = true
		)
	)
	format "groupHead: % \n" groupHead	
)
 
Old 06 June 2013   #42
Originally Posted by miauu: Denis have one line solution, I have 100 lines solution - ugly, but I hope my solution to works properly no matter of how big the code is.


  (
  	 local allObjParents = #()
  	 function FindRootParrent obj =
  	 (	   
  		 parent = obj.parent
  		 if parent != undefined then
  		 (
  			 append allObjParents obj
  			 FindRootParrent parent
  		 )
  		 else
  		 (
  			 append allObjParents obj
  			 obj
  		 )
  		 --
  		 objParents
  	 )
  	 FindRootParrent $Box001
  	 
  	notFound = false
  	groupHead = undefined
  	for i = allObjParents.count to 1 by -1 while notFound == false do
  	(
  		if (isGroupHead allObjParents[i] or isOpenGroupHead allObjParents[i]) and (not (isGroupMember allObjParents[i])) do
  		(
  			groupHead = allObjParents[i]
  			notFound = true
  		)
  	)
  	format "groupHead: % \n" groupHead	
  )
  

Can you try this
fn FindRootGroup obj &master=
(	   
	if (p = obj.parent) != undefined do (if isGroupHead p do master = p ; FindRootGroup p &master)
)
FindRootGroup $Box001 &master
master

What do you think? Close enough?
__________________
Looking in the right side. [bgaTools]
 
Old 06 June 2013   #43
Originally Posted by gazybara: Ok you talking about "pickObject" node. Now I get it.
Next is getRootGroupHead
I supose that I need to check if group is opened, right?

this is not for picking node. it's for loop where we have to collect only real geometries which can be converted to simple object plug-in
 
Old 06 June 2013   #44
Return the correct result.
Denis have to say how close it is to his solution.
Mine is far far away.
 
Old 06 June 2013   #45
and to find a root group head we really need only one line:

while <condition> do <iteration>
 
Thread Closed share thread



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 08:06 AM.


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