TheSwamp
CAD Forums => Vertically Challenged => Land Lubber / Geographically Positioned => Topic started by: lispman21 on July 27, 2006, 11:03:21 AM
-
I was just wondering if there was a way to take the lower left hand corner of a drawing and move it to (0,0). I know you can do this manually but i would like to have the program find the base point and move it to (0,0) automatically. Maybe you would have to select every entity in the drawing and have it find the lower left handcorner that way. I have no clue.
-
Wouldn't it be easier just to redefine 0,0 instead of moving everything? Just a thought.
UCS;n;[pick new point for 0,0].
Pete
-
there is a way, I think the sysvar is extmin, that would be your base point.
-
extmin will only be accurate (if I recall correctly) after a regen.
-
Before you tear down a fence, it always a good idea to determine why it was built in the first place.
Why is the drawing not @ 0,0? We build things on the coordinates in which they will reside which means the drawings can be very far from 0,0 and are rarely close to it. Maybe the better option is place all annotation in PS at PS 0,0,0, and leave the model geometry where it is.
-
Agreed Randy, all kinds of unintended consequences can happen when you move the drawing geometry and nearly all are quite unpleasant when discovered
-
(setq pt1 (car (acet-geom-ss-extents (setq theset (ssget "X")) t )))
(command "move" theset "" pt1 '(0 0 0))
Agreed Randy, all kinds of unintended consequences can happen when you move the drawing geometry and nearly all are quite unpleasant when discovered
what he said
-
-EDIT-
Depends to a large extent what the content and usage of the drawing are.
MY RESPONSE TO THIS DELETED POST BY ANNONYMOUS
Absolutely, and since the consequences of that action can vary from nothing at all to the trashing of an entire drawing set, it should not be done without a thorough investigation. As long as these drawings are entities unto themselves and not referenced to or from any other drawing everything should be OK except for an occasional hiccough in a hatch, leader or dimension. If someone comes in and does that to one of my Civil 3D project folders though, it is literally a start over for the project.
-
All of these drawings are dxf's and in order for this other program we have to bring them in and scale the proportionally and correctly the bottom left hand corner of the drawing must be placed at (0,0). As to why these were not drawn at (0,0) to begin with i don't know. Maybe they were just trying to get the drawings done and not worry about the placement until later.
-
(setq pt1 (car (acet-geom-ss-extents (setq theset (ssget "X")) t )))
(command "move" theset "" pt1 '(0 0 0))
I tried this code and it did not work. It said error no function acet-geom-ss-extents.
I am running in 2002 maybe i need to try it in 06.
-
From what it sounds like you are doing, you should have few problems - just the minor ones I mentioned above if that. Are these drawings all in modelspace (or even all in paperspace with a titleblock that you are wanting to move to 0,0? If so, no problems. If you have geometry in model with a paperspace titleblock and a viewport you are in for a lot of work.
-
All of the dxf geometry is in model space with nothing at all in paper space. And again I am working in Acad 2002 but do have access to 2006, just incase some code doesn't work in 2002.
-
What type of drawings are they Civil, Architectural, etc.? Or are they of the block type?
-
(setq pt1 (car (acet-geom-ss-extents (setq theset (ssget "X")) t )))
(command "move" theset "" pt1 '(0 0 0))
I tried this code and it did not work. It said error no function acet-geom-ss-extents.
I am running in 2002 maybe i need to try it in 06.
acet-geom-ss-extents
is express tools stuff
-
These drawings are Mechanical. All are of Fans and dampers for air handling units. All blocks in the drawings have been exploded so that they can be changed.
-
All blocks in the drawings have been exploded so that they can be changed.
No need for this. You can change them with code.
-
Ok whether or not it really matters they have already been exploded so maybe that makes it easier or not.
-
Then make sure all the layers are thawed, unlocked, and turned on, and see if this works for you.
(defun c:MoveTo0 ()
(command "_.regenall")
(command "_.move" "_all" "" (getvar "extmin") '(0.0 0.0 0.0))
)
ps. Make sure you are in model space.
-
No, I am sorry the previous code did not work. Infact it didn't move a single thing inthe drawing to (0,0,0). But worth a shot.
-
(defun c:test-1 (/ p1 p0)
(setq p1 (vlax-3d-point
(car
(acet-geom-ss-extents
(ssget "_X")
t
) ;_ acet-geom-ss-extents
) ;_ car
) ;_ vlax-3d-point
p0 (vlax-3d-point 0 0)
) ;_ setq
(VLAX-FOR x (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object)
) ;_ vla-get-activedocument
) ;_ vla-get-modelspace
(vla-move x p1 p0)
(vla-update x)
) ;_ VLAX-FOR
) ;_ defun
(defun lst-getboundingbox (lst)
(vl-load-com)
(if (and lst (listp lst))
((lambda (x)
(list
(apply
(function mapcar)
(cons
(function min)
(mapcar (function car) x)
) ;_ cons
) ;_ apply
(apply
(function mapcar)
(cons
(function max)
(mapcar (function cadr) x)
) ;_ cons
) ;_ apply
) ;_ list
) ;_ lambda
(vl-remove-if
(function null)
(mapcar
(function
(lambda (x / minp maxp)
(if (not
(vl-catch-all-error-p
(vl-catch-all-apply
(function vla-getboundingbox)
(list x 'minp 'maxp)
) ;_ vl-catch-all-apply
) ;_ vl-catch-all-error-p
) ;_ not
(list
(vlax-safearray->list minp)
(vlax-safearray->list maxp)
) ;_ list
) ;_ if
) ;_ lambda
) ;_ function
lst
) ;_ mapcar
) ;_ vl-remove-if
)
) ;_ if
) ;_ defun
(defun c:test-2 (/ p1 p0)
(setq
p1 (vlax-3d-point
(car
(lst-getboundingbox
(mapcar
(function vlax-ename->vla-object)
(vl-remove-if
(function listp)
(mapcar
(function cadr)
(ssnamex (ssget "_X"))
) ;_ mapcar
) ;_ vl-remove-if
) ;_ mapcar
) ;_ lst-getboundingbox
) ;_ car
) ;_ vlax-3d-point
p0 (vlax-3d-point 0 0)
) ;_ setq
(VLAX-FOR x (vla-get-modelspace
(vla-get-activedocument
(vlax-get-acad-object)
) ;_ vla-get-activedocument
) ;_ vla-get-modelspace
(vla-move x p1 p0)
(vla-update x)
) ;_ VLAX-FOR
) ;_ defun
-
your awesome the programs work great.
-
Let me see if I can make some sense of you request. Also looking at this thread, http://forums.augi.com/showthread.php?t=43703
that is you right.
You have many drawings that have in the one exploded block each but they are far from the origin 0,0,0 and you want
to move the exploded block objects back to 0,0,0 so the drawing can be inserted as a block using that 0,0,0.
-
Wow, that was quick. While I went to reset the TV for my wife your problem was solved. :-o
-
your awesome the programs work great.
Too true.
:)
-
Then make sure all the layers are thawed, unlocked, and turned on, and see if this works for you.
(defun c:MoveTo0 ()
(command "_.regenall")
(command "_.move" "_all" "" (getvar "extmin") '(0.0 0.0 0.0))
)
ps. Make sure you are in model space.
Hi Tim,
I think your elegant idea applies, but it may need a qsave like this:
(defun c:MoveTo0 ()
(setvar "cmdecho" 0)
(command "_.regenall")
(print (getvar "extmin"))
(command "_.move" "_all" "" (getvar "extmin") '(0.0 0.0 0.0))
(setvar "cmdecho" 1)
(princ)
)
(defun c:MoveTo0v2 ()
(setvar "cmdecho" 0)
(command "_.qsave")
(command "_.regenall")
(print (getvar "extmin"))
(command "_.move" "_all" "" (getvar "extmin") '(0.0 0.0 0.0))
(setvar "cmdecho" 1)
(princ)
)
Example: I open a drawing where the lower left corner of the all the
geometry is at 0,0. I move everything up and to the right. Then I run
MoveTo0. Nothing happens and (print (getvar "extmin")) returns (0.0 0.0 0.0).
Then I run MoveTo0v2. The geomerty moves back to 0,0 and (print (getvar "extmin"))
returns (13.9636 20.5102 0.0).
Draw your own conclusions... :-)
-
Then make sure all the layers are thawed, unlocked, and turned on, and see if this works for you.
(defun c:MoveTo0 ()
(command "_.regenall")
(command "_.move" "_all" "" (getvar "extmin") '(0.0 0.0 0.0))
)
ps. Make sure you are in model space.
Hi Tim,
I think your elegant idea applies, but it may need a qsave like this:
(defun c:MoveTo0 ()
(setvar "cmdecho" 0)
(command "_.regenall")
(print (getvar "extmin"))
(command "_.move" "_all" "" (getvar "extmin") '(0.0 0.0 0.0))
(setvar "cmdecho" 1)
(princ)
)
(defun c:MoveTo0v2 ()
(setvar "cmdecho" 0)
(command "_.qsave")
(command "_.regenall")
(print (getvar "extmin"))
(command "_.move" "_all" "" (getvar "extmin") '(0.0 0.0 0.0))
(setvar "cmdecho" 1)
(princ)
)
Example: I open a drawing where the lower left corner of the all the
geometry is at 0,0. I move everything up and to the right. Then I run
MoveTo0. Nothing happens and (print (getvar "extmin")) returns (0.0 0.0 0.0).
Then I run MoveTo0v2. The geomerty moves back to 0,0 and (print (getvar "extmin"))
returns (13.9636 20.5102 0.0).
Draw your own conclusions... :-)
Joe,
Hmmmm... That is weird, but thanks for posting the answer. I don't think I would have ever tried that.