Script to replace autocad block entities with 3dsmax instances

Hi All,
I have been using the Instance Replace script and its working okay but I was hoping to customize it some more.

I create landscape planting plans in Autocad using a library of Autocad block symbols (e.g. tree_1, shrub_1, etc.). I then import these from the dwg into max as 'entities'. Then I merge in the 3d plants models. Then I run the instance replace script (or Clone and Align) to replace, for example, all the imported autocad blocks named "tree_1" with my 3dsmax model instance for the that plant.

I am trying to create a script that I can edit to automate the process. Can anyone point me in the right direction with some simple code that I can try to figure out? Something in maxscript like....

for each entity in the current scene called "tree_1" replace with instance "tree1_3d"?

Any help would be greatly appreciated.

Comments

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
paulov's picture

3dmax has a modifier named

3dmax has a modifier named Substitute, with this purpose

br0t's picture

Or if you prefer a UI you may

Or if you prefer a UI you may use this :) :

Cheers

AttachmentSize
instancereplacebyname.ms 1.6 KB

Never get low & slow & out of ideas

Graph's picture

for o in objects where o.name

for o in objects where o.name == "tree_1" do (local a = instace $tree1_3d; a.transform = o.transform; delete o)

you can also replace the delete o with o.isHidden = true to just hide and not delete the original

Raphael 'Insanto' Steves
http://Graph.Net84.Net

windrock's picture

So simple yet powerful.

So simple yet powerful. Thanks a million.

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.