Showing results for 
Search instead for 
Did you mean: 

Extract informations from variable table using API

Valued Contributor
Valued Contributor

I'm able to extract by code all variable and driving dimensions using this:

myvartable = doc.Variables.Query("*",....)


Cycling into "myvartable" collection with a foreach, i discovered that item object's are of "Variable" or "Dimension" type depending on how the variable has been created.


The problem is that Variable and Dimension object does NOT appear to have an uniform set of API to extract informations visible on the variable table.


Variable has .GetValue(), Dimension only .Value

Variable has .GetComment(), Dimension DONT have .GetComment()

Fortunately, both have .Formula()


The question is... how to extract COMMENTS informations from variable table via API ?

I can read comments for user defined variables, but not dimension variables, despite into variable table user can specify a comment for both.


The .Value contains the variable (or dimension) value in database units (meter, radiants,...)

Does exist any way to extract a STRING representing the value, with the user defined unit of measure as you can see into variable table ?


Also, .GetVariable(str) always produces an empty string!


I'm under ST4, if this can be of any concern.



Paolo Marani


Posted by: Paolo Marani
Post date: 10/10/2012 10:01:08 AM


Extract informations from variable table using API

Valued Contributor
Valued Contributor

First, it's good practice to have a driving Variable for each Dimension. You should not edit Dimensions directly. Make a Variable for each Dimension you want to work with and then use that Variable name as the formula for the Dimension.


Dim    V392          28.000    Formula    MyVariable
Var    MyVariable    28.000


Now just work with the Variable.


Secondly, this also helps when you are dealing with "Nominal" vs "Actual" values like pipe sizes. You can have the Dimension formula be something like


Dim    V392    28.063    Formula    MyVariable + .0625
(or some other more complex formula) and then just work with nominal sizes.


Posted by: Terry Tyson
Post date: 10/11/2012 7:43:23 AM