Author Topic: Shape script optionality  (Read 3229 times)

Dave_Bullet

  • EA User
  • **
  • Posts: 291
  • Karma: +0/-0
    • View Profile
Shape script optionality
« on: December 22, 2008, 09:33:32 am »
We need a way to control whether the script applies to an element or not on a diagram.

On most diagrams, we want a standard rendering with shape script.  Problem is, we want to have one custom diagram type where user can render however they want.

Can Sparx please allow shape script execution to be conditional?

The best solution I can think of is permitting a return with a value within the shapescript itself that EA will check.  For example:
- return 0 - render using the statements executed thus far
- return 1 - draw the native shape and allow the user to do all normal overrides (such as choose alternate image, background colour / font etc....)

For backward compatibility, a return without value would default to return 0.

Thanks,
David.
« Last Edit: December 22, 2008, 09:34:21 am by Dave_Bullet »
"I know I'm close to a good design, but it's like the balloon animals, squeeze in one spot and the problem moves down the line"

mrf

  • EA User
  • **
  • Posts: 311
  • Karma: +0/-0
    • View Profile
Re: Shape script optionality
« Reply #1 on: December 22, 2008, 12:10:04 pm »
Dave,

In the help, the following example script is given:

Code: [Select]
//Return Statement Shape

shape main
{
       if(hasTag("alternatenotation", "false"))
       {
               //draw ea's inbuild glyph
               drawnativeshape();

               //exit script with the return statement
               return;
       }
  
       //alternate notation commands
       //...
       rectangle(0,0,100,100);
}

That of course only makes decisions based on the tagged value of an element. As far as I know there's no current evaluation that will inspect a diagram's properties.

[edit]Just had a check and you could potentially use HasProperty to inspect whether diagram.name was a particular value.[/edit]
« Last Edit: December 22, 2008, 12:15:22 pm by mfraser »
Best Regards,

Michael

support@sparxsystems.com
"It is more complicated than you think." - RFC 1925, Section 2.8

Dave_Bullet

  • EA User
  • **
  • Posts: 291
  • Karma: +0/-0
    • View Profile
Re: Shape script optionality
« Reply #2 on: December 22, 2008, 12:28:19 pm »
Hi Michael,

Thanks that works for elements only.  I tried that before but for some reason I couldn't change the appearance in the EA UI.  Seems to work (must have been a scripting issue).

Would be good if EA could support drawnativeshape for connectors (the help explicitly states drawnativeshape() is not supported for connectors and when I tried it in the script - nothing is drawn where the connector is (ie. blank / empty space).

Cheers,
DAvid.
"I know I'm close to a good design, but it's like the balloon animals, squeeze in one spot and the problem moves down the line"

Dave_Bullet

  • EA User
  • **
  • Posts: 291
  • Karma: +0/-0
    • View Profile
Re: Shape script optionality
« Reply #3 on: December 22, 2008, 12:30:46 pm »
Ok - I've found one bug...

"select alternate image" is greyed out as a menu option on the element.  That is the user can change the colour / font etc... but not select an alternate image.  This would be good so the user can just choose some other graphic after "drawnativeshape()"

Thanks,
David.
« Last Edit: December 22, 2008, 12:33:49 pm by Dave_Bullet »
"I know I'm close to a good design, but it's like the balloon animals, squeeze in one spot and the problem moves down the line"