How to know a variable or dimension in Variable Table is read-only ?

Siemens Creator Siemens Creator
Siemens Creator

How to know a variable or dimension in Variable Table is read-only using SE API in ST5? 

 

Thanks

 

3 REPLIES

AFAIK, there is no API to get this property directly, but...

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

AFAIK, there is no API to get this property directly, but you might try to change a variable and then check, if ti was really changed. Read-only variables/dimension do NOT throw an exception, but they also do not change their value.

'----------------------------------------------------------------------
' ASM/PAR/PSM: Check if a variable is read-only
'----------------------------------------------------------------------
Dim strVariableName As String = "Flat_Pattern_Model_CutSizeX"
Dim objDoc As SolidEdgeFramework.SolidEdgeDocument = objApp.ActiveDocument
Dim objVars As SolidEdgeFramework.Variables = objDoc.Variables
Dim bReadOnly = False
Try
  Dim objVar As Object = objVars.Translate(strVariableName)
  Dim val As Double = objVar.GetType().InvokeMember("Value", Reflection.BindingFlags.GetProperty, Nothing, objVar, Nothing)
  objVar.GetType().InvokeMember("Value", Reflection.BindingFlags.SetProperty, Nothing, objVar, New Object() {val + 0.001})
  Dim val2 As Double = objVar.GetType().InvokeMember("Value", Reflection.BindingFlags.GetProperty, Nothing, objVar, Nothing)
  bReadOnly = (val = val2)
  If Not bReadOnly Then
    ' Restore the original value
    objVar.GetType().InvokeMember("Value", Reflection.BindingFlags.SetProperty, Nothing, objVar, New Object() {val})
  End If
Catch ex As Exception
  Console.WriteLine("EXC: " & ex.Message)
  bReadOnly = True
End Try

 

Re: AFAIK, there is no API to get this property directly, but...

Siemens Creator Siemens Creator
Siemens Creator
When value is changed for non-read-only properties and reverting back to original values , do I need to worry about any changes may affect like, when dimension is changed , will Relation3D get affected if present ? If lots of formulas are dependent on this property, many other parameters will change and SE will do lots of re-computation !

Any thoughts on this concern ?

Re: AFAIK, there is no API to get this property directly, but...

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom
Yes, you are right. If you need to check all variables, then it will take a long time, but if it is needed only occasionally, then this might be a work-around.
Using DelayCompute does not make any sense here as it would accelerate the execution time, but it would also give you the wrong results, as the variable does not get updated immediately!!
If you really need this, file an incident report requesting a ReadOnly property on variable and Dimension objects.