Book a Demo

Author Topic: Shape Script for custom shape  (Read 2894 times)

ron-AEGON

  • EA Novice
  • *
  • Posts: 3
  • Karma: +0/-0
    • View Profile
Shape Script for custom shape
« on: June 11, 2008, 03:01:43 am »
Hello, I am trying to create a custom stereotype for a database object. I would like the object to look like a database object in 3D, similar to that found in Visio.

Here is the script that I've been trying to use. However, I can't quite figure out the arc method that will create the lower circular line (arc), to connect the 2 lower points of the rectangle.

Can anyone help with this?

setlinestyle("solid");
      
drawnativeshape();      //Subsequent shapes will superimpose
      
//rectangle(left, top, right, bottom);
rectangle(0,15,90,45);      //background rectangle

ellipse(0,0,90,30);      //top circle
      
startpath();
arc(0,0,145,90,-3000,0,0,1000);
endpath();
fillandstrokepath()

JohnDoe

  • EA User
  • **
  • Posts: 191
  • Karma: +0/-0
  • EA rocks !
    • View Profile
Re: Shape Script for custom shape
« Reply #1 on: June 11, 2008, 05:11:35 am »
Try this:

shape main
{
       setfillcolor(255,180,100);
       startpath();
       moveto(0,20);
       bezierto(0,0,100,0,100,20);
       lineto(100,80);
       bezierto(100,100,0,100,0,80);
       lineto(0,20);
       endpath();
       fillandstrokepath();
       bezierto(0,40,100,40,100,20);
}

---
First of all: The shape scripts are defined in percentage values ! This has driven me crazy to find out. Your number values are far too high !

The arc command means:

left upper point and right lower point (0,0) and (100,100) <= 100% !!

You can see the result in the preview of the shape editor. If you create shapes smaller than 100%, it gets scaled down in the diagrams (and this is the reason). If you scale values > 100, your shape leaves the shape border. Think in percentages, when you script the shapes !


-------------------
by the way:
you can put external images (WMF, EMF) into the EA project images folder (menu "settings"->"images") and use the "image" command in shape script to show a transparent metafile.

image(
       string imageId,    <= imageNameInImageBrowser e.g.: "pic.wmf"
       int left,      0
       int top,      0
       int right,       100 (=% !!)
       int bottom)   100   (=% !!)


just in case, you're trying to reinvent graphics that are already on your harddrive :-)

Best wishes
Bernd
« Last Edit: June 11, 2008, 08:05:11 am by BerndWill »