Notifications
Clear all

[Closed] Affect only a specific object class in selection

i saw your post #8, but nevertheless you as more experienced mxs developer should convince him of not using the modifier

Hey, I totally believe you guys that scripting-wise this would be the better way to do it. I’ll give it a try and see if it works the same. It might just as well be superstition on my part

Bringing this topic back up, I am regularly using PolyTools3D’s script from above.

       Now, I noticed that quite often CAD files use instances, and the script above, of course, kills any instancing links between objects. Is there a way to have instances survive the conversion?
     
     The problem with instances in imported CAD data is, they are always "blocked" by an empty "item" in the modifier stack. Here you can see it:
     
     [img] http://i.imgur.com/CNvelu2.gif [/img]
     
     I know the empty line has something to do with instances in Max (but I don't remember when it shows up). Anyway, I can't even manually select the object's instances via the "Select Instance" command, unless I delete the empty bar by adding a modifier (any will do) and deleting it right away. Now "Select Instances" will work.
     
     Still, I don't know how to incorporate an instancing-preservation in the script.
   
   EDIT:
   
   So, I'm making some minimal progress:
nodes = for j in selection where iskindof j body_object or iskindof j Pwr_EditNRB collect j
       																 
         max create mode
       																				  
    nodes.RenderViewportMeshRA = on
          nodes.WeldAndSmoothRA = on
          nodes.CleanMeshVDS = on
       																		
          max modify mode
       														
          modPanel.addModToSelection (Edit_Mesh ()) ui:off
          deleteModifier $ 1
     addModifier nodes (Edit_Mesh ()) ui:off
Unfortunately that's where I hit another wall. The Modify section of the script now adds and deletes an EditMesh modifier, resulting in the "derived object line" to disappear from the modifier stack. Then I'll add another EditMesh modifier (which is still instanced across the whole selection), and here's the problem: I now want to Collapse all objects to their topmost modifier - if they have one (like right-clicking a modifier and selecting "Collapse to"). This will both turn the objects into EditableMeshes AND will keep instances intact. How would I sctipt that?

Also this whole shebang with adding and deleting modifiers is REALLY slow… is there a faster way to get rid of the “derived object line” in the stack?

EDIT 2:
Alright, I found a way to now collapse these to their topmost EditMesh modifiers, via

for obj in selection do maxOps.CollapseNodeTo obj 1 true

Still, this only works in a second script, so I have to run this one afterwards… any ideas how I can add this to the first script?

Sorry that I have to bump this… but I’m desperately in need of turning a huge set of CAD data into meshes, while keeping instances intact. Can anybody help me out?

2 Replies
(@denist)
Joined: 11 months ago

Posts: 0

here is it:

with redraw off
(
	max create mode
	done = #()
	for node in objects where finditem done node == 0 do
	(
		instances = #()
		InstanceMgr.GetInstances node &instances
		if not iskindof (node = instances[1]) Editable_Mesh do
		(
			converttomesh node
			for k=2 to instances.count do instanceReplace instances[k] node 
			join done instances
		)
	)	
)

(@laserschwert)
Joined: 11 months ago

Posts: 0

Thank you so much! This finally did it! Thanks to both of you

I had to change it minimally to include all the settings I need on the CAD objects:

with redraw off
   (
   	max create mode
   	done = #()
   	for node in selection where finditem done node == 0 do
   	(
   		instances = #()
   		InstanceMgr.GetInstances node &instances
   		if iskindof (node = instances[1]) body_object or iskindof (node = instances[1]) Pwr_EditNRB do
   		(
   			node.RenderViewportMeshRA = on
   			node.WeldAndSmoothRA = on
   			node.CleanMeshVDS = on
   			converttomesh node
   			for k=2 to instances.count do instanceReplace instances[k] node 
   			join done instances
   		)
   	)	
   )

deleted… double post

instances = #()
 InstanceMgr.GetInstances $ &instances

all instances and references of selected object will be appended to that empty array
you should probably check that postby denisT

ps.and bout those grey lines you see in a modifier stack

Page 2 / 2