Jump to content

access attribute by tag name?


dbroada

Recommended Posts

If I have a block with a single attribute can I access the attribute by name....

 
   myAttributes = myObject.GetAttributes
   myName = myAttributes("Title").TextString

rather than

 

 
   myAttributes = myObject.GetAttributes
   myName = myAttributes(0).TextString

 

obviously I'm asking as my blind stubbling about has failed to reveal a solution. 8)

Link to comment
Share on other sites

I just asked the opposite question in the lisp forum at a guess your asking for tag name maybe something like myName = myAttributes(0).TagString this is a guess, I actually found it easier though to just use position (x) rather than tag name as a tag name can be changed then code will not work. Does the vba prompt give options as you type code ?

Link to comment
Share on other sites

I saw that you were asking and wondered if you would be back here. I was asking off the back of a quick and dirty routine I knocked up last week. Having completed my drawing somebody up the food chain decided that the cables should be prefixed with the name of the device they were connected to. I had used a single attributed block for both cable number and source device so it was a simple matter of reading attribute(0) from one block and writing to attribute(0) in the otehr block but I then started thinking about what if there had been 3 attributes, and what if different blocks had the same information but at different locations. It would suit me if I could use attribute("DeviceNumber") rather than step through untill the match was made.

 

You do get options in VBA but typical of microsoft, you only get the ones you know about and the others are only exposed when you have made a good enough guess. :lol:

Link to comment
Share on other sites

  • 2 weeks later...

the answer was staring at us`my guess was right

 

myName = myAttributes(0).TextString attrib value

myname = myAttributes(0).TagString attrib tag

Link to comment
Share on other sites

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