Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Moving all objects to 0,0 using a script

12 REPLIES 12
SOLVED
Reply
Message 1 of 13
testsubject
2357 Views, 12 Replies

Moving all objects to 0,0 using a script

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"
12 REPLIES 12
Message 2 of 13
Anonymous
in reply to: testsubject

Try and use the "Flatten" command. HTH

Message 3 of 13
cadffm
in reply to: testsubject

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

EESignature

Message 4 of 13
Anonymous
in reply to: testsubject

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

Message 5 of 13
testsubject
in reply to: Anonymous

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"
Message 6 of 13
cadffm
in reply to: Anonymous

@Anonymous 

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

Sebastian

EESignature

Message 7 of 13
testsubject
in reply to: cadffm

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"
Message 8 of 13
Anonymous
in reply to: testsubject

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.

Message 9 of 13
cadffm
in reply to: testsubject


@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

EESignature

Message 10 of 13
testsubject
in reply to: cadffm

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"
Message 11 of 13
cadffm
in reply to: testsubject

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

EESignature

Message 12 of 13
testsubject
in reply to: cadffm

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"
Message 13 of 13
jreidKVSUZ
in reply to: testsubject

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.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Forma Design Contest


AutoCAD Beta