Book a Demo

Author Topic: Shape width and other attributes  (Read 4935 times)

Dima

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Shape width and other attributes
« on: January 20, 2010, 08:34:30 am »
Guys,

I'm laying around with Shape Scripts. All examples point for a constant shape size when drawing. It looks ugly though when I drop an element from the toolbox. How can I find current width and height of the element?

Dima.

Sygnus

  • EA User
  • **
  • Posts: 21
  • Karma: +0/-0
    • View Profile
Re: Shape width and other attributes
« Reply #1 on: January 27, 2010, 04:47:08 am »
Hi there.

I was stuck with this one for quite some time and found the following solutions:

1- You can set the scalable attribute to false, and have the units of the drawing methods behave like absolute pixel units.

2- If you need the shape to scale, you can export the profile checking the Element Size checkbox. If you do this, the elements will be sized after the size of the stereotypes on the profile diagram.

The only problem is that, if you use this second approach, there's usually a limit to how small you can scale the stereotype element... to circumvent this, you need to go to the diagram properties and uncheck all element feature visibility checkboxes, or you need to change the auto-size behavior of the elements.

Either way, you'll be able to resize your stereotypes and, when you drop the elements from the toolbar, they will have the same size they had when you defined the profile.

There was a third option, setting the width and the height on the stereotype attributes, but I don't remember what were the attribute names.

Hope this helps.

Marcelo

Dima

  • EA User
  • **
  • Posts: 20
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Shape width and other attributes
« Reply #2 on: January 27, 2010, 07:39:19 am »
Thanks for taking time and answering this.

I worked around the problem by creating metafiles using Visio (this solution found on one of the forums I don't have the link to anymore).

Basically, I can create any shape I need in 2 min using visio. If I need slightly different look - I create diff shape and assign it to an appropriate stereotype.

Also, in addition I use ShapeScript to add small "perks" using drawnativeshape(); abd then adding whatever small fixes I need.

With how ShapeScript is limited at this point - I think this is the most reasonable solution (if you have Visio).

KP

  • EA Administrator
  • EA Expert
  • *****
  • Posts: 2919
  • Karma: +55/-3
    • View Profile
Re: Shape width and other attributes
« Reply #3 on: January 27, 2010, 10:30:34 am »
A shape script can't query its element's size, but you can use the defSize(x,y); command to set the size. Units are pixels at 100% zoom. Example:

shape main
{
    defsize(50,50);
    ellipse(0,0,100,100);
}

will create a circle not an oval.
The Sparx Team
[email protected]