Mountain_XD Posted 3 hours ago Posted 3 hours ago How can I arrange rectangles with a distance that the user enters at the command line? Arrange Rectangles.dwg Quote
Saxlle Posted 1 hour ago Posted 1 hour ago Hi @Mountain_XD, Try this: (prompt "\To run a LISP type: DISP") (defun c:DISP ( / dist base_dist ss len i ename) (setq dist (getreal "\nEnter the value for equal displacement:")) (setq base_dist dist) (princ) (prompt "\nSelect entities for displacement:") (setq ss (ssget)) (setq len (sslength ss) i 0 ) (while (< i len) (setq ename (ssname ss i)) (command "._move" ename "" "d" dist) (setq dist (+ dist base_dist)) (setq i (1+ i)) ) (prompt "\The displacement were done.") (princ) ) When entering a value for "equal displacement" it can be negative or positive value (eg. "-10" will displacement selected entities to the left side, "+10" to the right side). First, select the "green" rectangles to displacement, then run LISP again and select everything inside the "green" rectangle. Best regards. Quote
Mountain_XD Posted 1 hour ago Author Posted 1 hour ago Thank you so much Saxlle The first problem is that the first rectangle doesn't move. The second, is there any way to make the objects inside that rectangle move at the same time? Quote
Saxlle Posted 32 minutes ago Posted 32 minutes ago (edited) Try this modification, you just need to select all the rectangles and do NOT select anything inside them: (defun c:DISP ( / dist base_dist ss len i ename coords ssn ssn_len) (setq dist (getreal "\nEnter the value for equal displacement:")) (setq base_dist dist) (princ) (prompt "\nSelect RECTANGLES entities for displacement:") (setq ss (ssget)) (setq len (sslength ss) i 0 ) (while (< i len) (setq ename (ssname ss i)) (setq coords (mapcar 'cdr (vl-remove-if-not '(lambda (x) (= (car x) 10)) (entget ename)))) (setq ssn (ssget "WP" coords)) (command "._move" ename "" "d" dist) (setq ssn_len (sslength ssn)) (repeat ssn_len (command "._move" (ssname ssn (setq ssn_len (1- ssn_len))) "" "d" dist) ) (setq dist (+ dist base_dist)) (setq i (1+ i)) ) (prompt "\The displacement were done.") (princ) ) 1 hour ago, Mountain_XD said: The second, is there any way to make the objects inside that rectangle move at the same time? The above update code will solve that. 1 hour ago, Mountain_XD said: The first problem is that the first rectangle doesn't move I don't see why do you need to displacement first rectangle? But, i tried with first rectangle and it works for me. Edited 23 minutes ago by Saxlle Edited a code for multiple entities displacement inside of rectangle 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.