fromMlm Posted October 9 Posted October 9 Hi all, Again I have found a lisp Lee Mac made that copies a field into a dimension, "copyfield", but it requires that the field already exists... So is there a way to create a field from an attribute in a block and then insert the field directly into a dimension? Thanks in advance. Quote
BIGAL Posted October 9 Posted October 9 You can do a dimension then update the dimension string with a field just double click the dimension and a field is an option. In image move corner point and dim updates both normal length and area. You need to explain more what is in the field, then could speed up the process with a lisp. Quote
fromMlm Posted October 10 Author Posted October 10 Thanks for your answer! I have rebar block with a rebar number called "Littera". I would be great if I could place that directly into the dimesnsion, which works as a marker for in what area the rebars are to be placed. Can that also be done for multiple attributes into the same dimension? block.dwg Quote
BIGAL Posted October 10 Posted October 10 In simple terms if you want say all attributes into the dim can be done by just using a text answer, it will not update. but you can run again. For every time you want to do this using a field you have to get the ID of the attributes in the block selected, these are different for every block. Ok good news can be done, do you want the 25 12 s200 A326a as answer ? Quote
fromMlm Posted October 11 Author Posted October 11 Thanks again Bigal for your reply! The other attributes and "Littera" are for extraction to excel to sort them there. What i was hoping for, was if one, two or more different "Littra" can be put into same dimension as field? But multiple attributes as text answer into dimension from different blocks would be nice as well. Quote
BIGAL Posted October 11 Posted October 11 (edited) Yes should be the answer, I have take 2 attributes add them together and put result into a 3rd attribute all as fields. Should be able to do pick pick etc 1 - ? then put in a dim. Try this pick the attributes. Tested on 1 2 & 3 attributes. ; Take block atts and put as field in dimension ; By AlanH 2024 (defun c:wow ( / lst obj x str) (setq lst '()) (while (setq ent (nentsel "\nPick a attribute Enter to stop ")) (setq obj (vlax-ename->vla-object (car ent))) (setq lst (cons (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString obj :vlax-false) lst )) ) (setq lst (reverse lst)) (setq x -1 str "") (repeat (length lst) (setq str (strcat str " " "%<\\AcObjProp Object(%<\\_ObjId " (nth (setq x (1+ x)) lst) ">%).Textstring>%")) ) (setq obj (vlax-ename->vla-object (car (entsel "\nPick dimension ")))) (vlax-put obj 'textoverride str) (command "regen") (princ) ) Edited December 4 by BIGAL Quote
fromMlm Posted October 12 Author Posted October 12 Thank you very much Bigal! Works super! I could even put the chosen attribute into a block as a field. Quote
fromMlm Posted October 12 Author Posted October 12 By the way, and I hope I'm not pushing it. Is there a way to put in commas between the attributes? Thanks again! Quote
BIGAL Posted October 12 Posted October 12 (edited) Try this version (defun c:wow ( / lst obj x str) (setq lst '()) (while (setq ent (nentsel "\nPick a attribute Enter to stop ")) (setq obj (vlax-ename->vla-object (car ent))) (setq lst (cons (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString obj :vlax-false) lst )) ) (setq lst (reverse lst)) (setq x -1 ) (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " (nth (setq x (1+ x)) lst) ">%).Textstring>%")) (if (> (length lst) 1) (repeat (- (length lst) 1) (setq str (strcat str "," "%<\\AcObjProp Object(%<\\_ObjId " (nth (setq x (1+ x)) lst) ">%).Textstring>%")) ) ) (setq obj (vlax-ename->vla-object (car (nentsel "\nPick dimension ")))) (vlax-put obj 'textoverride str) (command "regen") (princ) ) (c:wow) Edited December 4 by BIGAL Quote
fromMlm Posted October 13 Author Posted October 13 Thanks!! But it seems like something happend. When I update an attribute it won't change in the dimension. And when I go into the dimension the fields isn't there and it turns back to a plain dimension. What am I missing? Quote
BIGAL Posted October 13 Posted October 13 (edited) You are right I changed the attribute value and the dim field did not update. I did the same to a mtext and it worked. It looks like you can not Update the dim value. May have to look at a dynamic block with a attribute. Any body have an idea ? Maybe ask over at forums/autodesk post link to here. Ok probably only way is make a dim block with also a Mtext value. Have the measurement set to blank eg space. insert it, align the dim and stretch etc, explode, then code will work. Edited October 14 by BIGAL Quote
fromMlm Posted October 14 Author Posted October 14 Thanks for replying! I will try and post it at the other forum as well. Quote
fromMlm Posted October 18 Author Posted October 18 ;; Get ObjectId and create fielexpression (setq objid (vla-get-ObjectId (vlax-ename->vla-object ent))) (setq fldexp (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa objid) ">%).TextString>%")) I found the part of a code above. And I'm wondering if it somehow could be used in this section of the code? Quote
BIGAL Posted October 18 Posted October 18 The problem is not in the code but rather that a dimension does not update when the attribute is changed. Only way around it is to use a Mtext. Quote
fromMlm Posted December 4 Author Posted December 4 Yes it does! Thanks for your help! Updated lisp: (defun c:wow ( / lst obj x str) (setq lst '()) (while (setq ent (nentsel "\nPick a attribute Enter to stop ")) (setq obj (vlax-ename->vla-object (car ent))) (setq lst (cons (vlax-invoke-method (vla-get-Utility (vla-get-activedocument (vlax-get-acad-object))) 'GetObjectIdString obj :vlax-false) lst )) ) (setq lst (reverse lst)) (setq x -1 ) (setq str (strcat "%<\\AcObjProp Object(%<\\_ObjId " (nth (setq x (1+ x)) lst) ">%).Textstring>%")) (if (> (length lst) 1) (repeat (- (length lst) 1) (setq str (strcat str "," "%<\\AcObjProp Object(%<\\_ObjId " (nth (setq x (1+ x)) lst) ">%).Textstring>%")) ) ) (setq obj (vlax-ename->vla-object (car (entsel "\nPick dimension ")))) (vlax-put obj 'textoverride str) (command "regen") (princ) ) (c:wow) 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.