Jump to content

Attach Objects by Layer request?


Recommended Posts

how many layers do you have to do this for? if its HUGE numbers of layers then there is probably a more automated way but....

 

...i use a script called quick attach (i think?) that attaches all selected meshes together into one multisub edit mesh. im at home now , but can post it tomorrow for you.

 

i select a layer and click and its one object, it doenst work with more than 1000 objects at once though.

Link to comment
Share on other sites

not offhand, but thats a pretty easy one.. would you just want 1 big multi-sub of the materials afterwards?

 

see below

that SHOULD do it.. barring some wierdness as i dont have max working here at home to check it ;)

 

Edit: Ok.. updated the script to actually work mostly.. Needs a little more error checking as yet

Edited by Dave Buchhofer
script updated
Link to comment
Share on other sites

I am still in the process of automating, or making automated as possible my Revit imports. Right now I am breaking out the materials per layer using a script, and then attaching all objects on each layer to each other. This leaves me with a handful of objects, and a Max file that is much lighter on the system.

 

Currently I am selecting everything on a layer, and running a Blur Script that attached everything that is selected. It works, but is time consuming. Because I have to monitor it, and manually select and run the script.

 

Dave,

 

One object with a multi-sub is not ideal, but may not be the end of the world. I tried to run the script on a smaller file, but ran into an error. i will try it a few more times, and see if I can get it to work. My knowledge of Max Script is limited to the page of Max Script Essentials I have read to so far.

Link to comment
Share on other sites

Here's something that works for me so far.. I'd forgotten about that pesky TargetClass before.

 

(
fn collapseNodes objs layername =
(
	if objs.count > 1 do 
	(
		mainCollapseObject = objs[1]
		format "Collapsing % nodes from layer % into 1 object named %\n" objs.count layername layername
		if (isGroupHead mainCollapseObject) do ( explodegroup mainCollapseObject ) 
		convertToMesh mainCollapseObject
		mainCollapseObject.name = layername
		for i = 2 to objs.count do 
		(
			if ((classof objs[i] != TargetObject) and (superclassof objs[i] == GeometryClass))  do
			(
				format "--- Attaching object % of type % to mesh %\n" objs[i].name (superclassof objs[i]) mainCollapseObject.name
				meshop.attach mainCollapseObject objs[i] attachMat:#IDToMat condenseMat:true deleteSourceNode:true
			)
		)
	)
)

count = layermanager.count - 1
local layerNodes = #()
for i = 0 to count do
(
	local layer = layermanager.getlayer i
	layer.nodes &layerNodes
	collapseNodes layerNodes layer.name
)
)

 

I'd be careful with this one though, after a little experimenting its pretty easy to run out of memory while doing this. You may be better off sticking to the olde collapse tool in the utilities panel and doing it by hand.

Edited by Dave Buchhofer
Link to comment
Share on other sites

From my experience with attaching objects I would stay away of mesh operations as for a lot of objects they'll eat all the memory and provoke a crash. Poly operations on the other hand work perfectly no matter how many objects you have. So I would convert everything to poly, do the attachment then convert back to mesh if needed.

Link to comment
Share on other sites

Neat good to know about the poly thing..

 

I've been wondering about that also, as i had to go through a few months back and collapse all the seperate seats of a stadium by section, taking something on the order of 20 minutes per collapse of ~500 objects at a time (for 80k..) while using the collapse utility shipped with max!

 

so its been in my head to find a better way before that comes up again someday!

Link to comment
Share on other sites

I read that about the poly/mesh in another thread. Kristian Botnen made a comment in another that thread about poly taking more disk space to store than a mesh. Personally, I would leave it a mesh, since poly is a lot more powerful, but if you are strapped for space, it might be worth converting it back. I suppose that means it requires less RAM to load also. Which may come in handy.

Link to comment
Share on other sites

Here's something that works for me so far.. I'd forgotten about that pesky TargetClass before.

 

I'd be careful with this one though, after a little experimenting its pretty easy to run out of memory while doing this. You may be better off sticking to the olde collapse tool in the utilities panel and doing it by hand.

 

Thanks. I will keep it in my back pocket until next week. I am past this point on this project, and need to keep moving ahead towards the deadline. I do have another project coming from Revit next week so I will be able to try and work out a few more of the kinks.

Link to comment
Share on other sites

So, finally what is the safe way to attach 1000+ objects?

For me it is not attach at all as it always crash or I have to spend whole afternoon by picking 100+100+100+100+....objects to avoid crashing.

 

For me I always use Neil Blevin's script pack - for this the script AttachSelectedObjects which fyi works on splines and meshes. It gives you a progress bar and I haven't had it crash on me yet.

 

Evidently since I'm still a newb here I can't post links so just go to neilblevins dot com and download his soulburn script pack.

 

Christopher Grant

Developer, ScriptSpot.com

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...