Jump to content

Recommended Posts

Posted

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.

Posted

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?

Posted (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 by Saxlle
Edited a code for multiple entities displacement inside of rectangle

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
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
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...