none
How to fully extrapolate values in a parameterizedProperty RRS feed

  • Question

  • Hey all,

    I'm working on scripting the creation of some Visio documents in Powershell and having a pretty difficult time.  (yeah, should probably just start using pure VBS but never got around to learning VBS).  At any rate.  Here's my conundrum.  

    I need a way to get all the information from a ParameterizedProperty dumped so I can see what's inside.  I've attempted get-members and get-property, etc to no avail. 

    The situation:

    When I create a shape on the page, sometimes I want to find out information about that object later, without storing it in a gigantic array (which is finicky at best).  So I dug and dug for a while and started running into a MemberType called the ParameterizedProptery.  This seems to be some kind of sub hash table value of objects in Visio.  The problem is I can't find a way for it to reveal its secrets without first knowing what the keys are.  Specifically below:

    $shape = $page.DrawRectangle(1, 1, 2, 2)
    
    $shape | get-member
    
    ... removed some stuff ... 
    
    AreaIU                          ParameterizedProperty double AreaIU (bool) {get}
    CellExists                      ParameterizedProperty short CellExists (string, short) {get}
    CellExistsU                     ParameterizedProperty short CellExistsU (string, short) {get}
    Cells                           ParameterizedProperty IVCell Cells (string) {get}
    CellsRowIndex                   ParameterizedProperty short CellsRowIndex (string) {get}
    CellsRowIndexU                  ParameterizedProperty short CellsRowIndexU (string) {get}
    CellsSRC                        ParameterizedProperty IVCell CellsSRC (short, short, short) {get}
    CellsSRCExists                  ParameterizedProperty short CellsSRCExists (short, short, short, short) {get}
    CellsU                          ParameterizedProperty IVCell CellsU (string) {get}
    DistanceFrom                    ParameterizedProperty double DistanceFrom (IVShape, short) {get}
    DistanceFromPoint               ParameterizedProperty double DistanceFromPoint (double, double, short, Variant, Vari...
    GeomExIf                        ParameterizedProperty IUnknown GeomExIf (short, double) {get}
    Layer                           ParameterizedProperty IVLayer Layer (short) {get}
    LengthIU                        ParameterizedProperty double LengthIU (bool) {get}
    RowCount                        ParameterizedProperty short RowCount (short) {get}
    RowExists                       ParameterizedProperty short RowExists (short, short, short) {get}
    RowsCellCount                   ParameterizedProperty short RowsCellCount (short, short) {get}
    RowType                         ParameterizedProperty short RowType (short, short) {get} {set}
    Section                         ParameterizedProperty IVSection Section (short) {get}
    SectionExists                   ParameterizedProperty short SectionExists (short, short) {get}
    SpatialNeighbors                ParameterizedProperty IVSelection SpatialNeighbors (short, double, short, Variant) {...
    SpatialRelation                 ParameterizedProperty short SpatialRelation (IVShape, double, short) {get}
    SpatialSearch                   ParameterizedProperty IVSelection SpatialSearch (double, double, short, double, shor...
    UniqueID                        ParameterizedProperty string UniqueID (short) {get}


    So I tried a few things to get data out after looking up all sorts of other people's information and eventually started recording macros to see what Visio is doing behind the scenes.  Using the "CellsU" property I am able to determine the "Width", "Height" and the X, Y coordinates of the center of the object.  This is all very math dependent to figure out what the actual dimensions are, though. Yes, I can code "Center_X - 1/2(Width) = Left coordinate", however I feel like that isn't necessary.  That data should be somewhere.  I should be able to dump all keys and values, however it's not an actual hash table and none of the methods seem to support doing so.  I've tried using wildcards and other trickery, but I'm at a loss now.  

    It would be WORLDS faster to know how to dump all information in ParameterizedProperty but I see nothing in MS's documentation.

    • Edited by atomicsnowman Thursday, March 23, 2017 12:37 PM Edited for clarity.
    • Moved by Bill_Stewart Friday, April 28, 2017 8:17 PM Move to more appropriate forum
    Wednesday, March 22, 2017 8:21 PM

All replies

  • It's not that I can't do the mathing.  It's just that it's a bloody mess.

    > [double]$shape.cells("PinX").ResultIU - ([double]$shape.cells("Width").resultIU/2)
    1
    


    Wednesday, March 22, 2017 8:27 PM
  • The foundation of programming is math.  If you have issues dividing by two then you are in trouble.

    I also think you need to learn how to use the object model.

    Your example doesn't tell us what you are trying to accomplish.  Are you asking how to define a formula in a Visio drawing?

    I recommend posting in the Visio developers forum for complex issues.

    You don't need [double]

    $shape.cells("PinX").ResultIU - ($shape.cells("Width").resultIU/2)

    It will be automatically converted due to the use of division.

    I suggest defining formulas on the drawing where needed.


    \_(ツ)_/

    Wednesday, March 22, 2017 10:34 PM
  • Has nothing to do with math.  I can math all over the place.  I'm just describing how I found the problem and i don't believe that it's specific to Visio.  Powershell is usually relatively good at turning strings into floats but I'm just in the habit of enforcing my casting so that in if anyone examines my code they'll know exactly what's happening.

    My question is thus: Is there any way to get all possible keys/values out of the ParameterizedProperty without knowing the keys.  MSDN lists the methods and properties in the following link.

    https://msdn.microsoft.com/en-us/library/system.management.automation.psparameterizedproperty_properties%28v=vs.85%29.aspx?f=255&MSPPError=-2147217396

    However, this doesn't give me a way to dump all the data.  To see what is stored away in that ParameterizedProperty.  Anything could be in there but I don't know how to find it.

    Thursday, March 23, 2017 1:13 AM
  • Get-Member -MemberType ParmaterizedProperty

    That is the question you should have asked.  I don't know why you asked about math.


    \_(ツ)_/

    Thursday, March 23, 2017 1:41 AM