Aftertouch Posted October 25, 2021 Posted October 25, 2021 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? Quote
BIGAL Posted October 26, 2021 Posted October 26, 2021 The answer is in this 2 methods UCSxdir & UCSydir and Viewtwist. https://forums.autodesk.com/t5/autocad-forum/getting-the-angle-difference-between-the-wcs-and-ucs/td-p/2221039 Quote
Jonathan Handojo Posted October 26, 2021 Posted October 26, 2021 (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 October 26, 2021 by Jonathan Handojo Quote
Aftertouch Posted October 26, 2021 Author Posted October 26, 2021 Thanks Jonathan, this is exactly what i was looking for! 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.