Part library items with custom properties

If you are having problems with QCAD, post here. Please report bugs through our Bug Tracker instead.

Always attach your original DXF or DWG file and mentions your QCAD version and the platform you are on.

Moderator: andrew

Forum rules
Always indicate Operating system, QCAD version
Attach Drawing files, Screenshots
Post Reply
cjh
Active Member
Posts: 31
Joined: Tue Jul 12, 2016 4:51 pm

Part library items with custom properties

Post by cjh » Thu Aug 04, 2016 5:54 pm

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

User avatar
andrew
Site Admin
Posts: 6166
Joined: Fri Mar 30, 2007 6:07 am

Re: Part library items with custom properties

Post by andrew » Thu Aug 04, 2016 7:05 pm

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

cjh
Active Member
Posts: 31
Joined: Tue Jul 12, 2016 4:51 pm

Re: Part library items with custom properties

Post by cjh » Thu Aug 04, 2016 7:47 pm

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.

User avatar
andrew
Site Admin
Posts: 6166
Joined: Fri Mar 30, 2007 6:07 am

Re: Part library items with custom properties

Post by andrew » Mon Aug 08, 2016 10:12 am

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.

Post Reply

Return to “QCAD Troubleshooting and Problems”