Lt Dan's legs Posted April 28, 2011 Posted April 28, 2011 (edited) I came up with this to return a field expression. What's the correct way? (defun rb:field ( vla-obj tag / n ) (if (and tag (vlax-method-applicable-p vla-obj "getattributes")) (mapcar '(lambda ( x ) (if (eq (strcase (vla-get-TagString x)) (strcase tag) ) (setq n x) ) ) (vlax-invoke (setq n vla-obj) "getattributes" ) ) (setq n vla-obj) ) (strcat "%<[url="file://\\AcObjProp"]\\AcObjProp[/url] Object(%<[url="file://\\_ObjId"]\\_ObjId[/url] " (itoa (vla-get-objectid n)) " >%).TextString>%" ) ) Edited April 28, 2011 by Lt Dan's legs update code Quote
alanjt Posted April 28, 2011 Posted April 28, 2011 ?? (defun _field (obj tag) (if (setq obj (vl-some '(lambda (a) (if (eq (strcase (vla-get-tagstring a)) (strcase tag)) a ) ) (vlax-invoke obj 'GetAttributes) ) ) (strcat "%<\\AcObjProp Object(%<\\_ObjId " (itoa (vla-get-objectid obj)) " >%).TextString>%") ) ) Quote
Lt Dan's legs Posted April 28, 2011 Author Posted April 28, 2011 I thought maybe there was a function or string of functions to get the field expression Quote
alanjt Posted April 28, 2011 Posted April 28, 2011 I thought maybe there was a function or string of functions to get the field expression vla-fieldcode, but I thought you were just trying to create a contents field from an attribute. Also, vla-fieldcode doesn't work on attributes. Quote
Lt Dan's legs Posted April 28, 2011 Author Posted April 28, 2011 (edited) this video kind of explains it. I'm just getting the attribute objectid and creating an field expression to add to . It can work the other way around too. TEST.zip Edited April 28, 2011 by Lt Dan's legs Quote
irneb Posted May 2, 2011 Posted May 2, 2011 I thought maybe there was a function or string of functions to get the field expressionThere's no one-stop method, and as alan's said - the vla-fieldcode doesn't work on attributes. To get hold of all fieldcodes (even those of attributes) you need to drill-down into the extension dictionaries of the object. As an example look at my code in this thread:http://www.cadtutor.net/forum/showthread.php?57342-Sum-Numbers-in-Mtext-Fields-to-Mtext-Field Quote
Lt Dan's legs Posted May 2, 2011 Author Posted May 2, 2011 There's no one-stop method That's all I needed to know Thank you Alanjt and irneb 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.