Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.

Moving all objects to 0,0 using a script

testsubject
Advisor

Moving all objects to 0,0 using a script

testsubject
Advisor
Advisor

I have a bunch of drawings where a previous colleague did not follow design standards and the title blocks are all over the place. I am attempting to write a script that will select all the objects on the drawing and move them to 0,0 with the first point being relative to the lower left corner of the title block. (FYI, there are no blocks in these drawings. The titleblock itself is just lines and text; another thing I want to fix.)

 

I found these lines which get me very close:

 

(command "zoom" "object" "all" "")
(command "move" "all" "" (getvar "extmin") '(0 0)) 

 

The problem I am having I think has to do with the BASE value. 

 

After running the above lines the titleblock are located at -0.25,-0.25. I discovered that the base was set to -0.25,-0.25. This should be simple; I set BASE to 0,0 and tried the above again. No change. Nothing I do seems to have any affect. If I start a new drawing and throw some objects on it and run the above code, everything works as expected.

 

I feel that this should have been a slam dunk but am stymied as to why I cannot get rid of this offset.

 

Does anyone have any clues?

 

Thanks in advance for any help.

 



Bob Hanrahan
Ace User since 1998
If this answered your question, please click on "Accept Solution"
0 Likes
Reply
Accepted solutions (1)
2,985 Views
12 Replies
Replies (12)

Anonymous
Not applicable

Try and use the "Flatten" command. HTH

0 Likes

cadffm
Consultant
Consultant
Accepted solution

1. Handle your objectsnap, use "_none" in front of your coordinates.

Or in your case: Use "_END" in front of the first coordinate (your (getvar "extmin") statement, and "_None" in front of the 0,0,0

2. As first step set your UCS to world

3. Offtopic: Base set the basepoint for this DWG, nothing to do with things inside this DWG (just important for inserting this dwg to another file by Insert as Block or Xref.)

If you don't why you set the base (insbase), use 0,0,0 wcs coordinates as insbase setting.

 

 

Sebastian

0 Likes

Anonymous
Not applicable

Try to do a google search for a lsp program called "Zero.lsp". It would flatten all entities in a drawing.

0 Likes

testsubject
Advisor
Advisor

Thanks for the suggestion but that did not do it.

 

I even erased every thing from the drawing, purged and then just drew 3 simple object;  Rectangle, circle, and Line.

 

I then did the zoom and move command strings and still have the  same thing. The EXTMIN is being offset by 0.25,0.25 from where it should be.



Bob Hanrahan
Ace User since 1998
If this answered your question, please click on "Accept Solution"
0 Likes

cadffm
Consultant
Consultant

@Anonymous 

Both hints are only for elevation/Z-Position, not to move objects from X,Y to 0,0

Sebastian

0 Likes

testsubject
Advisor
Advisor

Sebastian,

 

#2 was the problem. The USC was set to *NO NAME*. As soon as I set it to World everything works as expected.

 

I knew it had to be something simple.

 

Thanks so much!



Bob Hanrahan
Ace User since 1998
If this answered your question, please click on "Accept Solution"
0 Likes

Anonymous
Not applicable

My bad, thought you wanted to remove the z values.  Wow someone really jacked up a drawing.  You could try a select similiar and change the x and y values in your properties box.  It may help saving some stuff if its in the rightful place.

0 Likes

cadffm
Consultant
Consultant

@testsubject  schrieb:

I then did the zoom and move command strings and still have the  same thing. The EXTMIN is being offset by 0.25,0.25 from where it should be.


Extmin is not exactly what you thing, it is not reading your object properties, but please try this:

Run your ZOOM EXTENTS

then set treedepth, for example by using the following line:

(setvar "treedepth" (getvar "treedepth"))

then use EXTMIN

 

Is it better now?

 

Sebastian

0 Likes

testsubject
Advisor
Advisor

Sebastian,

 

I realize that extmin returns the Extents minimum coordinates. For what I am doing this is fine. I am doing Zoom Object; not Zoom Extents.

 

Thanks for your help.



Bob Hanrahan
Ace User since 1998
If this answered your question, please click on "Accept Solution"
0 Likes

cadffm
Consultant
Consultant

Whats the difference in your case (object selection ALL)??

 

But I wrote about  Extents and Treedepth because of i was searching for your problem.

( at this point i didn't read that my other post  about object snaps was the solution for you)

 

 

 

Why treedepth: Because the value of Exmin/Extmax is often wrong!!

The workaround is to re-set treedepth.

 

In a standard/automation process you have to make sure that what you do will ever works fine,

in case of your script you should add the treedepth statement in front of your move-statement.

 

Your welcome

Sebastian

0 Likes

testsubject
Advisor
Advisor

Thank you for the suggestion. I will give it a try.



Bob Hanrahan
Ace User since 1998
If this answered your question, please click on "Accept Solution"
0 Likes

jreidKVSUZ
Advocate
Advocate
Bob,
Just used your move command. Still works great in 2025 AutoCAD!!
We started about the same time with AutoCAD. Bendix was a test station for AutoCAD so I got lucky to be working there at the time. 35,000 desk tops. But beats the mainframes they used that was 80,000 per user for the warranty back then and raised air conditioned floors and computer room.
Thanks, JRR.
0 Likes