Search code examples
c#visiobpmnvisio2013

Creating Shapes in visio using c#


Hi i need to develop an addin for creating diagram objects in visio.I am able to create the top shape but not its derived types . for EG i am able to creat Start event in visio using c#, but couldn't create Start Event of message type or others enter image description here

In the above picture i have 3 start event , well the BPMN Start Event was added and its property Trigger/Result option was changed

Start Event - Multiple

Start Event - Message

Start Event - None

but all the above 3 shapes are from Start Event. How to create the Message start event or Multiple start evet etc.

I am creating shapes in visio using

            Visio.Master shapetodrop = Masters.get_ItemU(@"Start Event");
            Visio.Shape DropShape = ActivePage.Drop(shapetodrop, x, y);
            DropShape.Name = name;
            DropShape.Text = name;

but this only creates Start Event , how to create Message Start EVent , Multiple Start Event etc


Solution

  • For iteration through each property of a shape in visio

      short iRow = (short)Visio.VisRowIndices.visRowFirst;
                while (shape.get_CellsSRCExists((short)Visio.VisSectionIndices.visSectionProp, iRow, (short)Visio.VisCellIndices.visCustPropsValue, (short)Visio.VisExistsFlags.visExistsAnywhere) != 0)
                {
                    Visio.Cell c = shape.get_CellsSRC((short)Visio.VisSectionIndices.visSectionProp, iRow, (short)Visio.VisCellIndices.visCustPropsValue);
                             switch (c.Name)
                            {
                                case "Prop.BpmnTriggerOrResult":
                                    shape.Cells[c.Name].FormulaU = "\"" + "Message" + "\"";
                                    break;
    
                            }
    }
    

    and i can get Message start event. Like this value for all the property of a shape can be assigned.