Author Topic: moving a drawing to 0,0  (Read 8415 times)

0 Members and 1 Guest are viewing this topic.

lispman21

  • Guest
moving a drawing to 0,0
« 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. 

grush

  • Guest
Re: moving a drawing to 0,0
« Reply #1 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

David Hall

  • Automatic Duh Generator
  • King Gator
  • Posts: 4075
Re: moving a drawing to 0,0
« Reply #2 on: July 27, 2006, 11:09:15 AM »
there is a way, I think the sysvar is extmin, that would be your base point.
Everyone has a photographic memory, Some just don't have film.
They say money can't buy happiness, but it can buy Bacon and that's a close second.
Sometimes the question is more important than the answer. (Thanks Kerry for reminding me)

nivuahc

  • Guest
Re: moving a drawing to 0,0
« Reply #3 on: July 27, 2006, 11:10:54 AM »
extmin will only be accurate (if I recall correctly) after a regen.

CADaver

  • Guest
Re: moving a drawing to 0,0
« Reply #4 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.

Dinosaur

  • Guest
Re: moving a drawing to 0,0
« Reply #5 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

uncoolperson

  • Guest
Re: moving a drawing to 0,0
« Reply #6 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

Dinosaur

  • Guest
Re: moving a drawing to 0,0
« Reply #7 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.
« Last Edit: August 29, 2006, 08:11:44 PM by DinØsaur »

lispman21

  • Guest
Re: moving a drawing to 0,0
« Reply #8 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.

lispman21

  • Guest
Re: moving a drawing to 0,0
« Reply #9 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.

Dinosaur

  • Guest
Re: moving a drawing to 0,0
« Reply #10 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.

lispman21

  • Guest
Re: moving a drawing to 0,0
« Reply #11 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.

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
Re: moving a drawing to 0,0
« Reply #12 on: July 27, 2006, 12:45:13 PM »
What type of drawings are they Civil, Architectural, etc.? Or are they of the block type?
I drink beer and I know things....

uncoolperson

  • Guest
Re: moving a drawing to 0,0
« Reply #13 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

lispman21

  • Guest
Re: moving a drawing to 0,0
« Reply #14 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: moving a drawing to 0,0
« Reply #15 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

lispman21

  • Guest
Re: moving a drawing to 0,0
« Reply #16 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.

T.Willey

  • Needs a day job
  • Posts: 5251
Re: moving a drawing to 0,0
« Reply #17 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.

lispman21

  • Guest
Re: moving a drawing to 0,0
« Reply #18 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.

ElpanovEvgeniy

  • Water Moccasin
  • Posts: 1569
  • Moscow (Russia)
Re: moving a drawing to 0,0
« Reply #19 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

lispman21

  • Guest
Re: moving a drawing to 0,0
« Reply #20 on: July 28, 2006, 08:24:33 AM »
your awesome the programs work great.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: moving a drawing to 0,0
« Reply #21 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.


I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: moving a drawing to 0,0
« Reply #22 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
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: moving a drawing to 0,0
« Reply #23 on: July 28, 2006, 08:37:44 AM »
your awesome the programs work great.

Too true.

:)
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Joe Burke

  • Guest
Re: moving a drawing to 0,0
« Reply #24 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... :-)

T.Willey

  • Needs a day job
  • Posts: 5251
Re: moving a drawing to 0,0
« Reply #25 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.
Tim

I don't want to ' end-up ', I want to ' become '. - Me

Please think about donating if this post helped you.