Sparx Systems Forum

Enterprise Architect => Bugs and Issues => Topic started by: udap2009 on March 19, 2010, 03:08:20 pm

Title: ShapeScripts:how to display extend class attribute
Post by: udap2009 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);            
      }
}
Title: Re: ShapeScripts:how to display extend class attri
Post by: Paolo F Cantoni 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
Title: Re: ShapeScripts:how to display extend class attri
Post by: udap2009 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);
 }
}