Author Topic: Creating Custom Shapes  (Read 20200 times)

0 Members and 1 Guest are viewing this topic.

tbrown

  • Newbie
  • *
  • Posts: 4
Creating Custom Shapes
« on: May 23, 2012, 04:11:43 PM »
Everyone,

In the Visio 2010 standard stencils there is a tab for Valves and Fittings (US Units). There is a Globe Valve symbol, after this symbol is placed into my drawing I can go to the shape data tab and change the Valve type to Globe Valve 2 or 3. When I change the type the symbol on my drawing changes automatically to have a shaded circle in the middle. I am looking to do this same thing with my own custom shapes. Basically I am looking to use this one shape as my valve symbol so I can place it in a drawing then choose my valve type afterwards. Could anyone help me with this? Thanks in advance.

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: Creating Custom Shapes
« Reply #1 on: May 24, 2012, 01:45:27 AM »
Hello,

I can only give you some general advice, where to start:
At first you should add the "Developer"-Tap to the ribbon menu. The dialog to customize your menus is somewhere in the Visio options.
In the developer menu is a item, that lets you see the ShapeSheet of a selected shape, so you can select your valve shape, open it's ShapeSheet and look how the "magic" is done.

But to really understand what's happening there, you should learn more about the ShapeSheet first:
http://blogs.msdn.com/b/wmorein/archive/2006/01/27/518543.aspx


tbrown

  • Newbie
  • *
  • Posts: 4
Re: Creating Custom Shapes
« Reply #2 on: May 24, 2012, 10:42:58 AM »
Jumpy thanks for responding so quickly. I have played around in the ShapeSheet for the Globe Valve and found in the shape data under the Prop.SubType. If I change the type to Globe Valve 2 the value looks like it references an index. Do I need to create an index to reference? I can get the valve I want to customize to have the Valve type drop down I just don't know how to get it to reference the different shapes. Let me know if you have any other ideas or if you can tell me anything more. Thanks.

Jumpy

  • Hero Member
  • *****
  • Posts: 1061
Re: Creating Custom Shapes
« Reply #3 on: May 25, 2012, 01:42:31 AM »
could you upload an example .vsd with the
- original valve shape
- your custom shape
- explanations, what you want your custom shape to do

I guess that will be the best way to help you.

As to the ShapeData. Say there is a colum Prop.YourData.Format with a stinglist in it "A;B;C;D".
In the Prop.YourData.Value cell you find a formular like INDEX(1,Prop.YourData.Format).
I guess that is what you mean with Index? It only means: What is Item 1 in that Stringlist, so in this example "B" because the list is 0-based.
As to the shape changing it's look and behaviour: Usually there are many cells in the ShapeSheet, that look at the ShapeData and have formulas like (in Pseudocode) "IF ShapeDate=1 Then X ELSE IF ShapeData=2 Then Y ELSE Z".


hth Jumpy

tbrown

  • Newbie
  • *
  • Posts: 4
Re: Creating Custom Shapes
« Reply #4 on: May 25, 2012, 10:30:27 AM »
For simplicity lets just use a triangle. I insert a triangle into a drawing. But later decide that I want it to be a square. So instead of drawing a new shape I just want to have a drop down menu in the shape data that I could choose square. Once I choose this then the shape changes to a square. I can get to the point of having the drop down but I cannot figure out where I need to store, and how to make this master shape reference back to square so it updates automatically.

I hope this is a better explanation. Thanks for your help.


nashwaan

  • Full Member
  • ***
  • Posts: 85
Re: Creating Custom Shapes
« Reply #5 on: May 25, 2012, 06:16:40 PM »
On a new drawing document, create a rectangle shape and circle shape:



You may want to format the line and fill of these two shapes:



Now, move these two shapes to a same location:



Group the shapes (select the two shapes and right-click > Group > Group):



Right-click the group shape > Data > Define Shape Data... and enter the following:
Label: Type
Name: Type
Type: Fixed List
Format: Circle;Square
Value: Circle



Display the Shape Data of this group (in case it is not shown already) by right-click > Data > Shape Data...
You will see the newly created Shape Data "Type" with "Circle" as the current selection.
Also note the name of the group shape (in my case, it is Sheet.3. It can be a different name)



Sub-select the circle shape which is inside the group shape. Note that the name of the circle shape must be different than the name of the group shape. (In case you want to be sure that the circle shape is really selected, just change the fill color and only the circle shape should change its color)



With the circle shape is sub-selected, right-click > ShapeSheet. Enter the following formulas:
LinePattern = IF(LOOKUP(Sheet.3!Prop.Type,Sheet.3!Prop.Type.Format)=0,1,0)
FillPattern   = IF(LOOKUP(Sheet.3!Prop.Type,Sheet.3!Prop.Type.Format)=0,1,0)
The meaning of the formula: Check the currently selected "Type" Shape Data of the group shape. If the currently selected value is first in the list (in our case this means "Circle"), then use solid line/fill; otherwise don't use line/fill.
Note that we are writing these formulas in Sheet.2 to refer to a selected value made at Sheet.3




Now sub-select the rectangle shape, right-click > ShapeSheet. Enter the following formulas:
LinePattern = IF(LOOKUP(Sheet.3!Prop.Type,Sheet.3!Prop.Type.Format)=1,1,0)
FillPattern   = IF(LOOKUP(Sheet.3!Prop.Type,Sheet.3!Prop.Type.Format)=1,1,0)
The meaning of the formula: Check the currently selected "Type" Shape Data of the group shape. If the currently selected value is second in the list (in our case this means "Square"), then use solid line/fill; otherwise don't use line/fill.




