Replace Object command

Hello Rhino friends,

The Replace Object command is incredibly useful, but unfortunately doesn’t seem to work with groups. Is it possible to modify it so that you can replace one group of objects with another?

Thank you.

Cosmas

Hmm- that is a script that fooled you into thinking it was a command- not bad, eh? So for groups, you’d want an entire group replaced with a different object or group, correct?

-Pascal

Yes --that would be great. So let’s say you have a group of “geometrical objects” that make up a light fixture… and you want to replace the entire group with a different group of “geometrical objects” so you can have a different light fixture…

Thank you: )

Isn’t that kinda what blocks are for…?

–Mitch

You said it, man.

-Pascal

Your point is well taken, but isn’t it nice to have several different ways to do the same thing?

Yeah, I can see where this might be useful if you have not already blocked things. I’ll take a look…

-Pascal

Thank you, Pascal. I really appreciate it.

Hey @pascal

Where is that ReplaceObject script? And will it work in Rhino6?

Talking with a colleaguye about replacing objects in a scene. Would be great to select objects, replace with a Point, and then ultimately replace Points with Blocks

Thanks as always

Hmm… I dunno, is that something I made, do you recall?
I’m not finding anything yet…
-Pascal

oh, I assumed you wrote it 'cuz you said:

“Hmm- that is a script that fooled you into thinking it was a command- not bad, eh?”

Hi Alan - it could well be mine, I just don’t see it here, time for a coffee - @cosmas - did you get that from me??

-Pascal

1 Like

@pascal I’m looking for exactly this right now. I have a bunch of door handles I need to replace in a model (they are not blocks), is there a way to replace them with a different handle ?? tia :slight_smile:

Hello - there is no built-in way if they are not blocks - the best you could do in a script is an approximation, I’d think, placement-wise. Thinking…
@milezee, @Alan_Farkas - here is a first try at this - it only works to replace surfaces/polysurfaces so far.
The starting situation has to be that you have one replacement object in place on one target object.

  1. Select the first target, the one with the replacement in place
  2. Select the rest of the target objects. Note there is no check at the moment to see if these are actually copies of the first one - it will go wonky if they are not
  3. Select the replacement object.This can be anything, not necessarily a surface or polysurface.

ReplaceObject.py (2.2 KB)

Crude object matching checks added.
@milezee, @Alan_Farkas - multiple replacement objects supported now.

To use the Python script use RunPythonScript, or a macro:

_-RunPythonScript "Full path to py file inside double-quotes"

-Pascal

2 Likes

Hi Pascal, this works to a certain extent, it is restricted to replacing objects in one direction, ie either horizontally in x,y, or vertically in z axis. Also if the objects are not aligned it gives inaccurate resutls. I think I’m being a little harsh because despite this the script is very useful indeed, thanks for taking the time write and post, cheers :beers:

Hello- please post an example…

-Pascal

uhmm, it seems to be working now, just tried in a simplified file and its replacing and orientating objects as expected, I’ll try again later as I have a bunch more objects to replace :+1:

Thanks so much, excited to check it out! Sorry been MIA. Will post results

This is amazing, thank you so much!