Reset Xform and keep instances

Reset Xform and keep instances

rartidiello
Enthusiast Enthusiast
3,290 Views
7 Replies
Message 1 of 8

Reset Xform and keep instances

rartidiello
Enthusiast
Enthusiast

Hi,

I need a script for resetting xform and then collapsing the modifier stack while keeping the instances.

Thanks.

0 Likes
3,291 Views
7 Replies
Replies (7)
Message 2 of 8

denisT.MaxDoctor
Advisor
Advisor
Message 3 of 8

rartidiello
Enthusiast
Enthusiast

I'm sorry but that script doesn't keep instances when the xform modifier is on the stack, that's why I'm asking for the specifics of reset xform and keep instances. thanks

0 Likes
Message 4 of 8

denisT.MaxDoctor
Advisor
Advisor

Keeping instances with ResetXForm doesn't make sense because resetting XForm means individually changing the transformation properties of an object to meet certain criteria (such as aligning orientation or resetting scale).
But that doesn't mean my function doesn't work with the XForm modifier. If you apply it manually (addmodifier <node> (XForm ())), you will see that everything works the same as for other modifiers.

 

But ... sometimes it makes sense to reset the XForm for the "master" node and get a "relative" reset for all its instances. In this case, I see the only solution:
# 1 find all instances of the master node
# 2 reset the master's xform
# 3 replace all instances with master object

 

The code might look like this:

fn replaceNodeXForm node = 
(
	instancemgr.getinstances node &instances 
	resetxform node
	collapsestack node
	instancereplace instances node
)

/* where $ is a master

replaceNodeXForm $

*/
Message 5 of 8

rartidiello
Enthusiast
Enthusiast

My bad I didn’t describe the problem properly.

I have a big scene with around 100 instance groups each having dozens of instances and realized I didn’t reset xForm on the master of any group.

I’ve tried this last script you wrote but I haven’t been able to make it work. I’ve created a DragAndDrop button also tried uncommenting the line where $ is a master replaceNodeXForm. Is there anything else I should try?

Thanks for your time.

0 Likes
Message 6 of 8

denisT.MaxDoctor
Advisor
Advisor

select one of the instances and run:

try
(
    node = selection[1]
	instancemgr.getinstances node &instances 
	resetxform node
	collapsestack node
	instancereplace instances node
)
catch()
0 Likes
Message 7 of 8

rartidiello
Enthusiast
Enthusiast

thanks, it does what I asked for, unfortunately the child instances rotate as well. maybe what I requested is not feasible as you mentioned.

0 Likes
Message 8 of 8

denisT.MaxDoctor
Advisor
Advisor

you can try to post a sample scene here .. and explain what you want to reset. I'll take a look and maybe come up with some solution.

0 Likes