amb2301 Posted July 29, 2020 Posted July 29, 2020 Hi Friends, I Have task to Align Attribute & MTEXT with respect to Block Angle in a GIS application(Works in Autocad), for more understanding i have attched the Drawing, which shows the Blocks & its Attributes & how it has to be aligned. Could some one please give me a lisp to do this task. Thanks in Advance. Drawing1.dwg Quote
amb2301 Posted July 30, 2020 Author Posted July 30, 2020 (edited) friends , could someone please help me on this topic. simillar kind of task like arranging Attributes over the blocks was done by @BIGAL. i m sharing the post link here Edited July 30, 2020 by amb2301 Quote
amb2301 Posted July 31, 2020 Author Posted July 31, 2020 (edited) I Tried modifying Bigal's code but some changes to be done on it , somewere its mistaken .....so the text getting overlapped(attached screenshot), could someone help me .....as it is urgently required for my projects. attaching my modified code here .. ; pick 3 texts and align to a block (vl-load-com) (defun c:tritxt ( / oldang oldunit oldsnap obj ang ins Tp xscale bname ins) (setq oldang (getvar 'angdir)) (setq oldunit (getvar 'aunits)) (setq oldsnap (getvar 'osmode)) (setvar 'angdir 0) (setvar 'aunits 3) (setvar 'osmode 0) (setq obj (vlax-ename->vla-object (car (entsel "\nPick Block object")))) (setq Objname (vla-get-Objectname obj)) (if (/= Objname "AcDbBlockReference") ; check is it a block (alert "You have not Picked a block\n\nPress ok ") (progn (setq ang (vla-get-rotation obj)) (setq ins (vlax-safearray->list (vlax-variant-value(vla-get-insertionpoint obj)))) (setq xscale (vla-get-XScaleFactor obj)) (setq bname (vla-get-name obj)) (cond ((if (= bname "TERM_AER_E")(setq len 4))) ; as per sample ((if (= bname "xxxx")(setq len 5))) ; other blocks change len value ) (setq off 2.0) (setq Tp (vlax-ename->vla-object (car (entsel "\nPick text1")))) (setq pt1 (vlax-3d-point (polar ins ang (* len 1.2)))) (vla-put-insertionpoint Tp pt1) (vla-put-rotation Tp ang ) (setq Tp (vlax-ename->vla-object (car (entsel "\nPick text2")))) (setq pt1 (vlax-3d-point (polar ins ang (* len 1.2)))) (vla-put-insertionpoint Tp pt1) (vla-put-rotation Tp ang ) (setq Tp (vlax-ename->vla-object (car (entsel "\nPick text3")))) (setq pt1 (vlax-3d-point (polar ins ang (* len 1.2)))) (vla-put-insertionpoint Tp pt1) (vla-put-rotation Tp ang ) (setvar 'angdir oldang) (setvar 'aunits oldunit) (setvar 'osmode oldsnap) ) ) ) Edited July 31, 2020 by amb2301 Quote
ronjonp Posted July 31, 2020 Posted July 31, 2020 Try this to at least rotate the mtext. That white attributed block rotation is not horizontal at 0 so it's a bit of a mess. (defun c:foo (/ e m) (and (setq e (car (entsel "\nPick block to get rotation: "))) (setq s (ssget ":L" '((0 . "MTEXT")))) (foreach m (vl-remove-if 'listp (mapcar 'cadr (ssnamex s))) (entmod (append (entget m) (list (assoc 50 (entget e))))) ) ) (princ) ) Quote
amb2301 Posted July 31, 2020 Author Posted July 31, 2020 (edited) Hi Ronjonp, Thank you so much for your code, its works perfectly for the MTEXT. but the block attributes not getting aligned as you have mentioned & also MTEXT are getting rotated in its own place & i need that text to get closer to the Block. Sorry for troubling you, Actually i can able to rotate the MTEXT, Text & Block attributes using the below code, the below code works like, after the command TRITXT, i will select the block, then it will ask to select 3 objects seperately, after selection & hitting Enter , all the 3 objects comes closer to the block & getting aligned as per block angle. but the problem is i am not getting the TEXT spacings, object 2 & 3 getting overlapped, could you please help me to update this below code. i m thankful to you. i m attaching the sample DWG here (setq obj (vlax-ename->vla-object (car (entsel "\nPick Block object")))) (setq Objname (vla-get-Objectname obj)) (if (/= Objname "AcDbBlockReference") ; check is it a block (alert "You have not Picked a block\n\nPress ok ") (progn (setq ang (vla-get-rotation obj)) (setq ins (vlax-safearray->list (vlax-variant-value(vla-get-insertionpoint obj)))) (setq xscale (vla-get-XScaleFactor obj)) (setq bname (vla-get-name obj)) (cond ((if (= bname "TERM_AER_E")(setq len 4))) ; as per sample ((if (= bname "xxxx")(setq len 5))) ; other blocks change len value ) (setq off 2.0) (setq Tp (vlax-ename->vla-object (car (entsel "\nPick text1")))) (setq pt1 (vlax-3d-point (polar ins ang (* len 1.2)))) (vla-put-insertionpoint Tp pt1) (vla-put-rotation Tp ang ) (setq Tp (vlax-ename->vla-object (car (entsel "\nPick text2")))) (setq pt1 (vlax-3d-point (polar ins ang (* len 1.2)))) (vla-put-insertionpoint Tp pt1) (vla-put-rotation Tp ang ) (setq Tp (vlax-ename->vla-object (car (entsel "\nPick text3")))) (setq pt1 (vlax-3d-point (polar ins ang (* len 1.2)))) (vla-put-insertionpoint Tp pt1) (vla-put-rotation Tp ang ) (setvar 'angdir oldang) (setvar 'aunits oldunit) (setvar 'osmode oldsnap) ) ) ) sample (3).dwg Edited July 31, 2020 by amb2301 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.