Align all objects along one X/Y/Z axis of a reference point.

Align all objects along one X/Y/Z axis of a reference point.

Anonymous
Not applicable
4,859 Views
3 Replies
Message 1 of 4

Align all objects along one X/Y/Z axis of a reference point.

Anonymous
Not applicable

Dear all,

I would like have a little more automation on this command as I frequently use it in my work.

 

It's setting the object's X/Y/Z coordinate to a desire value from a reference point.

Instead of putting in numbers like what I did above, I want the following:

1. A dialogue asking which axis (X/Y/Z) to set the objects on,

2. Click on a point on screen 

3. Use the point's X/Y/Z coordinate as reference and apply to all objects.

 

I greatly appreciate any help from the community here. 

Accepted solutions (1)
4,860 Views
3 Replies
Replies (3)
Message 2 of 4

ВeekeeCZ
Consultant
Consultant
Accepted solution

Try this.. It works for blocks and m/texts.

 

(defun c:AxAlign ( / ax co ss ed pt)

  (initget "X Y Z")
  (setq ax (cond ((getkword "Which coordinate make the same [X/Y/Z] <Y>: "))
		 ("Y")))
  (initget 1)
  (setq co (getpoint "\nSelect a destination point: ")
	co (nth (- (ascii ax) 88) co))

  (if (setq ss (ssget '((0 . "INSERT,*TEXT"))))
    (repeat (setq i (sslength ss))
      (setq ed (entget (ssname ss (setq i (1- i))))
	    pt (assoc 10 ed))
      (entmod (subst (cond ((= ax "X")
			    (list 10 co (caddr pt) (last pt)))
			   ((= ax "Y")
			    (list 10 (cadr pt) co (last pt)))
			   ((= ax "Z")
			    (list 10 (cadr pt) (caddr pt) co)))
		     pt
		     ed))))
  (princ)
)
Message 3 of 4

Anonymous
Not applicable

Thx! The script is perfect.

0 Likes
Message 4 of 4

danglar
Advocate
Advocate

.. is it possible to do this for blocks with attributes?

0 Likes