[SOLVED] Assign custom properties to entities

Discussion forum for C++ and script developers who are using the QCAD development platform or who are looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

Forum rules

Always indicate your operating system and QCAD version.

Attach drawing files, scripts and screenshots.

Post one question per topic.

Post Reply
mink
Active Member
Posts: 30
Joined: Mon Jan 19, 2015 7:20 pm

[SOLVED] Assign custom properties to entities

Post by mink » Tue Mar 03, 2015 1:38 pm

Hi Andrew,

just to make sure: I'm trying to set / get custom properties from C++. I recognize that they are only available in the pro version - as documented. However, I compile / link my sources against the source code of the opensource version (which I compiled as debug). Compile / link works ok; as result, my plugin dll does not set custom properties in the pro version. However, using my plugin in the pro environment getting of custom properties works fine...

Is the behaviour which I figured out as desired? What do I need / can I do to be able to compile / link code with complete custom property acces?

Environment: QCAD 3.8.1 under OpenSuse 13.2; g++ etc.

Thanks in advance!

Ulrch

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

Re: Assign custom properties to entities

Post by andrew » Wed Mar 04, 2015 1:57 pm

You can explicitely enable custom properties in your plugin using:
RSettings::setXDataEnabled(true);
The Teigha Plugin for DXF/DWG support does that, so whenever that plugin is loaded, custom properties should be available. Without this plugin, you won't be able to save custom properties.

mink
Active Member
Posts: 30
Joined: Mon Jan 19, 2015 7:20 pm

Re: Assign custom properties to entities

Post by mink » Thu Mar 05, 2015 10:18 am

Hi Andrew,

thanks for your answer. The call of the setting in my plugins init() now shows the custom property widgets in the property editor. However, assigning custom properties from my c++ code has problems. Here is my code snipplet (not as long as in my other post ;-) :

Code: Select all

				nHighestSeamsectionNumber++;
				qDebug() << "buildSeamsequences4Circles set property to " << nHighestSeamsectionNumber;
				QString qsTitle = DACADGlobals::getCusPropNmTitle();
				QString qsKey = DACADGlobals::getCusPropNmSewingSectionId();
				QVariant qvValue(nHighestSeamsectionNumber);
				qDebug() << "qsTitle = " << qsTitle << "qsKey = " << qsKey << " qvValue = " << qvValue;
				entityPtr->setCustomProperty(qsTitle, qsKey, qvValue);
and the corresponding debug output:

Code: Select all

Debug:    buildSeamsequences4Circles set property to  1 
Debug:    qsTitle =  "QCAD" qsKey =  "DASewingSectionId"  qvValue =  QVariant(int, 1) 
However, the expected custom property does not show in the property editor.
Any idea what might be wrong?

As I want to be able to debug, I built debug binaries from the opensource 3.8.1 sources. I copied the Teigha shared lib from the pro (relase) distribution into the debug plugin directory; as expected, it does not load (not shown in the Help about plugin tab). Am I right that I need the c++ qcad libraries to be able to use all pro features in a debug version?
(NB: for my opinion the description of the c++ qcad libraries is too cryptic ...)

Regards,
Ulrich

mink
Active Member
Posts: 30
Joined: Mon Jan 19, 2015 7:20 pm

Re: Assign custom properties to entities

Post by mink » Fri Mar 06, 2015 11:37 am

I have to apologize.

I obviously made a mistake in transaction handling. The custom property was added to the entity, and then i tried to add it to a transaction with "addAffectedObject (RObject::Id objectId)". After using addObject, everything works fine (as least in the release version I alternatively tried).

Please close this post.

Regards,

Ulrich

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”