Easiest way to link data to an object?

Use this forum to ask questions about how to do things in QCAD.

Moderator: andrew

Forum rules
Always indicate Operating system, QCAD version
Attach Drawing files, Screenshots
Post one question per topic.
Post Reply
growdigital
Newbie Member
Posts: 9
Joined: Fri Oct 21, 2016 9:52 pm

Easiest way to link data to an object?

Post by growdigital » Wed Jan 04, 2017 2:00 pm

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!

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

Re: Easiest way to link data to an object?

Post by andrew » Wed Jan 04, 2017 2:07 pm

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 2485 times

growdigital
Newbie Member
Posts: 9
Joined: Fri Oct 21, 2016 9:52 pm

Re: Easiest way to link data to an object?

Post by growdigital » Fri Jan 06, 2017 3:30 pm

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

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

Re: Easiest way to link data to an object?

Post by andrew » Fri Jan 06, 2017 3:37 pm

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

growdigital
Newbie Member
Posts: 9
Joined: Fri Oct 21, 2016 9:52 pm

Re: Easiest way to link data to an object?

Post by growdigital » Fri Jan 06, 2017 5:20 pm

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

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

Re: Easiest way to link data to an object?

Post by andrew » Mon Jan 09, 2017 9:31 am

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

growdigital
Newbie Member
Posts: 9
Joined: Fri Oct 21, 2016 9:52 pm

Re: Easiest way to link data to an object?

Post by growdigital » Mon Jan 09, 2017 10:10 am

Fantastic, thank you :)

User avatar
dfriasb
Senior Member
Posts: 112
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Easiest way to link data to an object?

Post by dfriasb » Fri May 08, 2020 10:14 am

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?
David Frías Barranco | architect
[email protected] | davidfriasarquitecto.es

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

Re: Easiest way to link data to an object?

Post by andrew » Fri May 08, 2020 1:52 pm

DXF and DWG.

User avatar
dfriasb
Senior Member
Posts: 112
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Easiest way to link data to an object?

Post by dfriasb » Sat May 09, 2020 10:30 am

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 37 times
David Frías Barranco | architect
[email protected] | davidfriasarquitecto.es

User avatar
dfriasb
Senior Member
Posts: 112
Joined: Thu Mar 10, 2016 1:08 pm
Location: Calafell, Tarragona, Spain

Re: Easiest way to link data to an object?

Post by dfriasb » Sat May 09, 2020 12:19 pm

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?
David Frías Barranco | architect
[email protected] | davidfriasarquitecto.es

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

Re: Easiest way to link data to an object?

Post by andrew » Mon May 11, 2020 7:42 am

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

Post Reply

Return to “QCAD 'How Do I' Questions”