Code for listing shape data properties ?!?

Started by VisioBut, July 06, 2009, 05:11:08 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

VisioBut

Hallo there,

Im trying to write a script which should retrieve the user defined shape data properties. Unfortunately I coudlnt figure out how to do it.

Can anyone give a code sniplet how this could be done ???

Thank you in advance.

P.S. Im using Python if this is of importance.

Paul Herber

here is some code to dump the pagesheet custom properties into a memo on am output dialog. You'll need to modify it to access a shape rather than the pagesheet, and my code is written in Delphi, not Python.


    pagObj := VSL.visApp.ActivePage;
    pagesheetObj := pagObj.PageSheet;
    if (pageSheetObj.SectionExists[visSectionProp,1] <> 0) then
    begin
      for propertyCounter := 0 to pageSheetObj.RowCount[visSectionProp]-1 do
      begin
        SymbolListDlg.OutputMemo.Lines.Add(fStr(propertyCounter) + ':');
        name := pageSheetObj.CellsSRC[visSectionProp, propertyCounter,0].Name;
        localName := pageSheetObj.CellsSRC[visSectionProp, propertyCounter,0].LocalName;
        rowName := pageSheetObj.CellsSRC[visSectionProp, propertyCounter,0].RowName;
        SymbolListDlg.OutputMemo.Lines.Add('  Name =       ' + name);
        SymbolListDlg.OutputMemo.Lines.Add('  Local name = ' + localName);
        SymbolListDlg.OutputMemo.Lines.Add('  Row Name =   ' + rowName);
      end;
    end


Electronic and Electrical engineering, business and software stencils for Visio -

https://www.paulherber.co.uk/

VisioBut

10x for the snipplet.

the property visSectionProp in the VB documentation is shown to be found at a Visio object. A Visio obj in VB corresponds to an application obj or ... ?

Another question: if a user property is decleared as String with a Value some string, than by printing it i get a numerical value "0.0" instead of the string. What could have went wrong ?
Ex (python): print (str(shape.Cells("Prop.Kind"))) prints "0.0" instead of the string value.

Visio Guy

It's actually part of an enumeration:

Visio.VisSectionIndices.visSectionProp

In VB.NET and C# I usually have to cast it to a short.

When using Cells or CellsSRC, you want to follow them with .ResultIU, .Formula, etc.

So try one of these:

print (str(shape.Cells("Prop.Kind").Formula))
print (str(shape.Cells("Prop.Kind").ResultStr(Visio.VisUnitCodes.visNoCast)))


For articles, tips and free content, see the Visio Guy Website at http://www.visguy.com
Get my Visio Book! Using Microsoft Visio 2010