Page 1 of 1

? [solved] Add custom property in library item script

Posted: Fri May 16, 2014 9:35 am
by spatz
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)

Re: ? Add custom property in library item script

Posted: Sat May 17, 2014 2:33 pm
by hungerburg
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.

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

Posted: Sat May 17, 2014 10:29 pm
by spatz
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

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

Posted: Tue May 20, 2014 12:16 pm
by hungerburg
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?

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

Posted: Tue May 20, 2014 6:32 pm
by spatz
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