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 (14)
Comment policy
Barigazy, thanks!
I have sent you an email! Read when you can please!
oh, finally, Barigazy!
You did a brilliant work! Thank you so much - even with visual line :)
HUUUGS!
:)
You mean "rubber Band" ;) My pleasure
To prevent flickering use this way
if isGroupHead (grpHead = getGrandParentName grpMember) do with redraw off attachNodesToGroup selection grpHead
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!!!
I hope that this will help you.
This function will return the top most group head(work with hested groups also).
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.
:)
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.
oh! Barigazy connected
so nice to see you here!!!
:)
Yup. I'm here and just finish my new tool and post it on "Scripts" page.
Whole day I try to find a bug and finaly "seed" function is the main reason for the lost time. Thanks to Kostadin (miauuu) and DenisT problem are solved.
ow great
let's see
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
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?
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)?
This is funny work around
Try this
select some objects that you want to attach then run code below and pick any group member
fn getGrandParentName obj = (while obj.parent != undefined do obj = obj.parent)
fn groupFilt o = (isGroupMember o)
if selection.count != 0 do
(
grpMember = pickObject count:1 filter:groupFilt rubberBand:selection.center rubberBandColor:yellow
if isValidNode grpMember do
(
if isGroupHead (grpHead = getGrandParentName grpMember) do attachNodesToGroup selection grpHead
)
)