Jump to content

Move objects apart by a predetermined distance


Recommended Posts

Good Morning,

 

I was wondering if there is a lisp routine out there that when multiple objects are selected they could be put into a straight line along the X at a predetermined space. I have attached an AutoCAD 2000 dwg to show what i'm looking for. I would appreciate any help.

 

Thanks,

Brian

MOVE .dwg

Link to post
Share on other sites

Not that hard, only you may need to select the objects in order for the program to know which goes where

 

Select Objects

Enter Distance

Pick Point

Bounding Box

Move (lower left as basepoint)

Compute width (LL - > UR) point for distance for next object

 

Not thoroughly tested

 

(defun c:test  (/ ss pt e mn mx)
     (setq ss (ssget ":L"))
     (setq pt (getpoint "\nPick Point for new location: "))
     (if (not dist)
           (setq dist 1.00))
     (setq dist (cond
                      ((getreal
                             (strcat "\nEnter Distance <"
                                     (rtos dist 2 2)
                                     ">: ")))
                      (dist)))
     (repeat (sslength ss)
           (vla-getboundingbox
                 (setq e (vlax-ename->vla-object (ssname ss 0)))
                 'mn
                 'mx)
           (vla-move e mn (vlax-3d-point pt))
           (setq pt   (list (+ (car pt)
                               dist
                               (- (car  (vlax-safearray->list
                                              mx))
                                  (car  (vlax-safearray->list
                                              mn))))
                            (cadr pt)
                            0.0)
                 )
           (ssdel (ssname ss 0) ss)
           ))

Edited by pBe
Link to post
Share on other sites
Saqib_theleo
Not that hard, only you may need to select the objects in order for the program to know which goes where

 

Select Objects

Enter Distance

Pick Point

Bounding Box

Move (lower left as basepoint)

Compute width (LL - > UR) point for distance for next object

 

Not thoroughly tested

 

(defun c:test  (/ ss pt e mn mx)
     (setq ss (ssget ":L"))
     (setq pt (getpoint "\nPick Point for new location: "))
     (if (not dist)
           (setq dist 1.00))
     (setq dist (cond
                      ((getreal
                             (strcat "\nEnter Distance <"
                                     (rtos dist 2 2)
                                     ">: ")))
                      (dist)))
     (repeat (sslength ss)
           (vla-getboundingbox
                 (setq e (vlax-ename->vla-object (ssname ss 0)))
                 'mn
                 'mx)
           (vla-move e mn (vlax-3d-point pt))
           (setq pt   (list (+ (car pt)
                               dist
                               (- (car  (vlax-safearray->list
                                              mx))
                                  (car  (vlax-safearray->list
                                              mn))))
                            (cadr pt)
                            0.0)
                 )
           (ssdel (ssname ss 0) ss)
           ))

It works as he wanted.

Link to post
Share on other sites
this site provide me the knowledge of Auto Cad 2000 & it really worked.

 

Is that comment had anything to do with to this thread?

 

BTW: Welcome to the forum poojaul1. :)

Link to post
Share on other sites
  • 2 months later...

Will that be vertical or horizontal and not vertical AND horizontal?

 

(defun c:test  (/ ss pt e mn mx _d _d2 d dist mode)
     (setq ss (ssget ":L"))
     (setq pt (getpoint "\nPick Point for new location: "))
     (if (not dist)
           (setq dist 1.00))
     (setq dist (cond
                      ((getdist
                             (strcat "\nEnter Distance <"
                                     (rtos dist 2 2)
                                     ">: ")))
                      (dist)))
     (initget 1 "V H")
     (setq mode (getkword "\nSelect [Vertical/Horizontal]:"))
     (if (eq mode "H")
         (setq _D car _D2 cadr)(setq _D cadr _D2 car))
     (repeat (sslength ss)
           (vla-getboundingbox
                 (setq e (vlax-ename->vla-object (ssname ss 0)))
                 'mn 'mx)
           (vla-move e mn (vlax-3d-point pt))
           (setq d (+ (- (_d  (vlax-safearray->list mx))
                         (_d  (vlax-safearray->list mn))) dist))
           (setq pt   (if (eq mode "H") (list (+ (_d  pt) d) (_d2 pt)  0.0)
                             (list (_d2 pt) (+ (_d  pt) d)   0.0))
                 )
           (ssdel (ssname ss 0) ss)
           ))

Edited by pBe
Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...