Move rectangle

Move rectangle

saitoib
Advocate Advocate
751 Views
5 Replies
Message 1 of 6

Move rectangle

saitoib
Advocate
Advocate

Hi all.

 

>rectangle 0,0 100,100

 

If I want to move the entityent of a polyline shape like the one above by the length of len in the direction of the angle of rad, can I use the move command?
Or should I recalculate each 10 coordinates of the entity and subst?

 

Thank you.

Saitoib
0 Likes
Accepted solutions (2)
752 Views
5 Replies
Replies (5)
Message 2 of 6

ronjonp
Advisor
Advisor
Accepted solution

You can also use vla-move

Here's a quick example to shift X and Y by 100 while picking points.

 

(defun c:foo (/ n s)
  ;; RJP » 2021-06-25
  (setq n 100)
  (if (setq s (ssget ":L" '((0 . "LWPOLYLINE") (90 . 4))))
    (while (getpoint "\nPick points to shift rectangles: ")
      (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
	(entmod	(mapcar	'(lambda (x)
			   (if (= 10 (car x))
			     ;; Shift X
			     ;; (mapcar '+ (list 0 n 0) x)
			     ;; Shift Y
			     ;; (mapcar '+ (list 0 0 n) x)
			     ;; Shift X & Y
			     (mapcar '+ (list 0 n n) x)
			     x
			   )
			 )
			(entget e '("*"))
		)
	)
      )
    )
  )
  (princ)
)

 

 

0 Likes
Message 3 of 6

mjohnson3MF66
Advocate
Advocate

I'm not sure what angle of rad of a rectangle you mean, but you can use the move command on the rectangle if you know what angle you want and type @Anonymous<45 where you'd replace 10 with your distance, and 45 with your angle. So this example would move the rectangle 10 units at angle 45º.

0 Likes
Message 4 of 6

Kent1Cooper
Consultant
Consultant
Accepted solution

@saitoib wrote:

....

If I want to move the entity ent ... by the length of len in the direction of the angle of rad, can I use the move command?
....


Yes.  One way:

(command "_.move" ent "" "_none" '(0 0) "_none" (polar '(0 0) rad len))

Kent Cooper, AIA
0 Likes
Message 5 of 6

saitoib
Advocate
Advocate

This is the first time I learned that the move command can be used in this way.


Thank you very much for your help.

Saitoib
0 Likes
Message 6 of 6

Kent1Cooper
Consultant
Consultant

A couple of other ways, that don't care about the possibility of any running Object Snap mode(s):

 

Call for the Displacement option and give it that as a distance from 0,0:

(command "_.move" ent "" "_displacement" (polar '(0 0) rad len))

 

Use the fact that after you give it the first coordinates, there's the default option to use them as a displacement rather than as a point:

(command "_.move" ent "" (polar '(0 0) rad len) "")

 

And those can be done without using (polar), by constructing a "@distance<angle" string, but that requires conversion of radians to degrees, and of both that and the length from numbers to strings, and gets into the question of precision in those string conversions that you don't need to deal with using (polar).

Kent Cooper, AIA
0 Likes