Jump to content

Recommended Posts

Posted

I have a table cell that contains a field linked to a block attribute.

 

When I use the GetCellValue method it returns the text value of the attribute.

 

How do I retrieve the actual field data, for example:

 

%%).TextString>%

 

I'm primarily interested in retrieving the ObjID of the block containing the attribute the field references.

Posted

Problem solved for my specific instance.

 

Starting with a table cell (row 0, column 0) that contains a field as formatted above:

 

Store a reference to the active document:

 

(setq activedoc (vla-get-activedocument (vlax-get-acad-object)))

 

Get the Table object by user selection:

 

(setq table-obj (vlax-ename->vla-object (car (entsel))))

 

Get the field ID of the cell:

 

(setq pfieldid (vla-getfieldid table-obj 0 0))

 

Convert the Field ID to an object:

 

(setq pobject (vla-objectidtoobject activedoc pfieldid))

 

Apparently field objects are not fully supported in VLISP, so I needed to get the DXF entity data of the field to continue:

 

(setq pdxf (entget (handent (vla-get-handle pobject))))

 

This is the parent field data. From here I retrieved the Child Field ename from code 360 and then the DXF entity data:

 

(setq cdxf (entget (cdr (assoc 360 pdxf))))

 

Code 331 is the ename of the attribute reference and I used this to get the attribute reference object:

 

(setq aobject (vlax-ename->vla-object (cdr (assoc 331 cdxf))))

 

Finally I retrieved the Block Reference object using the OwnerID of the Attribute Reference object:

 

(setq bobject (vla-objectidtoobject activedoc (vla-get-ownerid aobject)))

 

I only tested this on 32Bit AutoCAD 2011. For 64Bit use GetFieldId32.

 

Any comments would be welcomed.

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