How to store text data in drawing documents

Hello,

I would like to store a string (a few characters long) in drawing documents, so that I can retrieve it later. I want my macro to be able to read and modify it when needed.

iNote interface has a "TagName" property, that a macro can read and modify. I don't know the purpose of this property since it's not accessible from SolidWorks' user interface, but only through the API. Essentially, such a property in the iDrawingDoc interface or IModelDoc2 interface would be exactly what I need. But they don't have it.

Would anyone know how I can achieve this?

I tried using a hidden iNote as the text storage, but it's cumbersome because notes belong to sheets not to documents. So I would have to traverse all the sheets to find my hidden note before reading/modifying.

Thanks in advance!

SolidworksApi/macros
Answers 7
AT
AT 2021-04-09 Best Answer

Check this: Data Storage

HK
HK 2021-04-09

I already tried this and it does wipe it. For parts, they get left alone, but for drawings they are wiped. We heavily customized DBWorks, so that might be the reason.

ST
ST 2021-04-09

The tag name is what is shown when you click on the Attributes button for the block.

I don't think DBWorks will wipe out all custom properties - only those ones it controls. If you add one called "APITest", I bet it gets left alone.

HK
HK 2021-04-09

Wow, thanks for that tip! It was such a mystery for me. Do you know what the purpose of them, though? And why are they visible only in blocks?

We use DBWorks as PDM, and it wipes and re-writes all the custom properties at every save.

HK
HK 2021-04-09

Thanks. I had looked at attributes but the usage seemed over complicated.

I'll look into them again.

ST
ST 2021-04-09

Tag Names are visible when you include the note in a sketch block.

Why not just store the data in a custom property?

MS
MS 2021-04-09

Out of the methods suggested above, I might focus on Attributes. The attribute feature can be hidden in the Feature Manager so user's don't wonder what it is. There is additional example code to read attributes available in the help.

2019 SOLIDWORKS API Help - Create Attribute Example (VBA)

Mike