none
Add Geometry of Connector Shape pragmatically RRS feed

  • Question

  • Hi Guys

    I create shapes and connectors with C# but I want to set Geometry of connectors (I mean lineTo, MoveTo) by code too.

    I tried this code but it raise: This section type does not support named rows

    short iRow = (short)(Microsoft.Office.Interop.Visio.VisRowIndices.visRowVertex);
    short visTagLineTo = (short)Microsoft.Office.Interop.Visio.VisRowTags.visTagLineTo;
    var aa = newShape.get_Section(1);
    short sectionId = (short)(newShape.AddSection(
        (short)Microsoft.Office.Interop.Visio.VisSectionIndices.visSectionFirstComponent));
    var row = newShape.AddNamedRow(sectionId, "LineTo", visTagLineTo);

    Actually I don't know how to get the Geometry1 section.

    Thanks you....


    • Edited by Daneshk Thursday, September 11, 2014 7:20 PM
    Thursday, September 11, 2014 7:20 PM

Answers

  • Hi Daneshk,

    Based on the description, you want to change the appearence for the connectors. I am not sure about "lineTo" and 'MoveTo', but I suggest that you do it manually and recorod a macro to get the API to do the same job. Then you can remove the unnecessary and modify it based on your requirement.

    Hope it is helpful.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 12, 2014 8:03 AM
    Moderator

All replies

  • Hi Daneshk,

    Based on the description, you want to change the appearence for the connectors. I am not sure about "lineTo" and 'MoveTo', but I suggest that you do it manually and recorod a macro to get the API to do the same job. Then you can remove the unnecessary and modify it based on your requirement.

    Hope it is helpful.

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Friday, September 12, 2014 8:03 AM
    Moderator
  • Did you try to debug the code?

    What line of code fires an exception?

    Friday, September 12, 2014 12:22 PM
  • this method raises exception:

    newShape.AddNamedRow(sectionId, "LineTo", visTagLineTo);

    and when I use     newShape.AddRow(sectionId, iRow, visTagLineTo);      instead it raises:

    Unexpected end of file

    Friday, September 12, 2014 1:14 PM
  • Hi Fei

    Thank you for your reply.

    I went trough your solution.

    It give me this code:

    Sub Macro1()
    
        'Enable diagram services
        Dim DiagramServices As Integer
        DiagramServices = ActiveDocument.DiagramServicesEnabled
        ActiveDocument.DiagramServicesEnabled = visServiceVersion140 + visServiceVersion150
    
        Dim UndoScopeID1 As Long
        UndoScopeID1 = Application.BeginUndoScope("Manual Edit")
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionObject, visRowXFormOut, visXFormWidth).FormulaForceU = "GUARD(EndX-BeginX)"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionObject, visRowXFormOut, visXFormHeight).FormulaForceU = "GUARD(0.25IN)"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionObject, visRowTextXForm, visXFormPinX).FormulaU = "4.1606500694979"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionObject, visRowTextXForm, visXFormPinY).FormulaU = "1.0775636793306"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionObject, visRowShapeLayout, visSLOConFixedCode).FormulaForceU = "3"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 0, visCnnctX).FormulaU = "2.0800694284036"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 0, visCnnctY).FormulaU = "0.60704796885466"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 1, visCnnctX).FormulaU = "4.1601544464995"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 1, visCnnctY).FormulaU = "1.0777050872997"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 2, visCnnctX).FormulaU = "6.2415355565837"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 2, visCnnctY).FormulaU = "0.60135254364972"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 3, visCnnctX).FormulaU = "4.1601544464995"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 3, visCnnctY).FormulaU = "1.0777050872997"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionFirstComponent, 1, 0).FormulaForceU = "0"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionFirstComponent, 1, 1).FormulaForceU = "0.125"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionFirstComponent, 2, 0).FormulaForceU = "4.1354166666667"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionFirstComponent, 2, 1).FormulaForceU = "1.0833666666667"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionFirstComponent, 3, 0).FormulaForceU = "8.3229166666667"
        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionFirstComponent, 3, 1).FormulaForceU = "0.125"
        Application.EndUndoScope UndoScopeID1, True
    
        'Restore diagram services
        ActiveDocument.DiagramServicesEnabled = DiagramServices
    
    End Sub

    It seems that these parts are setting LineTo:

        Application.ActiveWindow.Page.Shapes.ItemFromID(209).CellsSRC(visSectionConnectionPts, 1, visCnnctX).FormulaU = "4.1601544464995"

    but we don't have anything similar to this method:CellsSRC in C# API. 

    It takes a lot of my time.

    If you know any books or document related to this please tell me.

    Regards

    Danesh

    Friday, September 12, 2014 2:25 PM
  • Hi Danesh,

    As far as I know, the Shape.CellsSRC is used to Returns a Cell object that represents a ShapeSheet cell identified by section, row, and column indices.

    And you can get the its reference from link below:
    Shape.CellsSRC

    And here is the reference for the Visio Object model:
    Visio Object Model Reference

    Best regards

    Fei


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, September 15, 2014 6:52 AM
    Moderator