# Move imported geometry to a specific point in space macro

**URL:** <https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612>\
**Category:** Rhino for Windows\
**Tags:** windows, macro\
**Created:** [December 4, 2022, 10:26am UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612 "2022-12-04T10:26:30Z")\
**Posts on this page:** 16\
**Page:** 1

<div class="post-metadata">

**Author:** ![nicolocostan99](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nicolocostan99/32/603862_2.png) [@nicolocostan99](https://discourse.mcneel.com/u/nicolocostan99)\
**Post date:** [December 4, 2022, 10:26am UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/1 "2022-12-04T10:26:30Z")

</div>

Dear All,

Is there a way to move a selection from it’s bounding box center to a fixed point which is not the world origin?

I have repetitive tasks whereby I import .dwg files which are often far from the rhino origin. I run this macro to select them and move them to World 0:

"  
_\_SelAll_  
_ZS_  
_\_Move_  
_\_Pause_  
_\_Pause 0_  
_ZS_  
"

Problem is I have to manually select the point from which to move the geometry and, once the macro is complete, I still have to move them to another point manually. Can this be achieved with a Macro or is it a job for a script?

Thank you!

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [December 4, 2022, 10:40am UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/2 "2022-12-04T10:40:06Z")

</div>

This script should help…  
[MoveObjsCtrToPickPoint.py](https://discourse.mcneel.com/uploads/short-url/meJA2pAvZTVoAuNSli5PaUclSwq.py) (541 Bytes)

---

<div class="post-metadata">

**Author:** ![nicolocostan99](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nicolocostan99/32/603862_2.png) [@nicolocostan99](https://discourse.mcneel.com/u/nicolocostan99)\
**Post date:** [December 5, 2022, 7:38am UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/3 "2022-12-05T07:38:24Z")

</div>

Perhaps I haven’t explained myself clearly.

What I’d wish is for a script is to:

1. Select all the geometry.
2. Automatically instantiate a move operation automatically picking the point to move from as the geometry’s bounding box center.
3. Automatically move said geometry to the world origin.

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [December 5, 2022, 9:15am UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/4 "2022-12-05T09:15:19Z")

</div>

OK, I misunderstood your initial request as wanting to move your objects from their combined bounding box center to a picked point, not world 0. Here is a simple script for moving to world 0.

[MoveObjsCtrToW0.py](https://discourse.mcneel.com/uploads/short-url/hv6nnjj6YVUBPjLtaFbcJ6LQ5nV.py) (444 Bytes)

---

<div class="post-metadata">

**Author:** ![nicolocostan99](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nicolocostan99/32/603862_2.png) [@nicolocostan99](https://discourse.mcneel.com/u/nicolocostan99)\
**Post date:** [December 5, 2022, 2:18pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/5 "2022-12-05T14:18:15Z")

</div>

I have modified it so that the script also automatically selects all visible objects, however it also moves locked objects for some reason.

"!\_-RunPythonScript (

“”“Simple script to move selected objects from their bounding box center to W0.  
Script by Mitch Heynick 05.12.22 _ **MODIFIED** _”“”

import rhinoscriptsyntax as rs

def MoveObjsCtrToW0():  
objs=rs.VisibleObjects(view=None, select=False, include\_lights=False, include\_grips=False)  
if not objs: return  
orig=rs.coerce3dpoint([0,0,0])  
bb=rs.BoundingBox(objs)  
bb\_ctr=(bb[0]+bb[6])/2  
rs.EnableRedraw(False)  
rs.MoveObjects(objs,orig-bb\_ctr)  
MoveObjsCtrToW0()

)

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [December 5, 2022, 6:17pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/6 "2022-12-05T18:17:12Z")

</div>

Use `rs.NormalObjects()` instead of `rs.VisibleObjects()`.

[MoveNormalObjsCtrToW0.py](https://discourse.mcneel.com/uploads/short-url/no5ZLQIp8B0xX9j2DaXcExHF8T7.py) (486 Bytes)

---

<div class="post-metadata">

**Author:** ![nicolocostan99](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nicolocostan99/32/603862_2.png) [@nicolocostan99](https://discourse.mcneel.com/u/nicolocostan99)\
**Post date:** [December 6, 2022, 1:53pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/7 "2022-12-06T13:53:10Z")

</div>

Hello,

Thank you. However, despite my efforts in trying to fix it, the script still does not move geometry to world 0.

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [December 6, 2022, 3:11pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/8 "2022-12-06T15:11:07Z")

</div>

There’s nothing to ‘fix’ as far as I can see - it works here.

Unless you are looking for _each individual object to be moved from it’s bounding box center to World 0_ rather than the combined bounding box of all of the objects. Again, your explanation is not clear. The script below will do that.

[MoveNormalObjsEachCtrToW0.py](https://discourse.mcneel.com/uploads/short-url/ssi7sPEq4l4LpfYk6FopW0D9XkC.py) (525 Bytes)

---

<div class="post-metadata">

**Author:** ![nicolocostan99](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nicolocostan99/32/603862_2.png) [@nicolocostan99](https://discourse.mcneel.com/u/nicolocostan99)\
**Post date:** [December 6, 2022, 3:28pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/9 "2022-12-06T15:28:51Z")

</div>

I am indeed trying to move multiple object to world 0 keeping their structure.

However this happens:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/b/0/3/b03887502470b3fe8f655eccb94ce3053f725932.png)

Your last script does indeed work, but, as expected, puts every single object at 0.

EDIT:

I believe there may be a block instance with a basepoint far in the distance. I cleared everything up and retried the script from earlier, getting this message:

 ![image](https://global.discourse-cdn.com/mcneel/uploads/default/original/4X/2/e/5/2e5d1125c7398fa292d1cbcfd5f47da330f618da.png)

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/481553_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [December 6, 2022, 3:48pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/10 "2022-12-06T15:48:34Z")

</div>

I remember seeing that issue a while back, just can’t seem to find it.  
Alternatives:

```python
import scriptcontext as sc
sc.doc.Views.EnableRedraw(False, False, False)

```

```python
rs.EnableRedraw = False

```

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [December 6, 2022, 3:50pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/11 "2022-12-06T15:50:53Z")

</div>

`bool is not callable' for rs.EnableRedraw()`

Bizarre, I have never seen this one before…

looks like @Gijs has though…

Funny that the last script works, but the previous ones don’t though. They all have the same line.

---

<div class="post-metadata">

**Author:** ![Gijs](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/gijs/32/481553_2.png) [@Gijs](https://discourse.mcneel.com/u/Gijs)\
**Post date:** [December 6, 2022, 3:55pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/12 "2022-12-06T15:55:34Z")

</div>

@nicolocostan99 Are you working in Rhino 7 only when this failed?

---

<div class="post-metadata">

**Author:** ![nicolocostan99](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nicolocostan99/32/603862_2.png) [@nicolocostan99](https://discourse.mcneel.com/u/nicolocostan99)\
**Post date:** [December 6, 2022, 3:56pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/13 "2022-12-06T15:56:43Z")

</div>

A Pc reboot fixed the issue, weird. Anyhow, even if after having exploded all blocks and having reset the model basepoint manually to 0, the objects still do not move to W0. They behave exactly the same as shown in the pictures above. What may be the problem?

@Gijs

> @nicolocostan99 Are you working in Rhino 7 only when this failed?

Yes I am

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [December 6, 2022, 4:12pm UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/14 "2022-12-06T16:12:17Z")

</div>

Can you post a sample file where it does not work for you? At least that way someone here can test/analyze.

---

<div class="post-metadata">

**Author:** ![nicolocostan99](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/nicolocostan99/32/603862_2.png) [@nicolocostan99](https://discourse.mcneel.com/u/nicolocostan99)\
**Post date:** [December 7, 2022, 7:30am UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/15 "2022-12-07T07:30:48Z")

</div>

[Sample-file\_W0py.3dm](https://discourse.mcneel.com/uploads/short-url/6gvO8klNGuYHfCuClpoWK5enGNt.3dm) (1.2 MB)

---

<div class="post-metadata">

**Author:** ![Helvetosaur](https://sea3.discourse-cdn.com/mcneel/user_avatar/discourse.mcneel.com/helvetosaur/32/635974_2.png) [@Helvetosaur](https://discourse.mcneel.com/u/Helvetosaur)\
**Post date:** [December 7, 2022, 9:33am UTC](https://discourse.mcneel.com/t/move-imported-geometry-to-a-specific-point-in-space-macro/151612/16 "2022-12-07T09:33:11Z")

</div>

On your posted file above, the script works correctly here.

`rs.NormalObjects()` will take _all selectable objects_ and the script will calculate the collective bounding box of those. What you maybe have is a selectable point at the origin? _That gets included in the collective bounding box calculation._ .

This is the danger of using a script that automatically selects all selectable objects - you might have something in there - maybe even far off in space somewhere - that you haven’t realized is there and gets selected too.
