BrianTFC Posted February 17, 2012 Posted February 17, 2012 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 Quote
pBe Posted February 17, 2012 Posted February 17, 2012 (edited) 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 February 17, 2012 by pBe Quote
Saqib_theleo Posted February 18, 2012 Posted February 18, 2012 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. Quote
BrianTFC Posted February 20, 2012 Author Posted February 20, 2012 It worked great thank you..... Quote
pBe Posted February 22, 2012 Posted February 22, 2012 It worked great thank you..... You are welcome BrianTFC Glad I could help Cheers Quote
poojaul1 Posted February 22, 2012 Posted February 22, 2012 this site provide me the knowledge of Auto Cad 2000 & it really worked. Quote
pBe Posted February 22, 2012 Posted February 22, 2012 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. Quote
RenManZ Posted May 6, 2012 Posted May 6, 2012 how would you modify this to align and space vertically or horizontally? Quote
pBe Posted May 7, 2012 Posted May 7, 2012 (edited) 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 May 7, 2012 by pBe Quote
Recommended Posts
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.