sivapathasunderam Posted August 1, 2021 Share Posted August 1, 2021 Say my attribute block name is MYDWGFRAME & it has 10 TAGs or more, over there I wanted to move positions of the 2 tags or more (I will add/modify TAGs into the lisps as per my requirement) Say Tag name REVISION wanted to move position to X1,Y1 (I will modify the coordinate value in the lisp as per my requirement) Say Tag name DATE wanted to move position to X2,Y2 (I will modify the coordinate value in the lisp as per my requirement) then (command "_attsync" "_n" "*") Thanks Quote Link to comment Share on other sites More sharing options...
BIGAL Posted August 2, 2021 Share Posted August 2, 2021 Do you really need code "Bedit" will do it for you. Click block 1st then BEDIT. Quote Link to comment Share on other sites More sharing options...
sivapathasunderam Posted August 2, 2021 Author Share Posted August 2, 2021 Really Sir need code, Bedit command is manual & I was tried with searching the google for Attribute blocks slightly I have doubt on one link have a look . . . https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-insert-block-change-attribute-values-and-position-angle/td-p/9936772 I have to modify Attribute blocks on many drawings using script - this will be useful for many Colleagues Quote Link to comment Share on other sites More sharing options...
aridzv Posted January 18, 2022 Share Posted January 18, 2022 @sivapathasunderam you can use the polar command,see this: YourPoint (polar YourPoint YourAngle YourDistance) and look on this topic: https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/find-the-other-point-with-distance-and-angle-in-lisp/td-p/6966607 hope it will help. Quote Link to comment Share on other sites More sharing options...
Steven P Posted January 18, 2022 Share Posted January 18, 2022 Expanding what BigAl said, without testing and trying this, if you do this will it work, open the block editor and edit it using a LISP as if it was just normal model space (command "bedit" <MYDWGFRAME) .... do your commands here (command "bsave") (command "bclose") I am sure there is plenty out there about locating a named attribute and moving it, perhaps using ssget, going through the list of entities in the block if it is the correct one move it to the new coordinates Not forgetting an attsync at the end to update it. Quote Link to comment Share on other sites More sharing options...
aridzv Posted January 18, 2022 Share Posted January 18, 2022 (edited) @Steven P Hi. 1. there isn't that much examples about it. I was looking recently for this issue and struggled to find clear examples. if you could help him with clear code I belive it will help not only him. 2. in my routine I didn't used attsync. mybe because I neede to move one attribute at a time to a specific location it was not requiered, but bottom line - it worked. here is a summery of what I did: (vl-load-com) (if (setq ensel (entsel "\nSelect Block: ")) ;select the block object to edit its attributes (setq bname (cdr (assoc 2 (entget (car ensel))))) ) (setq obj (car ensel)) ;set the block object to varaible (setq obj2 (vlax-ename->vla-object obj)) ;; set the block object to a VLAX object for the attribute function . . (setq base1 (getpropertyvalue (car ensel) "Position" 1 "X")) ;get the source block base point . . (setq pAtt (polar base1 ang2 42)) ;;set the new attribute insertion point based on the block insertion point. base1 is the block insertion point, ;; 42 is the distance from base1 and ang2 is angle of that distance.it will put the attribute at 42 distance units ;;at an angle of ang2 (in radians) . . ( ;; move the object attributes foreach att (vlax-invoke Obj2 'GetAttributes) ;;loop through al the attributes of the selected block ( if (= "ORDER" (strcase (vla-get-tagstring att))) ;; if the attribute tag name is "ORDER" then move it (vlax-put att 'insertionpoint pAtt) ) ) hope it will give some guide lines. regards, Ari. Edited January 18, 2022 by aridzv Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 18, 2022 Share Posted January 18, 2022 Did Bedit and then looked at a attribute. ((-1 . <Entity name: 68df4da0>) (0 . "ATTDEF") (5 . "11C55") (330 . <Entity name: 3db030f0>) (100 . "AcDbEntity") (67 . 0) (410 . "Model") (8 . "DRGTEXT") (62 . 4) (370 . -1) (100 . "AcDbText") (10 612.293348792386 3.78122019187447 0.0) (40 . 5.0) (1 . "") (50 . 0.0) (41 . 1.0) (51 . 0.0) (7 . "Standard") (71 . 0) (72 . 0) (11 0.0 0.0 0.0) (210 0.0 0.0 1.0) (100 . "AcDbAttributeDefinition") (3 . "DRAWING DESCRIPTION") (2 . "DRAWING_DESCRIPTION") (70 . 0) (73 . 0) (74 . 0) (280 . 0)) Using a ssget with filter 0 . attdef & 2 . attname so could get insertion point (assoc 10 use that as a base point then move the entity to new pt. Quote Link to comment Share on other sites More sharing options...
mhupp Posted January 18, 2022 Share Posted January 18, 2022 @aridzv use nentsel (nested entity select) instead of entsel will get you the attribute itself. (defun C:MoveATT (/ att base pt) (vl-load-com) (while (setq (car att (nentsel "\nSelect Atribute to Move: "))) (if (= (setq base (cdr (assoc 10 (entget att)))) '(0.0 0.0 0.0)) (setq base (cdr (assoc 11 (entget att)))) ;text will have diffrent points if not left Justification ) (setq att (vlax-ename->vla-object e)) (vla-move att base (getpoint)) ;replace getpoint with x1 y1 ) ) Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 18, 2022 Share Posted January 18, 2022 (edited) Nice idea Mhupp but going back a few steps "modify Attribute blocks on many drawings using script" So entsel or nentsel can not be used if its to be automated but ssget works. Edited January 18, 2022 by BIGAL Quote Link to comment Share on other sites More sharing options...
Steven P Posted January 19, 2022 Share Posted January 19, 2022 41 minutes ago, BIGAL said: So entsel or nentsel can not be used if its to be automated but ssget works. Would nentselp work and specify the points within the LISP? However if you are automatng this with a lot of drawings, I also think you need to do ssget from within the block editor to make the LISP more generic and versetile. If the OP is just modifying the drawing frame / border it is more likely that it is inserted consistently at the same insertion point, maybe nentselp would work then.. so long as no one else has modified the dwgframeblock in that drawing Quote Link to comment Share on other sites More sharing options...
BIGAL Posted January 19, 2022 Share Posted January 19, 2022 If its one block then just update one dwg use copyclip and paste into current dwg it should say redefine so YES, then attsync all done. Quote Link to comment Share on other sites More sharing options...
aridzv Posted January 19, 2022 Share Posted January 19, 2022 (edited) 10 hours ago, mhupp said: @aridzv use nentsel (nested entity select) instead of entsel will get you the attribute itself. (defun C:MoveATT (/ att base pt) (vl-load-com) (while (setq (car att (nentsel "\nSelect Atribute to Move: "))) (if (= (setq base (cdr (assoc 10 (entget att)))) '(0.0 0.0 0.0)) (setq base (cdr (assoc 11 (entget att)))) ;text will have diffrent points if not left Justification ) (setq att (vlax-ename->vla-object e)) (vla-move att base (getpoint)) ;replace getpoint with x1 y1 ) ) @mhupp thanks for the advise - I will defentaly chek it. @Steven P I use this lisp (with entsel) to change atrribute in one selected block so probably it is not good for a selection of many blocks. here is a lisp that I use to change attributes rotation in a seleced group of blocks,and there the lisp use the ss method to create a list of blocks, fish a specipic tag and change its rotation: (defun c:chatht15 ( / ta an bent bent2 pt lay tagname ss bname x att temp YN ) (setq tagname "ORDER") (setq ss (ssget (list (cons 0 "INSERT")))) (setq ht (getreal "\nEnter text height<24>: ")) (if (= ht nil) (setq ht 24) ) (setq an (getreal "\nEnter Rotation<0>: ")) (if (= an nil) (setq an 0) ) (setq tagname (strcase (getstring "\nAttribute tag specification<ORDER>: "))) (if (= tagname "") (setq tagname "ORDER") ) (initget "Yes No") (if (null (setq YN (getkword "\nClear Attribute Value? [Yes/No] <No>: "))) (setq YN "No") ) (setq an (/ (* an pi) 180)) (repeat (setq x (sslength ss)) (setq obj (vlax-ename->vla-object (ssname SS (setq x (- x 1) )))) (if (= (vla-get-hasattributes obj) :vlax-true) (foreach att (vlax-invoke obj 'getattributes) (if (= tagname (strcase (vla-get-tagstring att))) (progn (vla-put-Rotation att an) (vla-put-height att ht) (if (= (vlax-get-property att 'Backward) :vlax-true) (vlax-put-property att 'Backward :vlax-false) ) (if (= (vlax-get-property att 'UpsideDown) :vlax-true) (vlax-put-property att 'UpsideDown :vlax-false) ) (if (= YN "Yes") (vla-put-textstring att "") ) ) ) ) ) ) (princ) ) I belive it is possible to use this structure and add a code segment that will change the attribute insertion point as well, or instead... Regards, Ari. Edited January 19, 2022 by aridzv Quote Link to comment Share on other sites More sharing options...
sivapathasunderam Posted May 11, 2022 Author Share Posted May 11, 2022 (edited) Can't use "Move with specific distance" because the position of the TAG is different in some drawings (can be different block names but i know how to rename the blocks to default by lisp route, this is because of it is done by many cad persons) I wanted to bring the specific one or more TAG(s) position to default I hope we have to use setpropertyvalue (AutoLISP) I hope far better to attach a cad drawing example - if you request me. I have attached Example (3 dwgs), The revision Tag position is different in each dwg. Drawing2.dwg Drawing3.dwg Drawing1.dwg Edited May 11, 2022 by sivapathasunderam Quote Link to comment Share on other sites More sharing options...
BIGAL Posted May 12, 2022 Share Posted May 12, 2022 Using nentsel can move attribute, simple for say 1 block. (setq obj (vlax-ename->vla-object (car (nentsel "Pick attribute")))) (vla-put-textAlignmentPoint obj '(800 100 0.0)) inside bedit (setq ss (ssget "X" (list (cons 0 "ATTDEF") (cons 2 "YOUR TAG NAME") (cons 410 "Model")))) (setq ent (entget (ssname ss 0))) then use entmod and change dxf 10 If you want to edit all blocks can call BEDIT and move attribute, then attsync. Quote Link to comment Share on other sites More sharing options...
sivapathasunderam Posted May 12, 2022 Author Share Posted May 12, 2022 (edited) 16 hours ago, BIGAL said: Using nentsel can move attribute, simple for say 1 block. (setq obj (vlax-ename->vla-object (car (nentsel "Pick attribute")))) (vla-put-textAlignmentPoint obj '(800 100 0.0)) inside bedit (setq ss (ssget "X" (list (cons 0 "ATTDEF") (cons 2 "YOUR TAG NAME") (cons 410 "Model")))) (setq ent (entget (ssname ss 0))) then use entmod and change dxf 10 If you want to edit all blocks can call BEDIT and move attribute, then attsync. Thanks a lot BIGAL . . . This is by inside block edit (setq ent (subst (cons 11 '(my default coordinate)) (assoc 11 ent) ent)) (entmod ent) (command "_.bsave") (command "_.bclose") (command "_attsync" "_N" "My block name") (princ)) Edited May 12, 2022 by sivapathasunderam Quote Link to comment Share on other sites More sharing options...
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.