TheSwamp

CAD Forums => Vertically Challenged => Land Lubber / Geographically Positioned => Topic started by: lispman21 on July 27, 2006, 11:03:21 AM

Title: moving a drawing to 0,0
Post 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. 
Title: Re: moving a drawing to 0,0
Post by: grush on July 27, 2006, 11:08:50 AM
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
Title: Re: moving a drawing to 0,0
Post by: David Hall on July 27, 2006, 11:09:15 AM
there is a way, I think the sysvar is extmin, that would be your base point.
Title: Re: moving a drawing to 0,0
Post by: nivuahc on July 27, 2006, 11:10:54 AM
extmin will only be accurate (if I recall correctly) after a regen.
Title: Re: moving a drawing to 0,0
Post by: CADaver on July 27, 2006, 11:16:25 AM
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.
Title: Re: moving a drawing to 0,0
Post by: Dinosaur on July 27, 2006, 11:25:23 AM
Agreed Randy, all kinds of unintended consequences can happen when you move the drawing geometry and nearly all are quite unpleasant when discovered
Title: Re: moving a drawing to 0,0
Post by: uncoolperson on July 27, 2006, 11:48:44 AM
Code: [Select]
(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
Title: Re: moving a drawing to 0,0
Post by: Dinosaur on July 27, 2006, 12:05:39 PM
-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.
Title: Re: moving a drawing to 0,0
Post by: lispman21 on July 27, 2006, 12:20:59 PM
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.
Title: Re: moving a drawing to 0,0
Post by: lispman21 on July 27, 2006, 12:25:21 PM
Code: [Select]
(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.
Title: Re: moving a drawing to 0,0
Post by: Dinosaur on July 27, 2006, 12:31:11 PM
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.
Title: Re: moving a drawing to 0,0
Post by: lispman21 on July 27, 2006, 12:35:14 PM
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.
Title: Re: moving a drawing to 0,0
Post by: Slim© on July 27, 2006, 12:45:13 PM
What type of drawings are they Civil, Architectural, etc.? Or are they of the block type?
Title: Re: moving a drawing to 0,0
Post by: uncoolperson on July 27, 2006, 12:46:17 PM
Code: [Select]
(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
Title: Re: moving a drawing to 0,0
Post by: lispman21 on July 27, 2006, 01:22:08 PM
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.
Title: Re: moving a drawing to 0,0
Post by: T.Willey on July 27, 2006, 01:30:15 PM
All blocks in the drawings have been exploded so that they can be changed.
No need for this.  You can change them with code.
Title: Re: moving a drawing to 0,0
Post by: lispman21 on July 27, 2006, 01:41:08 PM
Ok whether or not it really matters they have already been exploded so maybe that makes it easier or not.
Title: Re: moving a drawing to 0,0
Post by: T.Willey on July 27, 2006, 05:15:25 PM
Then make sure all the layers are thawed, unlocked, and turned on, and see if this works for you.

Code: [Select]
(defun c:MoveTo0 ()

(command "_.regenall")
(command "_.move" "_all" "" (getvar "extmin") '(0.0 0.0 0.0))
)
ps. Make sure you are in model space.
Title: Re: moving a drawing to 0,0
Post by: lispman21 on July 28, 2006, 07:28:00 AM
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.
Title: Re: moving a drawing to 0,0
Post by: ElpanovEvgeniy on July 28, 2006, 08:16:10 AM
Code: [Select]
(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
Code: [Select]
(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
Title: Re: moving a drawing to 0,0
Post by: lispman21 on July 28, 2006, 08:24:33 AM
your awesome the programs work great.
Title: Re: moving a drawing to 0,0
Post by: CAB on July 28, 2006, 08:25:00 AM
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.


Title: Re: moving a drawing to 0,0
Post by: CAB on July 28, 2006, 08:27:15 AM
Wow, that was quick. While I went to reset the TV for my wife your problem was solved. :-o
Title: Re: moving a drawing to 0,0
Post by: MP on July 28, 2006, 08:37:44 AM
your awesome the programs work great.

Too true.

:)
Title: Re: moving a drawing to 0,0
Post by: Joe Burke on July 28, 2006, 10:50:41 AM
Then make sure all the layers are thawed, unlocked, and turned on, and see if this works for you.

Code: [Select]
(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... :-)
Title: Re: moving a drawing to 0,0
Post by: T.Willey on July 28, 2006, 10:56:07 AM
Then make sure all the layers are thawed, unlocked, and turned on, and see if this works for you.

Code: [Select]
(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.