Code Red > .NET

Custom AutoCAD Fields

(1/3) > >>

jtoverka:
All,

I use AutoCAD Electrical 2018. I like fields as it reduces manual work and errors. I use fields for the ladder blocks to use the project code. That way, if I update the project code, everything that uses that value will be updated (after refresh).

Here is the string that goes into the text entity: "%<\AcVar CustomDP.Project Code \f "%tc1">%"

One thing to note is the "CustomDP.Project Code"

This value is stored in a block called WD_M in the IEC_PROJ attribute. If I edit this block with a new Project code, the drawing does not get updated upon refresh. However, If I open the drawing properties dialog box it will show the updated project code. When I hit okay (even though I didn't "update" anything) and refresh, the drawing gets updated.

Using the drawing properties dialog box is actually the "proper" way of updating information in the WD_M block. This part is important for my question.

My question is this:
How do I create my own custom variables to use in the AutoCAD fields? This isn't entirely being referenced from another object (WD_M block), not directly anyways. That information is sent somewhere where this custom variable is referencing from. If I delete the WD_M block, the value is still the same code.

Atook:
If you purge the block, does the value persist?

If not, you may have to update the block definition.

jtoverka:

--- Quote from: Atook on September 25, 2019, 04:31:37 PM ---If you purge the block, does the value persist?

--- End quote ---

Purging the WD_M block does not change the field value.

I am interested in how AutoCAD Electrical gets this value, it has to be stored in a dictionary or something. I just want to be able to create custom values to use in fields. If I can store a value in a dictionary to have it show up as a field option in the dialog box then that would be great.

It's Alive!:
Hi,
Does the UPDATEFIELD command work?
From an API perspective, you can also update field(s) directly.

You can create your own custom field, there’s an example in one of the ARX SDKs, caveat its C++, so you'll need to translate it to .net.
Its not trivial to do, but not crazy hard

jtoverka:

--- Quote from: It's Alive! on September 25, 2019, 11:15:25 PM ---Hi,
Does the UPDATEFIELD command work?
From an API perspective, you can also update field(s) directly.

You can create your own custom field, there’s an example in one of the ARX SDKs, caveat its C++, so you'll need to translate it to .net.
Its not trivial to do, but not crazy hard


--- End quote ---

Once I update the WD_M block attribute using properties palette or the enhanced attribute editor dialog box, it does not update the project code stored elsewhere in the drawing. I tried using updateField and it "updates" the block using the old project code. It is only when I open the drawing properties dialog box does it actually update. That dialog box has code stored in it that updates something in the drawing that is tied to the fields.

I just found these
https://knowledge.autodesk.com/support/autocad/learn-explore/caas/CloudHelp/cloudhelp/2015/ENU/AutoCAD-Core/files/GUID-8FCDDD74-0FDC-4189-8407-9EC9D7D482C5-htm.html
https://forums.autodesk.com/t5/net/set-a-custom-drawing-property/td-p/6893092

This answers my question.

Navigation

[0] Message Index

[#] Next page

Go to full version