I'm using the process outlined here:
http://www.qcad.org/rsforum/viewtopic.p ... 27&p=10125
to add custom properties to part library blocks.
After inserting an item from the Part Library browser, the block shows up in the Block List as expected.
If I insert further instances of that block from the Block List (not the Part Library browser), the custom properties are lost.
Is there a workaround for this?
Connor
Part library items with custom properties
Moderator: andrew
Forum rules
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Always indicate your operating system and QCAD version.
Attach drawing files and screenshots.
Post one question per topic.
Re: Part library items with custom properties
This is expected behavior. The custom properties are added to a block reference (aka "block instance" or "block insert") in the part library.
When you insert the part library item, the block reference is copied into your drawing, copying the custom properties with it. The block definition is also copied into your drawing.
When you insert a block from the block list, you are creating a new block reference to that block. Newly created block references (like any newly created objects) do not have any custom properties attached to them.
If you can explain what you are trying to achieve, perhaps I can think of another way to achieve what you want to do (perhaps using block attributes).
When you insert the part library item, the block reference is copied into your drawing, copying the custom properties with it. The block definition is also copied into your drawing.
When you insert a block from the block list, you are creating a new block reference to that block. Newly created block references (like any newly created objects) do not have any custom properties attached to them.
If you can explain what you are trying to achieve, perhaps I can think of another way to achieve what you want to do (perhaps using block attributes).
Re: Part library items with custom properties
OK I see why the custom properties don't persist in the block definition.
I am trying to link Part Library items to parts in a database using the part's ID (PartId).
The same library item can have varied PartIds depending on the drawing.
Because of this, I would like to keep track of the PartIds previously used by the library item (PreviousPartIds).
I planned on doing this with custom properties because AFAIK attribute definitions cannot be marked as invisible.
So the way this would work:
1. Add a library item.
2. Dialog allows user to choose part from database. (example: PartId = 25)
3. Set the block's custom property "PartId". (...setCustomProperty("QCAD", "PartId", "25"))
4. Append "25" to the Part Library's custom property "PreviousPartIds". (PreviousPartIds = "x,y,z,25")
The next time the dialog to link the library item to a part is displayed, the PreviouslyUsedParts will be displayed first.
I am trying to link Part Library items to parts in a database using the part's ID (PartId).
The same library item can have varied PartIds depending on the drawing.
Because of this, I would like to keep track of the PartIds previously used by the library item (PreviousPartIds).
I planned on doing this with custom properties because AFAIK attribute definitions cannot be marked as invisible.
So the way this would work:
1. Add a library item.
2. Dialog allows user to choose part from database. (example: PartId = 25)
3. Set the block's custom property "PartId". (...setCustomProperty("QCAD", "PartId", "25"))
4. Append "25" to the Part Library's custom property "PreviousPartIds". (PreviousPartIds = "x,y,z,25")
The next time the dialog to link the library item to a part is displayed, the PreviouslyUsedParts will be displayed first.
Re: Part library items with custom properties
You can attach custom properties or custom variables to:
- documents (data that refers to one specific document, RDocument::setVariable)
- entities (individual data for each individual entity)
- blocks (data that refers to blocks or is the same for all block references of the same block)
- layers (layer specific data or data that is the same for all entities on the same layer)
Further, you can use the QCAD configuration file as a global context to store application specific data (RSettings::setValue).
If you need to add custom data to any other contexts, I'd recommend to store it externally (in your own SQL DB, XML file, JSON, etc).
I hope that helps.
- documents (data that refers to one specific document, RDocument::setVariable)
- entities (individual data for each individual entity)
- blocks (data that refers to blocks or is the same for all block references of the same block)
- layers (layer specific data or data that is the same for all entities on the same layer)
Further, you can use the QCAD configuration file as a global context to store application specific data (RSettings::setValue).
If you need to add custom data to any other contexts, I'd recommend to store it externally (in your own SQL DB, XML file, JSON, etc).
I hope that helps.