? [solved] Add custom property in library item script

Discussion forum for contributors and developers who are using the QCAD version 3 ECMAScript development platform or the C++ plugin interface or who are otherwise looking to contribute to QCAD (translations, documentation, etc).

Moderator: andrew

? [solved] Add custom property in library item script

Postby 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 9 times
StructuralSteelSectionsI.js
(4.33 KiB) Downloaded 8 times
Last edited by spatz on Sat May 17, 2014 10:14 pm, edited 1 time in total.
spatz
Newbie Member
 
Posts: 5
Joined: Sun Mar 11, 2012 12:25 pm

Re: ? Add custom property in library item script

Postby 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.
User avatar
hungerburg
Senior Member
 
Posts: 125
Joined: Fri May 28, 2010 7:35 pm

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

Postby 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 9 times
spatz
Newbie Member
 
Posts: 5
Joined: Sun Mar 11, 2012 12:25 pm

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

Postby 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?
User avatar
hungerburg
Senior Member
 
Posts: 125
Joined: Fri May 28, 2010 7:35 pm

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

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


Return to QCAD 3 Developers and Contributors

Who is online

Users browsing this forum: No registered users and 1 guest

cron