If the above is done correctly, then if you go back and select the group shape and select the "Circle" in the Shape Data, you will see circle shape only.



And if you select the "Square" in the Shape Data, you will see square shape only.


I have inspected the Globe Valve shape and it has slightly different formulas; but the idea is the same.
Hope this helps.
Yousuf.
« Last Edit: May 25, 2012, 06:35:19 PM by nashwaan »
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

aledlund

  • Hero Member
  • *****
  • Posts: 1412
Re: Creating Custom Shapes
« Reply #6 on: May 26, 2012, 08:31:19 AM »
Nicely done  :)
al

tbrown

  • Newbie
  • *
  • Posts: 4
Re: Creating Custom Shapes
« Reply #7 on: June 01, 2012, 09:09:42 AM »
This works great thanks everyone for the help!

wapperdude

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 3828
  • Ideas Visio-lized into solutions
Re: Creating Custom Shapes
« Reply #8 on: June 01, 2012, 11:47:57 PM »
There is a slightly more compact approach for this.  Rathering than grouping the shapes, build them all into one shape.  For example, draw the circle.  Then open it's shapesheet.  Next, insert another geometry section.  Do this for as many shapes as desired.  In each of the new geometry sections, enter the "coordinate" values to create a new shape.  Then, using the "if" and "lookup" functions, enable/disable the fill and line properties.  Similarly, use the "if" & "lookup" to set the fill and line colors.

I believe this makes Visio run a little more efficienctly, and eliminates the confusion that sometime arises when clicking on a grouped shape more than once.

The attached file does three shapes:  circle, square, triangle, each with a unique color set.

HTH
Wapperdude
« Last Edit: June 02, 2012, 08:30:43 PM by wapperdude »
Visio 2019 Pro

nashwaan

  • Full Member
  • ***
  • Posts: 85
Re: Creating Custom Shapes
« Reply #9 on: June 02, 2012, 11:29:58 AM »
I fully agree with wapperdude. It is more efficient to have a single shape rather than a bunch of shapes grouped in a shape. I actually don't understand why microsoft designed the Globe Valve using multiple shapes when it can be done by a single shape (this is against what they preach!).

However, it might be easier for a beginner to go for mutiple shapes in a group approach; otherwise fiddling with geometry sections and using many formulas can be unpleasant journey for starters.

As for sub-selecting sub shapes after the multi-shape is designed: it can be sealed by setting the SelectMode of the group shape to 0.



I should also say here that hiding/showing the sub-shape via its LinePattern and FillPattern is not the best approach. A better approach would be inserting the formulas in the GeometryX.NoShow cells and HideText cell. My previous post was done in a way to mimic the micorosoft approach for Globe Valve.


It should be noted that VisGuy has in-depth treatment of multi-shape development (which shouldn't be missed by any multi-shape developer):
Visio Multi-shapes - http://www.visguy.com/2008/11/10/visio-multi-shapes/

Also, the Visio developers team published this great article:
Building Shapes the Easy Way - http://blogs.msdn.com/b/visio/archive/2006/07/18/670154.aspx
Creating a Multi-shape - http://blogs.msdn.com/b/visio/archive/2006/07/21/673305.aspx

Yousuf.
« Last Edit: June 02, 2012, 01:54:33 PM by nashwaan »
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

vojo

  • Hero Member
  • *****
  • Posts: 1521
Re: Creating Custom Shapes
« Reply #10 on: June 02, 2012, 03:53:24 PM »
unless ALL regions (shape faces, geometries, etc)  of a shape are exactly the same color, same fill, same line color, same line thickness, etc.....

groups ARE the only way to go

nashwaan

  • Full Member
  • ***
  • Posts: 85
Re: Creating Custom Shapes
« Reply #11 on: June 03, 2012, 12:51:55 AM »
I disagree with you on this, vojo.
You can still have a single shape that changes its look and also its color.
wapperdude has demonstrated this in his reply (part of this post) and attached a working example of Visio document. As he explained:

... Then, using the "if" and "lookup" functions, enable/disable the fill and line properties.  Similarly, use the "if" & "lookup" to set the fill and line colors...

Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

vojo

  • Hero Member
  • *****
  • Posts: 1521
Re: Creating Custom Shapes
« Reply #12 on: June 03, 2012, 08:52:22 PM »
for ALL geometries in that shape....you can NOT change the color of 1 geometry vs another

for example...you can NOT do this in a single shape (attachment)

Believe me I tried many times (would make life dramaticlly easier if possible)....so for a given shape, color, fill, etc apply to ALL geometries of a shape


nashwaan

  • Full Member
  • ***
  • Posts: 85
Re: Creating Custom Shapes
« Reply #13 on: June 04, 2012, 12:26:50 AM »
Ok I see your point now.  :)
You are right. A single shape cannot have different colors applied on different geometry sections.

The shape that you attached is very interesting.  8)
How did you get the highlight effect on the face of cube which is movable by a control point?

Thanks,
Yousuf.
Give me six hours to chop down a tree and I will spend the first four sharpening the axe — Abraham Lincoln

vojo

  • Hero Member
  • *****
  • Posts: 1521
Re: Creating Custom Shapes
« Reply #14 on: June 04, 2012, 06:55:31 AM »
fill free to poke around the group and individual shapes (may need to go to format to enable looking at subshapes of the group).

Basically, if a geometry of a subshape is outside the boundary of a group (even if no show = true), any fill patterns is against the width/height of all geometries of that shape.

so by moving the control point then hiding it....can move the shadows around as well.

BTW, this cube is based on some work June the 2nd did about 5 years ago....so due credit goes to him as well.
I believe Visio Guy came up with the movable highlight in order to make a circle look like a sphere.