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-14-2013, 06:13 PM   #46
denisT
MAX Doctor
 
denisT's Avatar
portfolio
Denis Trofimov
CA, USA
 
Join Date: Jul 2009
Posts: 9,306
Send a message via ICQ to denisT
here is a sample of sensibly organized scene:
we have furniture items: tables, chairs, cocktail tables, etc.
we have some on table things: plates, forks, knives, glasses, etc

furniture might be grouped in groups: two chair table, three... four, double table, table and cocktail table.., etc.
table things also can be specifically grouped...

and now is the same task: Get a node (or many nodes from table things) or whole table thing group and attach it to any furniture group or just a member of the group.

does it make scene?
but the tool provided does do it for root heads only... and we can't use only selected members to clone or attach to. Do we have to write new tool every time when we slightly modify the rules?
 
Old 06-14-2013, 06:53 PM   #47
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Quote:
Originally Posted by denisT
here is a sample of sensibly organized scene:
we have furniture items: tables, chairs, cocktail tables, etc.
we have some on table things: plates, forks, knives, glasses, etc

furniture might be grouped in groups: two chair table, three... four, double table, table and cocktail table.., etc.
table things also can be specifically grouped...

and now is the same task: Get a node (or many nodes from table things) or whole table thing group and attach it to any furniture group or just a member of the group.

does it make scene?
but the tool provided does do it for root heads only... and we can't use only selected members to clone or attach to. Do we have to write new tool every time when we slightly modify the rules?

I agree with you. But maybe is better to write now when we starts this topic a new tool "Group Manager" something like "Outliner" or "Named Selection Sets" dialog which is BTW broken in max2014. I was thinking of simple "tree list" dialog which will shows only current scene groups. Then it would be very easy to assign a selections to any group even if the group is nested. Also we can add all the options like: attach, detach, open, close group etc.
I'd love to participate in this challenge
This idea can be related to Denis previous thread "a discussion about a delicate matter... "
because we will talk about mxs and .net controls
__________________
Looking in the right side. [bgaTools]

Last edited by gazybara : 06-14-2013 at 07:09 PM.
 
Old 06-14-2013, 11:59 PM   #48
try2script
Expert
portfolio
Mike
Moldova
 
Join Date: Mar 2013
Posts: 484
I'm very close to the FINISH

