Group Attaching

Tell me please, I just want to make the same operation like simple attach group tool! I need to use this:

attachNodesToGroup

I know that I can use

on atachbtn click do 
( 
   attachNodesToGroup selection <targetNode> 
) 

but how to define targetnode that will be a group? It means that selection should be attached to the picked group=>finally it will be a group as well! How to pick a group by script? Thx in advance!

on atachbtn picked obj do 
( 
   if isValidNode obj AND isGroupHead obj do 
   print obj.name 
)

doesn't work for me

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
artrender.info's picture

Barigazy, thanks!

I have sent you an email! Read when you can please!

artrender.info's picture

oh, finally, Barigazy!

You did a brilliant work! Thank you so much - even with visual line :)

HUUUGS!

barigazy's picture

:)

You mean "rubber Band" ;) My pleasure

barigazy

barigazy's picture

To prevent flickering use

To prevent flickering use this way

if isGroupHead (grpHead = getGrandParentName grpMember) do with redraw off attachNodesToGroup selection grpHead

barigazy

artrender.info's picture

thx Miauu

the problem is that first we have selection (it can be an object, group or even more then 1 object selected - t.e. torus001 from the picture of barigazy)! With this you pick the group(group001 from pic) that will attach your previous selection(torus001)!

my difficulty is to get the selection after you pressed on atachbtn and immediately to be able to pick the group that will take this selection inside!

Thank you again for your patience and for the wish to help!!!

miauu's picture

I hope that this will help you.

This function will return the top most group head(work with hested groups also).

function FindTopMostGroupHead obj = 
	(
		res = undefined
		if ((isGroupHead obj) AND (not (isGroupMember obj))) then
			result = obj
		else
		(
			if (isGroupMember obj) then
				FindTopmostGroupHead (obj.parent) 
			else
				result = undefined
		)
		--	return
		res
	)

Using the atachbtn you can pick an object that is a part of a group, then the fn above will return the group head and you can attach the object that you want(is selected or stored in array) to the group head.

on atachbtn picked obj do 
( 
	grpHead = FindTopMostGroupHead obj
	if isValidNode obj  do 
	(
		grpHead = FindTopMostGroupHead obj
		if grpHead != undefined then
			print "Picked object is part of a group. Attach the objects that you want to grpHead"
		else
			print "Picked object is not a part of a group"
	)
)
barigazy's picture

:)

Hey Kostadin
you are fester then me.

@artrender

See this image

You have Torus and one group which contains box sphere and teapot.
Schematic view shows you everithing that you need to know.
Group Head ei. helper is the grand parent of theses tree nodes.

barigazy

barigazy's picture

...

Previous image code
Select Torus and then Group and try next line

sourceObj = selection[1]
targetObj = (for i in 2 to selection.count where selection[i].parent == undefined and isgroupHead selection[i] collect selection[i])[1]
attachNodesToGroup sourceObj targetObj

barigazy

artrender.info's picture

the idea is good

but default attach tool doesn't work like it! It works when the object is selected and then when pressed on attachbtn you can pick the group that will attach the object

what if you have 2 toruses to attach at once? or even more?

barigazy's picture

Then select first theses two

Then select first theses two toruses first then group and start for loop from number 3
for i = 3 to ...
Are you want pickObject method maybe (select objects that you need to attach and activae picking)?

barigazy

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.