Mystogan Posted August 10, 2023 Posted August 10, 2023 (edited) Hi, Would like to know if possible. As you may notice in the attached file. Those are lighting fixture and power receptacle and it is already in the block. What I wanted to make it faster, Is it possible for LISP to create a customized command that can do the following: 1. Changing the Mtext/Text into ATT 2. Insert another ATT (as default no value as blank) 3. Those different block will create their own individual ATT as indicated in the number 1 and 2. if possible all of those in the block will do the same routine. Hoping someone can do, Thank you in advance ChangeBlckATT.dwg Edited August 10, 2023 by Mystogan Quote
BIGAL Posted August 10, 2023 Posted August 10, 2023 Not sure exactly which block your trying to edit, the answer maybe simply solved with making dynamic blocks with multiple visibility states, so a light can have the label in 4 directions just choose correct one. If it is just add an attribute to a block why not just do that using bedit, fill in correct attribute value when inserting block. Your request seems to be I forgot to do this and now need to fix. Quote
SLW210 Posted August 11, 2023 Posted August 11, 2023 As mentioned by BIGAL, you are not clear on what exactly is being done and to what is being done on in the drawing. There a plenty of Mtext/Text to Attribute routines around. I would recommend converting the Mtext that you want as an attribute to Text. Should be able to find something for inserting attributes. You could probably do a lot of this with a script file. I agree with with BIGAL, you might look into dynamic blocks. Quote
Mystogan Posted August 11, 2023 Author Posted August 11, 2023 Hi BIGAL and SLW210, Yes there are a lot of Mtext/Text in the drawing. The main goal are those already in the block state. Like for example those LF1, LF2 etc,. they are already in the block state and it has a MText/Text inside the block. Looking at the dwg file (It was small qty of block, what if there are let say 30 different block. It will take more time for editing adding another attribute.) I can say there too many of them, I was thinking if possible those already in the block state it will convert the Mtext/Test into Attribute and then it will add another attribute inside the existing block. Is it possible? by the way it was done by other trade/discipline to be more precise it was done by architect Quote
SLW210 Posted August 11, 2023 Posted August 11, 2023 You could start at Lee Mac's Website. Start at Attribute Functions if you want to learn some for yourself. Somewhere on this thread... ;; Txt2Att ( Lee Mac ) ;; Converts Single-line Text to Attribute Definition MText to Attribute - AutoLISP, Visual LISP & DCL - AutoCAD Forums (cadtutor.net) Quote
SLW210 Posted August 11, 2023 Posted August 11, 2023 You might also check this thread... Import simple text to existing blocks as an additional attribute What exactly are you trying to accomplish? If we know what you are looking to do, there may be a better way to accomplish that task. Quote
aridzv Posted August 11, 2023 Posted August 11, 2023 Hi @Mystogan. about your second request - Insert another ATT (as default no value as blank), here is a lisp that I'm using to insert a new attribute to an existing bolck that is already in the drawing. I called this attribute "SYSTEM" but you can change that name. hope it will help on that task. (defun c:add_SYS_ATT (/ ss blk blk-lst atts-lst def AttObj obj2) (vl-load-com) (if (setq ss (ssget '((0 . "INSERT")))) ;change if to while repeats command if you keep selecting things (foreach e (vl-remove-if 'listp (mapcar 'cadr (ssnamex SS))) ;makes a list of all entitys by ename in selection set and steps thought them one at a time (setq blk (cdr (assoc 2 (entget e)))) (if (not (vl-position blk blk-lst)) (progn (setq blk-lst (cons blk blk-lst)) (setq obj2 (vlax-ename->vla-object e)) (setq atts-lst nil) ;clear list from last use (if (= (vla-get-hasattributes obj2) :vlax-true) (foreach att (vlax-invoke obj2 'getattributes) (setq atts-lst (cons (strcase (vla-get-tagstring att)) atts-lst)) ;make a list of all Attributs tag names to check rather then checking them all individually ) ;;close foreach ) ;;close if (if (not (member "SYSTEM" atts-lst)) ;checks list for "SYSTEM" could also use vl-position (progn (setq def (vla-item (vla-get-blocks (vla-get-activedocument (vlax-get-acad-object))) blk)) (setq AttObj (vla-addattribute def 36 acAttributeModeInvisible "" (vlax-3D-point 72 84) "SYSTEM" "")) ;;add "SYSTEM" Attribute to the block (vlax-put AttObj 'Alignment acAlignmentmiddle) (command "_.attsync" "_N" blk) ) ;;close progn ) ;;close if ) ;;close progn ) ;;close if ) ;;close foreach ) ;;close if (princ) ) 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.