Jump to content

Recommended Posts

Posted

Hello all,

 

i found this snipped of code, that aligns block on the X-Y or Z axis.

(defun c:ab ( / axs idx obj pnt sel )
   (initget "X Y Z")
   (setq axs (cond ((getkword "\nSelect axis [X/Y/Z] <Y>: ")) ("Y")))
   
   (if (and (setq sel (ssget "_:L" '((0 . "INSERT"))))
            (setq pnt (getpoint "\nSpecify alignment point: "))
            (setq pnt (trans pnt 1 (trans '(0 0 1) 1 0 t)))
       )
       (repeat (setq idx (sslength sel))
           (setq obj (vlax-ename->vla-object (ssname sel (setq idx (1- idx)))))
           (vla-put-insertionpoint obj (vlax-3D-point (mapcar '(lambda ( a b c ) (if (= axs c) b a)) (vlax-get obj 'insertionpoint) pnt '("X" "Y" "Z"))))
       )
   )
   (princ)
)
(vl-load-com) (princ)

 

But this code only works, when UCS is world.

Could this be modded, so it works with all UCS'es?

 

Posted (edited)

Do you want it to align to the axis of the UCS or WCS? That's the question first.

 

Also, I provide a program with more features in here that could align more than just blocks into any direction: Align To Direction. However, it would only work on 2D as opposed to 3D.

 

Edited by Jonathan Handojo
Posted

Thanks Jonathan, this is exactly what i was looking for!

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...