? [solved] Add custom property in library item script

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
spatz
Junior Member
Posts: 16
Joined: Sun Mar 11, 2012 12:25 pm

? [solved] Add custom property in library item script

Post by spatz » Fri May 16, 2014 9:35 am

Hello,

I wrote a library item script for inserting drawings of steel sections in several sizes according to DIN standard. Now I want to add a custom property to the (polyline) entity using the .setProperty() method like it's shown here https://ribbonsoft.com/rsforum/viewtopic.php?p=4552.

But when I add this code (line 89/90 in attached file "StructuralSteelSectionsI.js")

Code: Select all

	var des = "DIN 1025-1" + " - " + "I " + StructuralSteelSectionsI.hi ;
	polylineEntity.setProperty(new RPropertyTypeId("designation"), des);
there's nothing shown in the property editor and I get the following error message:

Code: Select all

Warning:  RObject::setProperty:  cannot set custom property with empty title or name
I printed the content of variable "des" with "qdebug(des)" and it showed the right value. Changing the color using

Code: Select all

polylineEntity.setColor(new RColor("blue"));
worked, so I guess the variable "polylineEntity" is also a correct Entity object. What did I miss?

Best regards
Stephan

Edit:
I'm using QCAD version 3.5.1.0 on Linux Mint Debian (32bit)
Attachments
StructuralSteelSectionsI.ui
(2.78 KiB) Downloaded 605 times
StructuralSteelSectionsI.js
(4.33 KiB) Downloaded 528 times
Last edited by spatz on Sat May 17, 2014 10:14 pm, edited 1 time in total.

User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

Re: ? Add custom property in library item script

Post by hungerburg » Sat May 17, 2014 2:33 pm

Hello Spatz, the post you refer to is three years old. The interface did change since then. Discussion and up to date sample code here http://www.qcad.org/bugtracker/index.ph ... omment1239 and documentation here http://www.qcad.org/doc/qcad/3.0/develo ... 908190d766

Basically, setCustomProperty() takes three parameters, thats the complaint you receive.

spatz
Junior Member
Posts: 16
Joined: Sun Mar 11, 2012 12:25 pm

Re: ? [solved] Add custom property in library item script

Post by spatz » Sat May 17, 2014 10:29 pm

Hello hungerburg,

thank you for your quick reply. Replacing setProperty() with setCustomProperty() and using three parameters indeed solved my problem (see updated script attached).

Best regards
Stephan
Attachments
StructuralSteelSectionsI.js
(4.52 KiB) Downloaded 559 times

User avatar
hungerburg
Premier Member
Posts: 160
Joined: Fri May 28, 2010 7:35 pm

Re: ? [solved] Add custom property in library item script

Post by hungerburg » Tue May 20, 2014 12:16 pm

Hello Spatz, I copied the script to the library and can see the I-beam in the browser, but I cannot put it into a drawing. What else would I have to do for that?

spatz
Junior Member
Posts: 16
Joined: Sun Mar 11, 2012 12:25 pm

Re: ? [solved] Add custom property in library item script

Post by spatz » Tue May 20, 2014 6:32 pm

Hello Hungerburg,

did you also download the .ui file in my first post? I didn't upload it again because I hadn't changed it since.

Best regards
Stephan

Post Reply

Return to “QCAD Programming, Script Programming and Contributing”