Page 1 of 1

Easiest way to link data to an object?

Posted: Wed Jan 04, 2017 2:00 pm
by growdigital
I'm using QCAD to create simple garden plans, and I'm curious about the easiest way to link data about a plant to that object.

I've used JSON a bit in designing websites, and it seems an ideal way to store the information.

Any tips gratefully received before I bolt down the rabbit hole!

Re: Easiest way to link data to an object?

Posted: Wed Jan 04, 2017 2:07 pm
by andrew
You can add custom properties (key / value pairs) to entities using the property editor (View > Property Editor):
Screen Shot 2017-01-04 at 14.04.45.png
Screen Shot 2017-01-04 at 14.04.45.png (94.62 KiB) Viewed 11209 times

Re: Easiest way to link data to an object?

Posted: Fri Jan 06, 2017 3:30 pm
by growdigital
Thank you for swift reply (I didn't get notification so only just noticed).

The custom properties would be good for one or two pairs but I have about 11. Was thinking of creating simple database/JSON file to keep track, and hoping that this data could be linked easily. If not, I'll fallback to using custom properties for the binomial name.

thanks, Jake

Re: Easiest way to link data to an object?

Posted: Fri Jan 06, 2017 3:37 pm
by andrew
growdigital wrote:The custom properties would be good for one or two pairs but I have about 11.
You would typically add a new script tool to assign those properties (i.e. My Menu > Mark Selection as Tree XY) or even a dialog to add / edit these properties.
growdigital wrote:Was thinking of creating simple database/JSON file to keep track, and hoping that this data could be linked easily.
If you are looking for an ID to use as reference, you can use the object handle for this (see property editor). The handle of an object is persistent (stored to DXF/DWG).

Re: Easiest way to link data to an object?

Posted: Fri Jan 06, 2017 5:20 pm
by growdigital
Brilliant, thank you for this, will have play with it.

On a related note, is it easy to /export/ the data from Custom Properties?

many thanks, Jake

Re: Easiest way to link data to an object?

Posted: Mon Jan 09, 2017 9:31 am
by andrew
growdigital wrote:On a related note, is it easy to /export/ the data from Custom Properties?
Custom properties are automatically saved to DXF/DWG files. Export to other formats would have to be implemented. The effort for this greatly depends on the complexity on the desired format. Accessing / listing custom properties is straightforward (RObject::getCustomPropertyTitles, RObject::getCustomPropertyKeys, RObject::getCustomProperty).

Re: Easiest way to link data to an object?

Posted: Mon Jan 09, 2017 10:10 am
by growdigital
Fantastic, thank you :)

Re: Easiest way to link data to an object?

Posted: Fri May 08, 2020 10:14 am
by dfriasb
andrew wrote:
Fri Jan 06, 2017 3:37 pm
If you are looking for an ID to use as reference, you can use the object handle for this (see property editor). The handle of an object is persistent (stored to DXF/DWG).
So entity Id only works on dxf, do it?

Re: Easiest way to link data to an object?

Posted: Fri May 08, 2020 1:52 pm
by andrew
DXF and DWG.

Re: Easiest way to link data to an object?

Posted: Sat May 09, 2020 10:30 am
by dfriasb
I have made a function that prints into command line all Custom Properties from selected entities. I hope someone can find it useful. I'm planning to write some similar function to print this data into csv in order to export to spreadsheets.
Best regards, David.
queryCustomPropertiesFromSelection.js
(928 Bytes) Downloaded 649 times

Re: Easiest way to link data to an object?

Posted: Sat May 09, 2020 12:19 pm
by dfriasb
By the way, is there any way to create Custom Properties with Tittle different from "QCAD" inside QCAD application? And any idea of how could it be outside?

Re: Easiest way to link data to an object?

Posted: Mon May 11, 2020 7:42 am
by andrew
QCAD properties are stored as column separated key / value pair strings and QCAD needs to know which properties it can handle when loading a file (those stored with the "QCAD" app ID).

You can use another app ID, but then properties will be stored the Autocad way (number code + value of type int, double, string, ...).