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

0 Members and 1 Guest are viewing this topic.

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.