Sparx Systems Forum

Enterprise Architect => Automation Interface, Add-Ins and Tools => Topic started by: jguerra on November 08, 2008, 01:47:35 am

Title: Shape script and properties!
Post by: jguerra on November 08, 2008, 01:47:35 am
Hi,
In a shape script, I want to modify part of the text on an element only when the element is instantiated. I went through the property list and I didn't see anyone indicating something such as "isinstance"or similar. Is there any way to find that out?

Thanks
Title: Re: Shape script and properties!
Post by: KP on November 10, 2008, 09:17:36 am
Could you check for a non-null value of the "classifier" property?

Code: [Select]
if(hasproperty("classifier",""))
{
      print("no classifier");
}
else
{
      print("classifier=#classifier#");
}
Title: Re: Shape script and properties!
Post by: jguerra on November 10, 2008, 10:22:23 pm
Awesome !!

Thanks for the clues!. I updated the code snipped and this is what it looks like the now.
...
if(hasproperty("classifier",""))
{
        printwrapped("#name#");
} else
{
          printwrapped("#name#:#classifier.name#");
}
...

So, based on the criteria of whether or not we are dealing with an instance, the script prints out the name of the element (no instance, classifier == "") or the pattern <instance_name>:<classifier_name>. The Shape script was tested out on 7.1 b833 with no probs and the code snipped above works nicely and it does what it's meant to do!!

Thanks