You need to put the condition in the decoration code too to prevent the decoration showing but because your using the DrawNativeShape() method you just get whats already there. Another approach is to put a stereotype on the diagram and write the whole script and not use DrawNativeShape().
Here is an example of an application component script for ArchiMate that changes the shape to circle if the stereotype of the diagram is "BubbleChart".
As you can see I don't use DrawNativeShape() method as I need to put the condition in both main and decoration code fragments.
shape main
{
layouttype="border";
if(hasproperty("diagram.stereotype","BubbleChart"))
{
defsize(100,100);
ellipse(0,0,100,100);
addsubshape("padding","n");
addsubshape("bubblename","center");
}
else
{
defsize(90,70); //
rectangle(0,0,100,100);
addsubshape("padding","n");
if(hasproperty("rectanglenotation","0"))
{
addsubshape("port","w");
}
addsubshape("name","center");
}
shape bubblename
{
h_align="center";
println("#name#");
}
shape port
{
preferredwidth=20;
scalable=false;
rectangle(-10,-10,10,0);
rectangle(-10,10,10,20);
}
shape padding
{
preferredheight=15;
}
shape name
{
h_align="center";
print("#name#");
}
}
decoration component
{
orientation="ne";
if(hasproperty("diagram.stereotype", "BubbleChart"))
{
return;
}
if(hasproperty("rectanglenotation","0"))
{
return;
}
else
{
rectangle(0,0,60,100);
rectangle(-10,10,10,30);
rectangle(-10,50,10,70);
}
}
decoration composite
{
orientation="SE";
if(hasproperty("diagram.stereotype", "BubbleChart"))
{
return;
}
if(hasproperty("iscomposite","true"))
{
ellipse(0,40,40,60);
ellipse(60,40,100,60);
moveto(30,50);
lineto(70,50);
}
}