Code:
try(destroyDialog ::bgaRoll)catch() rollout bgaRoll "• • •" ( fn filtGroup o = isGroupMember o or isGroupHead o fn getRootClosedGroupHead node = if node != undefined do ( if isgroupmember node then ( if isOpenGroupHead node.parent then ( detachNodesFromGroup node node ) else getRootClosedGroupHead node.parent ) else node ) --<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> fn getRootGroupHead node = if node != undefined do ( if isgroupmember node then ( getRootGroupHead node.parent ) else node ) pickbutton pick "PickGroup" pos:[5,5] width:100 height:20 filter:filtGroup on pick picked destObj do if destObj != undefined and selection.count !=0 do ( attachingNodes = #() attachingNodesInstances = #() destinationGroups = #() local rootGroup = getRootGroupHead destObj InstanceMgr.GetInstances rootGroup &groups for i = 1 to groups.count do appendIfUnique destinationGroups (getRootGroupHead groups[i]) for s in selection do if (q=(getRootClosedGroupHead s)) != rootGroup then appendIfUnique attachingNodes q nodeCounts = 0 if destinationGroups.count > 1 and attachingNodes.count>0 then ( with redraw off ( for i = 1 to destinationGroups.count where destinationGroups[i] != rootGroup do ( maxOps.cloneNodes attachingNodes cloneType:#instance newNodes:&objs for o in objs do ( appendIfUnique attachingNodesInstances (getRootGroupHead o) if attachingNodesInstances.count>nodeCounts then ( nodeCounts+=1 tm = o.transform * (inverse rootGroup.transform) o.transform = tm*destinationGroups[i].transform --attachNodesToGroup o destinationGroups[i] ) ) ) ) ) else print "make another selection" ) ) createDialog bgaRoll 110 30 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)


The only thing is that I don't know how to attach attachingnodes to destinationgroups! If attachingnodes are groups, then I get error if I attach! If I don't use attach, the script is working fine! Thank you Denis and Branko for your great begining!
 
Old 06-15-2013, 07:23 AM   #49
try2script
Expert
portfolio
Mike
Moldova
 
Join Date: Mar 2013
Posts: 484
Finished

Code:
try(destroyDialog ::bgaRoll)catch() rollout bgaRoll "• • •" ( fn filtGroup o = isGroupMember o or isGroupHead o fn getRootClosedGroupHead node = if node != undefined do ( if isgroupmember node then ( if isOpenGroupHead node.parent then ( detachNodesFromGroup node node ) else getRootClosedGroupHead node.parent ) else node ) --<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> fn getRootGroupHead node = if node != undefined do ( if isgroupmember node then ( getRootGroupHead node.parent ) else node ) pickbutton pick "PickGroup" pos:[5,5] width:100 height:20 filter:filtGroup on pick picked destObj do if destObj != undefined and selection.count !=0 do ( attachingNodes = #() attachingNodesInstances = #() destinationGroups = #() local rootGroup = getRootGroupHead destObj InstanceMgr.GetInstances rootGroup &groups for i = 1 to groups.count do appendIfUnique destinationGroups (getRootGroupHead groups[i]) for s in selection do if (q=(getRootClosedGroupHead s)) != rootGroup then appendIfUnique attachingNodes q nodeCounts = 0 if destinationGroups.count > 1 and attachingNodes.count>0 then ( with redraw off ( for i = 1 to destinationGroups.count where destinationGroups[i] != rootGroup do ( maxOps.cloneNodes attachingNodes cloneType:#instance newNodes:&objs for o in objs do ( appendIfUnique attachingNodesInstances (getRootGroupHead o) if attachingNodesInstances.count>nodeCounts then ( nodeCounts+=1 tm = o.transform * (inverse rootGroup.transform) o.transform = tm*destinationGroups[i].transform ) ) attachNodesToGroup objs destinationGroups[i] ) attachNodesToGroup attachingNodes rootGroup ) ) else print "make another selection" ) ) createDialog bgaRoll 110 30 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
 
Old 06-15-2013, 08:14 AM   #50
try2script
Expert
portfolio
Mike
Moldova
 
Join Date: Mar 2013
Posts: 484
Quote:
Originally Posted by denisT
and undo "Attach" on to pick object at least


Denis, please help to make my tool undoable! I don't understand how

Here is the final code

Code:
try(destroyDialog ::bgaRoll)catch() rollout bgaRoll "• • •" ( fn filtGroup o = isGroupMember o or isGroupHead o fn getRootClosedGroupHead node = if node != undefined do ( if isgroupmember node then ( if isOpenGroupHead node.parent then ( detachNodesFromGroup node node ) else getRootClosedGroupHead node.parent ) else node ) --<<<<<<<<<<<<>>>>>>>>>>>>>>>>>>>>>>>>>> fn getRootGroupHead node = if node != undefined do ( if isgroupmember node then ( getRootGroupHead node.parent ) else node ) pickbutton pick "PickGroup" pos:[5,5] width:100 height:20 filter:filtGroup on pick picked destObj do if destObj != undefined do ( attachingNodes = #() attachingNodesInstances = #() destinationGroups = #() if selection.count == 0 then print "select attaching nodes first :)" else ( local rootGroup = getRootGroupHead destObj InstanceMgr.GetInstances rootGroup &groups for i = 1 to groups.count do appendIfUnique destinationGroups (getRootGroupHead groups[i]) for s in selection do if (q=(getRootClosedGroupHead s)) != rootGroup then appendIfUnique attachingNodes q nodeCounts = 0 if destinationGroups.count > 1 and attachingNodes.count>0 then ( with redraw off ( for i = 1 to destinationGroups.count where destinationGroups[i] != rootGroup do ( maxOps.cloneNodes attachingNodes cloneType:#instance newNodes:&objs for o in objs do ( appendIfUnique attachingNodesInstances (getRootGroupHead o) if attachingNodesInstances.count>nodeCounts then ( nodeCounts+=1 tm = o.transform * (inverse rootGroup.transform) o.transform = tm*destinationGroups[i].transform ) ) attachNodesToGroup objs destinationGroups[i] ) attachNodesToGroup attachingNodes rootGroup ) print "Successful :)" ) else print "make another selection :(" ) ) ) createDialog bgaRoll 110 30 10 110 style:#(#style_titlebar, #style_sysmenu, #style_toolwindow)
 
Old 06-15-2013, 08:27 AM   #51
gazybara
Architect
 
gazybara's Avatar
portfolio
Branko Živković
Freelancer
Niš, Serbia
 
Join Date: Apr 2011
Posts: 1,103
Try with this
Code:
with undo "attach_to_groups" on ( with redraw off ( -- rest of code ) )
__________________
Looking in the right side. [bgaTools]
 
Old 06-15-2013, 09:00 AM   #52
try2script
Expert
portfolio
Mike
Moldova
 
Join Date: Mar 2013
Posts: 484
Thx, Branko, it's working now! I will add the tool soon!
 
Old 06-15-2013, 09:00 AM   #53
CGTalk Moderation
Lord of the posts
CGTalk Forum Leader
 
Join Date: Sep 2003
Posts: 1,066,481
Thread automatically closed

This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
__________________
CGTalk Policy/Legalities
Note that as CGTalk Members, you agree to the terms and conditions of using this website.
 
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 07:25 PM.


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