CAD_Noob Posted December 7, 2017 Share Posted December 7, 2017 hi, can somebody help me? I want to select an attribute block and convert it to an Object Value field. Currently my workflow is this : Edit the attribute value Highlight and select "Insert Field" Under Field Category, I select Object Under object type I pick which object I want the field to insert Under Object Type properties, I select VALUE on the Preview, I choose Uppercase. wonder if this can be automated by just picking the attribute in the screen and convert it automatically to FIELD using Object Value. Thanks in advance. Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 8, 2017 Share Posted December 8, 2017 (edited) This is the reverse of what you want http://www.lee-mac.com/getfieldobjects.html but may give some ideas. Edited December 8, 2017 by BIGAL Quote Link to comment Share on other sites More sharing options...
BIGAL Posted December 8, 2017 Share Posted December 8, 2017 Same question as this http://www.cadtutor.net/forum/showthread.php?102332-Part-list-Balloon-question-(AutoCAD-2008) Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 9, 2017 Share Posted December 9, 2017 You could use my Quick Field application to create a program which will allow you to accomplish this - please read the instructions provided on the program page and in the code header. Quote Link to comment Share on other sites More sharing options...
CAD_Noob Posted December 12, 2017 Author Share Posted December 12, 2017 I tried this one : (defun c:test4 ( ) (LM:QuickField "Textstring" "%tc1" 1)) and I get an error: Command: TEST4 Select Object with Textstring property: Object does not have Textstring property. Select Object with Textstring property: Object does not have Textstring property. I was selecting an Attribute tag that contains the value which I want to convert to field. This is the field expression : %<\AcObjProp Object(%<\_ObjId 8796087809088>%).TextString \f "%tc1">% Quote Link to comment Share on other sites More sharing options...
Lee Mac Posted December 12, 2017 Share Posted December 12, 2017 Oh, sorry you may need to change line 273 from: (list 'if '(setq ent (LM:quickfield:selectifhasprop prop entsel)) to: (list 'if '(setq ent (LM:quickfield:selectifhasprop prop nentsel)) The program will currently select the block reference when selecting an attribute within a block. Quote Link to comment Share on other sites More sharing options...
CAD_Noob Posted December 13, 2017 Author Share Posted December 13, 2017 Hi Lee, it's turning the attribute into a Field but appears as ####. I've tried on several attribs and the result are the same. any thoughts why? Quote Link to comment Share on other sites More sharing options...
wkplan Posted December 13, 2017 Share Posted December 13, 2017 just regenerate the drawing (type "_rga" at the commandline) sysvar "fieldeval" may also be usefull regards Wolfgang Quote Link to comment Share on other sites More sharing options...
CAD_Noob Posted December 14, 2017 Author Share Posted December 14, 2017 just regenerate the drawing (type "_rga" at the commandline)sysvar "fieldeval" may also be usefull regards Wolfgang I did re-generate but still the same. Fieldeval is set to 31. Quote Link to comment Share on other sites More sharing options...
EYNLLIB Posted February 14 Share Posted February 14 (edited) On 12/9/2017 at 5:22 AM, Lee Mac said: You could use my Quick Field application to create a program which will allow you to accomplish this - please read the instructions provided on the program page and in the code header. Just wanted to say thanks for this bit of code. I implemented it into my routine to swap out attributes in a detail cut for a hyperlink to other DWGs dynamically based on the attribute contents. Love it! (vl-load-com) (princ) ;; Get Attribute Value - Lee Mac ;; Returns the value held by the specified tag within the supplied block, if present. ;; blk - [vla] VLA Block Reference Object ;; tag - [str] Attribute TagString ;; Returns: [str] Attribute value, else nil if tag is not found. (defun LM:vl-getattributevalue (blk tag) (setq tag (strcase tag)) (vl-some '(lambda (att) (if (= tag (strcase (vla-get-tagstring att))) (vla-get-textstring att))) (vlax-invoke blk 'getattributes)) ) ; Function to extract project number based on the pattern ##-### (defun LM:ExtractProjectNumber (path / i found) (setq i 0) (while (and (< i (- (strlen path) 6)) (not found)) (if (and (>= (ascii (substr path (+ i 1) 1)) 48) (<= (ascii (substr path (+ i 1) 1)) 57) (>= (ascii (substr path (+ i 2) 1)) 48) (<= (ascii (substr path (+ i 2) 1)) 57) (= (substr path (+ i 3) 1) "-") (>= (ascii (substr path (+ i 4) 1)) 48) (<= (ascii (substr path (+ i 4) 1)) 57) (>= (ascii (substr path (+ i 5) 1)) 48) (<= (ascii (substr path (+ i 5) 1)) 57) (>= (ascii (substr path (+ i 6) 1)) 48) (<= (ascii (substr path (+ i 6) 1)) 57)) (setq found (substr path (+ i 1) 6)) ) (setq i (+ i 1)) ) found ) ; Main function to update SHEETNUMBER fields in Detail Cut blocks (defun C:UDN (/ dwgPath projectNumber) (setq dwgPath (getvar "DWGPREFIX")) (setq projectNumber (LM:ExtractProjectNumber dwgPath)) (if projectNumber (LM:IterateBlocksAndUpdate "Detail Cut" projectNumber) (princ "\nUnable to extract project number from DWG path.") ) (princ) ) ; Function to iterate over blocks named Detail Cut and update their SHEETNUMBER attributes (defun LM:IterateBlocksAndUpdate (blockName projectNumber / doc blocks blk attribs attrib fieldCode sheetNumber) (setq doc (vla-get-activedocument (vlax-get-acad-object))) (setq blocks (vla-get-modelspace doc)) (vlax-for blk blocks (if (and (= (vla-get-objectname blk) "AcDbBlockReference") (= (vla-get-effectivename blk) blockName)) (progn (setq sheetNumber (LM:vl-getattributevalue blk "SHEETNUMBER")) (if (and sheetNumber (not (vl-string-search "X" sheetNumber))) (progn (setq fieldCode (strcat "%<\\AcVar \\href \".\\Structural DETAILS-" projectNumber ".dwg#," sheetNumber " (24x36)#" sheetNumber "#1\">%")) (foreach attrib (vlax-invoke blk 'getattributes) (if (= (strcase (vla-get-tagstring attrib)) "SHEETNUMBER") (vla-put-textstring attrib fieldCode) ) ) ) ) ) ) ) (command "regenall") ) Edited February 14 by EYNLLIB 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.