Vba 如何控制UML图中连接器的路径
我在visio中以编程方式绘制UML图,其中我使用动态连接器连接形状。但有时连接器会穿过形状而不是穿过页面(即连接器通过位于源和目标之间的另一个形状从源形状路由到目标形状),我希望连接器只能通过页面。请建议如何实现这一点。您必须从C#翻译过来,但我就是这样做的:Vba 如何控制UML图中连接器的路径,vba,uml,visio,Vba,Uml,Visio,我在visio中以编程方式绘制UML图,其中我使用动态连接器连接形状。但有时连接器会穿过形状而不是穿过页面(即连接器通过位于源和目标之间的另一个形状从源形状路由到目标形状),我希望连接器只能通过页面。请建议如何实现这一点。您必须从C#翻译过来,但我就是这样做的: /// <summary>Attaches two Visio shapes to each other with the specified connector object.</summary> /// &l
/// <summary>Attaches two Visio shapes to each other with the specified connector object.</summary>
/// <param name="shape1">Visio shape to connect from.</param>
/// <param name="shape2">Visio shape to connect to.</param>
/// <param name="connector">Visio line shape that will connect shape1 to shape2.</param>
/// <param name="straight">Whether this connector should be a straight line</param>
[CLSCompliant(false)]
protected static void ConnectShapes(
Visio.Shape shape1,
Visio.Shape shape2,
Visio.Shape connector,
bool straight = false)
{
try
{
// get the cell from the source side of the connector
Visio.Cell beginXCell = connector.CellsSRC[(short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXForm1D, (short)Visio.VisCellIndices.vis1DBeginX];
// glue the source side of the connector to the first shape
beginXCell.GlueTo(shape1.CellsSRC[(short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXFormOut, (short)Visio.VisCellIndices.visXFormPinX]);
// get the cell from the destination side of the connector
Visio.Cell endXCell = connector.CellsSRC[(short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXForm1D, (short)Visio.VisCellIndices.vis1DEndX];
// glue the destination side of the connector to the second shape
endXCell.GlueTo(shape2.CellsSRC[(short)Visio.VisSectionIndices.visSectionObject, (short)Visio.VisRowIndices.visRowXFormOut, (short)Visio.VisCellIndices.visXFormPinX]);
if (straight)
{
connector.CellsU["ConLineRouteExt"].ResultIUForce = (double)Visio.VisCellVals.visLORouteExtStraight;
connector.CellsU["ShapeRouteStyle"].ResultIUForce = (double)Visio.VisCellVals.visLORouteCenterToCenter;
}
else
{
// THIS IS WHAT YOU ARE LOOKING FOR
connector.CellsU["ConLineRouteExt"].ResultIUForce = (double)Visio.VisCellVals.visLORouteExtNURBS;
connector.CellsU["ShapeRouteStyle"].ResultIUForce = (double)Visio.VisCellVals.visLORouteRightAngle;
}
}
catch (Exception e)
{
throw (e);
}
}
///使用指定的连接器对象将两个Visio形状相互连接。
///要从中连接的Visio形状。
///要连接到的Visio形状。
///将连接形状1和形状2的Visio线条形状。
///此接头是否应为一条直线
[CLSCompliant(false)]
受保护的静态空心形状(
Visio.Shape shape1,
Visio.Shape形状2,
Visio.Shape连接器,
布尔直线=假)
{
尝试
{
//从连接器的源端获取单元
Visio.Cell beginXCell=connector.cellsrc[(短)Visio.vissectionindex.visSectionObject,(短)Visio.visrowindex.visRowXForm1D,(短)Visio.viscellindex.vis1DBeginX];
//将连接器的源侧粘合到第一个形状
beginXCell.GlueTo(shape1.cellsrc[(短)Visio.vissectionindex.visSectionObject,(短)Visio.visrowindex.visRowXFormOut,(短)Visio.viscellindex.visXFormPinX]);
//从连接器的目标端获取单元
Visio.Cell endXCell=connector.cellsrc[(短)Visio.vissectionindex.visSectionObject,(短)Visio.visrowindex.visRowXForm1D,(短)Visio.viscellindex.vis1DEndX];
//将连接器的目标侧粘合到第二个形状
endXCell.GlueTo(shape2.cellsrc[(短)Visio.vissectionindex.visSectionObject,(短)Visio.visrowindex.visRowXFormOut,(短)Visio.viscellindex.visXFormPinX]);
如果(直线)
{
connector.CellsU[“ConLineRouteExt”]。ResultIUForce=(双精度)Visio.VisCellVals.visloroutextright;
connector.CellsU[“ShapeRouteStyle”]。ResultIUForce=(双精度)Visio.VisCellVals.visLORouteCenterToCenter;
}
其他的
{
//这就是你要找的
connector.CellsU[“ConLineRouteExt”]。ResultIUForce=(双精度)Visio.VisCellVals.visloroutextnurbs;
connector.CellsU[“ShapeRouteStyle”]。ResultIUForce=(双精度)Visio.VisCellVals.visLorOuterRightAngle;
}
}
捕获(例外e)
{
投掷(e);
}
}