none
Visio 2013 SDK 32 bit and Read Custom Shape Data Properties RRS feed

  • Question

  • Hello,

    I am trying to access a custom shape data property using Visio 2013 drawing control via an active-x reference wrapped in a host form.  Everything seems to be working fine, but it would seem that the included C# example (ReadANamedCustomPropertySample) does not actually work... =or= I am completely missing something.

    The scenario is this:

    I have a VSDX file that contains 3 pages, which each page contains their own set of shapes.  Upon loading the document, I parse through the pages and for each page I parse through each page's shapes list.  For each shape I search for a custom property that I have set via Visio 2013 (call it TestProperty) which is a simple boolean property...IE:

    TestProperty | True

    Is what you would see in the ShapeData window of any shape on any of the 3 pages that might have this property.

    I have literally copy and pasted the given ReadANamedCustomPropertySample  method from the 2013 SDK and have tried setting the property name as being both a local and non-local property value... IE:

    void SomeFunction(Visio.Shape ashape)
    {

         Visio.Cell TestCell = ReadANamedCustomProperty(ashape,"TestProperty",true);

         if(TestCell == null)
        {
            TestCell = ReadANamedCustomProperty(ashape,"TestProperty",false);
        }

    ...  

    }

    The only modification I have made to the example code is to just return the Cell that is found to contain the custom property contained within some of the shapes on each of the pages.  The custom property is created via Visio 2013 by just adding the custom property data, setting the name to "TestProperty", setting the type to Boolean, and then setting the value.

    I have confirmed that the custom property data does indeed reside on several shapes, have confirmed the program loading the vsdx file is loading the proper vsdx file, and yet no shape seems to contain the "TestProperty" custom data property which does indeed exist when viewed within Visio 2013 using the ShapeData properties window view.

    Since I am using the example given in the Visio 2013 SDK help file... I am a bit confused... as it doesn't appear to be working at all... am I not naming the property name properly? In Visio 2013 the name of the property is "TestProperty" and I am assuming that is the name we would search for...or is it some other name I must search for to give me a list that contains the custom data property?

    Anyone else having this issue?
    Any pointers/help would be greatly appreciated!

    Cheers,

    -Noel

    Wednesday, August 20, 2014 10:37 PM

Answers

  • I think I figured it out... :)

    Replace the above test code section that acquires each cell with:

    Visio.Cell cell = customPropertyShape.get_CellsSRC(iSect, iRow, (short)Visio.VisCellIndices.visCustPropsLabel);

    and you get:

    [0] = "Prop.Row_1.Label|Prop.Row_1.Label|Row_1|TestProperty"

    So, it would appear the "Label" is the name of the property in question and the Rows are just always rows...and will be named as such...Row_(n).

    Of course this means in order to parse through all of the information one must construct something like a dictionary that contains the label as the key and the value as the value to the label in order to most effectively parse through data.

    Is there an easier way to obtain the value of a row that contains a specific label or is this it?

    Cheers,

    -Noel


    Wednesday, August 20, 2014 11:08 PM

All replies

  • So,

    Here is a bit of code I added at the base of the ReadANamedCustomProperty method provided from the Visio 2013 SDK in order to better understand what the contents of the Visio.VisSectionIndices.visSectionProp type cells might be.

              if (customPropertyCell == null)
                {
                    List<String> NamesFound = new List<string>();
                    short iSect = (short)Visio.VisSectionIndices.visSectionProp;
                    if (0 != customPropertyShape.get_SectionExists(iSect, (short)Visio.VisExistsFlags.visExistsAnywhere))
                    {
                        for (short iRow = 0; iRow < customPropertyShape.get_RowCount(iSect); ++iRow)
                        {
                            if (0 != customPropertyShape.get_CellsSRCExists(iSect, iRow, (short)Visio.VisCellIndices.visCustPropsValue, (short)Visio.VisExistsFlags.visExistsAnywhere))
                            {
                                Visio.Cell cell = customPropertyShape.get_CellsSRC(iSect, iRow, (short)Visio.VisCellIndices.visCustPropsValue);
                                String stuff = cell.Name + "|" + cell.LocalName + "|" + cell.RowName + "|" + cell.get_ResultStr(Microsoft.Office.Interop.Visio.VisUnitCodes.visNoCast);
                                NamesFound.Add(stuff);
                                
                            }
                        }
                    }
                    if (NamesFound.Count() > 0)
                    {
                        String N1 = NamesFound[0];
                    }
                
                }

    I placed a break point where I assign NamesFound[0] to an arbitrary string.
    It would seem the *name* of the property is not translating over?   It would seem that the proper values for each shape that has the TestProperty shape data property value applied to it are correct (and confirmed the shape name matches) yet... the result looks like:

    [0] = "Prop.Row_1|Prop.Row_1|Row_1|TRUE"

    Where in Visio the first row of each Shape that has this property is name TestProperty, and as such I would expect it to look like:

    [0] = "Prop.TestProperty|Prop.TestProperty|TestProperty|TRUE"

    Don't know if this helps anyone looking at this issue or not... perhaps there is something in particular that I am not setting on the Visio 2013 side of things when I add the property to each Shape? 

    Otherwise, could this just be a bug?  Am I looking for some other "object" that is associated with the Cell(s) in question which might actually have the name that is being applied in Visio 2013?

    Thanks for any response!

    Cheers,

    Noel

    Wednesday, August 20, 2014 10:59 PM
  • I think I figured it out... :)

    Replace the above test code section that acquires each cell with:

    Visio.Cell cell = customPropertyShape.get_CellsSRC(iSect, iRow, (short)Visio.VisCellIndices.visCustPropsLabel);

    and you get:

    [0] = "Prop.Row_1.Label|Prop.Row_1.Label|Row_1|TestProperty"

    So, it would appear the "Label" is the name of the property in question and the Rows are just always rows...and will be named as such...Row_(n).

    Of course this means in order to parse through all of the information one must construct something like a dictionary that contains the label as the key and the value as the value to the label in order to most effectively parse through data.

    Is there an easier way to obtain the value of a row that contains a specific label or is this it?

    Cheers,

    -Noel


    Wednesday, August 20, 2014 11:08 PM