Crazy Homeless Guy Posted October 27, 2008 Share Posted October 27, 2008 Anyone know of a Max Script that attaches all objects on a layer to make a single object on that layer? Link to comment Share on other sites More sharing options...
Nic H Posted October 27, 2008 Share Posted October 27, 2008 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 More sharing options...
Dave Buchhofer Posted October 27, 2008 Share Posted October 27, 2008 (edited) 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 October 28, 2008 by Dave Buchhofer script updated Link to comment Share on other sites More sharing options...
Crazy Homeless Guy Posted October 27, 2008 Author Share Posted October 27, 2008 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 More sharing options...
quizzy Posted October 28, 2008 Share Posted October 28, 2008 travis, I have a script on my website that attaches objects by material. maybe thats something to look into?? Link to comment Share on other sites More sharing options...
Dave Buchhofer Posted October 28, 2008 Share Posted October 28, 2008 Travis, i'm sure its broken atm i was more dropping it here to remind me to take a look into it this morning as this revit silliness is starting to get pretty big here also. will let you know and update it in a bit Link to comment Share on other sites More sharing options...
Dave Buchhofer Posted October 28, 2008 Share Posted October 28, 2008 (edited) 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 October 28, 2008 by Dave Buchhofer Link to comment Share on other sites More sharing options...
anton Posted October 28, 2008 Share Posted October 28, 2008 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 More sharing options...
Dave Buchhofer Posted October 28, 2008 Share Posted October 28, 2008 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 More sharing options...
Crazy Homeless Guy Posted October 28, 2008 Author Share Posted October 28, 2008 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 More sharing options...
Crazy Homeless Guy Posted October 28, 2008 Author Share Posted October 28, 2008 travis, I have a script on my website that attaches objects by material. maybe thats something to look into?? I will check that out. It seams like that should have been something logical to try before I posted. Oh well, it was a Monday. Link to comment Share on other sites More sharing options...
Crazy Homeless Guy Posted October 28, 2008 Author Share Posted October 28, 2008 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 More sharing options...
Zdravko Barisic Posted October 28, 2008 Share Posted October 28, 2008 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. Link to comment Share on other sites More sharing options...
anton Posted October 28, 2008 Share Posted October 28, 2008 The way it worked fine for me for any number of meshes was to convert them to poly and attach them as polys. Then at the end if needed convert back to mesh. It worked perfectly every time. Link to comment Share on other sites More sharing options...
Crazy Homeless Guy Posted October 28, 2008 Author Share Posted October 28, 2008 I havn't monitored my RAM usage on the Mesh/Poly yet, but I have had to do multiple selections, and attach like you are speaking of Zdravko. It is a real pain, but so far attaching is the only solution that I have come up with that seems to make these files usable. Link to comment Share on other sites More sharing options...
cgrant3d Posted October 29, 2008 Share Posted October 29, 2008 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 More sharing options...
molson Posted November 4, 2008 Share Posted November 4, 2008 I have not read through the whole thread to see if anyone else posted this already. If you disable undo, the RAM usage should not escalate and your script should run quicker when dealing with attaching objects. Mark Link to comment Share on other sites More sharing options...
molson Posted November 4, 2008 Share Posted November 4, 2008 See "Disable Undo system when possible" in the MAXscript help files for details on usage of undo as it relates to attach Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now