amb2301 Posted November 14, 2020 Posted November 14, 2020 Hi Friends, i got some task to align zig zag attributes to proper way as shown in screenshot. also i have attached the sample dwg file for the same, could someone please provide me lisp to do this task, it would be a great help for me. Thanks in Advance. sample_dwg.dwg Quote
Tharwat Posted November 14, 2020 Posted November 14, 2020 This should work unless you have the insert point of your attributed blocks far from the attribute definition. (defun c:test (/ int sel 1pt 2pt alg ent ins cls) (and (princ "\nSelect Attributed blocks to align to line : ") (setq int -1 sel (ssget "_:L" '((0 . "INSERT") (66 . 1))) ) (setq 1pt (getpoint "\nSpecify base point of line : ")) (setq 2pt (getpoint "\nSpecify next point of line : " 1pt)) (setq alg (entmakex (list '(0 . "LINE") (cons 10 1pt) (cons 11 2pt))) ) (while (setq int (1+ int) ent (ssname sel int) ) (and (setq ins (cdr (assoc 10 (entget ent))) cls (vlax-curve-getclosestpointto alg ins) ) (vlax-invoke (vlax-ename->vla-object ent) 'Move ins cls) ) ) ) (and alg (entdel alg)) (princ) ) (vl-load-com) 2 Quote
amb2301 Posted November 14, 2020 Author Posted November 14, 2020 Thank you so much Sir, it worked perfectly. Really you saved my day Sir. Quote
Tharwat Posted November 14, 2020 Posted November 14, 2020 1 hour ago, rlx said: Brilliant as always Tharwat Thank you rlx, that's to kind of you to say. 1 hour ago, amb2301 said: Thank you so much Sir, it worked perfectly. Really you saved my day Sir. You're welcome anytime. Quote
Jonathan Handojo Posted November 14, 2020 Posted November 14, 2020 A bit late into the party, but I wrote this program half a year ago, it aligns almost every object to any direction, and works on all ucs provided that the objects are on the same plane. https://www.cadtutor.net/forum/files/file/30-align-to-direction/ Quote
Jonathan Handojo Posted November 15, 2020 Posted November 15, 2020 (edited) On 11/15/2020 at 3:09 AM, Tharwat said: Thank you rlx, that's to kind of you to say. You're welcome anytime. Tharwat, one check is to make sure that the current layer is unlocked so entdel works. It's one of the most annoying checks to miss... Plus, I believe it's better if you supply the "extend infinitely" argument to the vlax-curve-getclosestpointto function, just my opinion so that you can just supply the two points closer to each other. Nonetheless, everything else is great! Edited November 15, 2020 by Jonathan Handojo Quote
Tharwat Posted November 16, 2020 Posted November 16, 2020 Thanks Jonathan for your comments. Definitely I agree with you but my codes were to help the OP to automate their work and it was not a commercial program to account for every eventuality that the user might think of or encounter, so its simple as that. 1 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.