Jump to content

making a field expression...


Recommended Posts

Posted (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 by Lt Dan's legs
update code
Posted

??

 

(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>%")
 )
)

Posted

I thought maybe there was a function or string of functions to get the field expression

Posted
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.

Posted (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 by Lt Dan's legs
Posted
I thought maybe there was a function or string of functions to get the field expression
There'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

Posted
There's no one-stop method

That's all I needed to know

 

Thank you

Alanjt and irneb

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...