Sparx Systems Forum

Enterprise Architect => General Board => Topic started by: Glassboy on October 01, 2018, 09:24:56 am

Title: Resizable pipe shape script
Post by: Glassboy on October 01, 2018, 09:24:56 am
Does anyone have a resizable pipe shape script like the Visio network icon?

If so can you post it here as I can't reach a lot of the file sharing sites from my work network.
Title: Re: Resizable pipe shape script
Post by: Eve on October 01, 2018, 11:05:18 am
You mean a cylinder?

Code: [Select]
shape main
{
setfixedregion(0,0,0,20);
startpath();
moveto(0,10);
setfixedregion(0,80,0,100);
lineto(0,90);
arcto(0,80,100,100,0,90,100,90);
setfixedregion(0,0,0,20);
lineto(100,10);
endpath();
FillAndStrokePath();

ellipse(0,0,100,20);
addsubshape("top",0,0,100,20);
}

Changing the height of your object changes the length of the pipe. Changing the width changes the view angle.
Title: Re: Resizable pipe shape script
Post by: Glassboy on October 01, 2018, 12:51:02 pm
Hmmm yes but going the other way.  That looks like a database :-)
Title: Re: Resizable pipe shape script
Post by: Eve on October 01, 2018, 03:23:34 pm
Hmmm yes but going the other way.  That looks like a database :-)
Which other way? I can think of three obvious ones.
Title: Re: Resizable pipe shape script
Post by: Eve on October 01, 2018, 03:41:04 pm
Bottom
Code: [Select]
shape main
{
setfixedregion(0,80,0,100);
startpath();
moveto(100,90);
setfixedregion(0,0,0,20);
arcto(0,00,100,20,100,10,0,10);
setfixedregion(0,80,0,100);
lineto(0,90);
endpath();
FillAndStrokePath();

ellipse(0,80,100,100);
}

Left
Code: [Select]
shape main
{
setfixedregion(0,0,20,0);
startpath();
moveto(10,100);
setfixedregion(80,0,100,0);
arcto(80,0,100,100,90,100,90,0);
setfixedregion(0,0,20,0);
lineto(10,0);
endpath();
FillAndStrokePath();

ellipse(0,0,20,100);
}

Right
Code: [Select]
shape main
{
setfixedregion(80,0,100,0);
startpath();
moveto(90,0);
setfixedregion(0,0,20,0);
arcto(0,0,20,100,10,0,10,100);
setfixedregion(80,0,100,0);
lineto(90,100);
endpath();
FillAndStrokePath();

ellipse(80,0,100,100);
}

Note: I removed the redundant lineto from before arcto in these scripts.

I just noticed that the arc portion of the script doesn't appear to obey the fixed region. To get it working nicely you would convert the scripts to use two bezier sections.
Title: Re: Resizable pipe shape script
Post by: Glassboy on October 02, 2018, 07:19:36 am
Thanks.  Right looks best with the existing deployment view shapes.  I noticed in the example you use an unspecialised node resized to be a rectangle but it doesn't look that great or really fit in on a nice tidy diagram :-)
Title: Re: Resizable pipe shape script
Post by: Eve on October 02, 2018, 05:16:02 pm
Here's a version of right where the left edge scales in the same way as the right.

Code: [Select]
shape main
{
setfixedregion(80,0,100,0);
startpath();
moveto(90,0);
setfixedregion(0,0,20,0);
//arcto(0,0,20,100,10,0,10,100);
lineto(10,0);
bezierto(4,0,0,28,0,50);
bezierto(0,72,4,100,10,100);
setfixedregion(80,0,100,0);
lineto(90,100);
endpath();
FillAndStrokePath();

ellipse(80,0,100,100);
}
Title: Re: Resizable pipe shape script
Post by: Glassboy on October 03, 2018, 07:57:56 am
Something about that approach makes the name subshape I added print at top left.  Any idea what?

Code: [Select]
AddSubShape("name", "center");
text name
{
h_align = "center";
v_align = "center";
        PrintWrapped("#NAME#");
   }
}
Title: Re: Resizable pipe shape script
Post by: Eve on October 03, 2018, 09:25:54 am
I'd say that when you copied the rest of my script you lost the following from the top of your script.

Code: [Select]
layouttype="border";
I would also add the following to center the text within the face.
Code: [Select]
AddSubShape("padding","e");
shape padding
{
    preferredWidth=20;
}
Title: Re: Resizable pipe shape script
Post by: Glassboy on October 03, 2018, 10:28:43 am
I'd say that when you copied the rest of my script you lost the following from the top of your script.
Code: [Select]
layouttype="border";

Ahh yes, obviously. Thanks.

I've been busy translated Visio fruit salad into proper deportment diagrams so it's been a bit hard to get my head properly into shape script mode. :-)
Title: Re: Resizable pipe shape script
Post by: Paolo F Cantoni on October 03, 2018, 04:43:36 pm
I'd say that when you copied the rest of my script you lost the following from the top of your script.
Code: [Select]
layouttype="border";

Ahh yes, obviously. Thanks.

I've been busy translated Visio fruit salad into proper deportment diagrams so it's been a bit hard to get my head properly into shape script mode. :-)
OK, I'll bite... What's a deportment diagram?   ;) ;)

Paolo
Title: Re: Resizable pipe shape script
Post by: qwerty on October 03, 2018, 05:57:23 pm
Try Google it has lots of colored pictures.

q.
Title: Re: Resizable pipe shape script
Post by: Glassboy on October 04, 2018, 06:08:57 am
OK, I'll bite... What's a deportment diagram?   ;) ;)

It's an orderly deployment diagram.
Title: Re: Resizable pipe shape script
Post by: Paolo F Cantoni on October 04, 2018, 08:38:15 am
OK, I'll bite... What's a deportment diagram?   ;) ;)

It's an orderly deployment diagram.
Does it have a "book" widget at the top to ensure it's smooth passage?

Paolo
Title: Re: Resizable pipe shape script
Post by: Glassboy on October 04, 2018, 11:40:12 am
Does it have a "book" widget at the top to ensure it's smooth passage?

I'm telling you man, I'm blowing vendor diagrams up to 300% to work out where their lines are running.  I'm on the edge.