Book a Demo

Author Topic: ShapeScripts:how to display extend class attribute  (Read 3324 times)

udap2009

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
ShapeScripts:how to display extend class attribute
« on: March 19, 2010, 03:08:20 pm »
hello:
   i define a stereotype(myStereotype) applies to class and override Appearance by Shape Script,the script is the below,
  if i create a myStereotype element in a diagram and add some attribute for myStereotype,the mystereotype is not display the attribute,but the class do it.
  how can i display the attribute in diagram?
  thanks


shape main
{
      setpencolor(153,102,0);
      rectangle(0,0,100,100);
      addsubshape("namecompartment", 100, 40);
      addsubshape("serviceClassicon", 13,20, 83,-30);      
      
      shape namecompartment
      {
            h_align = "center";
            v_align = "center";
            editablefield = "name";
            setpencolor(153,102,0);
            rectangle(0,00,100,100);
            println(" ");
            println("#name #");
      }      
      shape serviceClassicon
      {
            setpen(200,150,0,1);
            rectangle(0,0,100,100);
            
            setpen(200,150,0,1);
            moveto(0,0);
            lineto(0,100);      
            moveto(100,0);
            lineto(0,0);      
            
            setpen(200,150,0,1);
            moveto(0,100);
            lineto(100,100);
            moveto(100,100);
            lineto(100,0);      
            
            rectangle(25,25,75,75);            
            setpen(150,100,0,2);                  
            moveto(15,40);
            lineto(35,40);      
            moveto(15,60);
            lineto(35,60);            
      }
}
« Last Edit: March 19, 2010, 03:09:58 pm by udap2009 »

Paolo F Cantoni

  • EA Guru
  • *****
  • Posts: 8626
  • Karma: +259/-129
  • Inconsistently correct systems DON'T EXIST!
    • View Profile
Re: ShapeScripts:how to display extend class attri
« Reply #1 on: March 19, 2010, 04:30:20 pm »
You can't access Attributes directly from a shape script (as far as I know).

If you include a drawnativeshape() command in your main shape, you can at least see the attribute.  You can then adjust the feature visibility to show only what you want.

HTH,
Paolo
Inconsistently correct systems DON'T EXIST!
... Therefore, aim for consistency; in the expectation of achieving correctness....
-Semantica-
Helsinki Principle Rules!

udap2009

  • EA Novice
  • *
  • Posts: 2
  • Karma: +0/-0
    • View Profile
Re: ShapeScripts:how to display extend class attri
« Reply #2 on: March 19, 2010, 07:51:16 pm »
by the meathod,the issue is ok.

thanks very much.

the modify shapescripts is the below:


shape main
{
 setpen(128,64,64,1);
 addsubshape("subClass", 25,25, 100,0);
 drawnativeshape();

 shape subClass
 {
       scalable = "false";
       setpen(128,64,64,1);
      rectangle(-28,7,-7,28);                  
      setpen(128,64,64,1);            
      moveto(-25,10);
      lineto(-25,24);      
      lineto(-11,24);
      lineto(-11,10);
      lineto(-25,10);
      
       moveto(-23,22);
       lineto(-18,13);      
       lineto(-13,22);
       moveto(-21,18);
       lineto(-15,18);
      
       moveto(-31,14);
       lineto(-25,14);
      
       moveto(-31,20);
       lineto(-25,20);
 }
}