Is there a way to access a PC-DMIS array variable from PC-DMIS Basic?

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Is there a way to access a PC-DMIS array variable from PC-DMIS Basic?

    Is there a way to access a PC-DMIS array variable from PC-DMIS Basic? The Help for GetVariableValue() doesn't mention arrays and indices.
    AndersI
    SW support - Hexagon Metrology Nordic AB

  • #2
    Is that helps ? (from PCDBASIC 3.6)

    Variable.GetArrayUpperBound
    Syntax
    Return Value=expression.GetArrayUpperBound
    Return Value: This returns the upper bound if the variable is an array. Otherwise it
    returns zero.
    expression: required expression for object type Variable.


    Variable.GetArrayLowerBound
    Syntax
    Return Value=expression.GetArrayLowerBound
    Return Value: This returns the lower bound if the variable is an array. Otherwise it
    returns zero.
    expression: required expression for object type Variable.

    Variable.GetArrayIndexValue
    Syntax
    Return Value=expression.GetArrayIndexValue
    Return Value: This returns the array variable at the specified index position.
    expression: required expression for object type Variable.

    Variable.SetArrayIndexValue
    Syntax
    Return Value=expression.SetArrayIndexValue (Index, Variable)
    Return Value: This sets the array variable at the specified index position. Type
    Boolean.
    expression: required expression for object type Variable.
    Index: Long value specifying the index

    Comment


    • #3
      Yes, found them in the Type Library, but still not sure how to get at them. Experimenting...

      OK, this seems to work! But GetArrayUpperBound returns the number of elements + 1, and it took a while to find the .PointValue which is necessary to get at the parts (XYZ) of the indexed value.

      Thanks!

      Code:
      Sub Main
        Dim App As Object 
        Set App = CreateObject ("PCDLRN.Application")
        Dim Part As Object
        Set Part = App.ActivePartProgram
        Dim Var As Object
        Dim i_var As Object
      
        Set Var = Part.GetVariableValue ("PT")
        MsgBox Var.GetArrayUpperBound
        Set i_var = var.getarrayindexvalue(2).PointValue
        MsgBox i_var.x
      
      End Sub
      AndersI
      SW support - Hexagon Metrology Nordic AB

      Comment


      • #4
        Originally posted by AndersI View Post

        GetArrayUpperBound returns the number of elements + 1
        You should try something like Option Base 1 at the start.

        Comment


        • AndersI
          AndersI commented
          Editing a comment
          Doesn't affect anything. Probably only valid for BASIC arrays, not PC-DMIS ones.

          But maybe "Upper Bound" means "the first index that is not addressable", instead of the expected "the last index that is addressable" (or GetArrayLowerBound + <number of elements>)

          Anyway, it isn't important as long as it's consistent.
          Last edited by AndersI; 04-10-2018, 10:12 AM.

      • #5
        Code:
        Sub Main()
        
          Dim App As PCDLRN.Application
          Set App = CreateObject("PCDLRN.Application")
          Dim Part As PCDLRN.PartProgram
          Set Part = App.ActivePartProgram
          Dim Var As PCDLRN.Variable
          Dim i_var As VariableArray
        
          Set Var = Part.GetVariableValue("PT")
          MsgBox Var.VariableType
        
        End Sub
        Output = 5.
        5 = VARIABLE_TYPE_ARRAY (according to the PCDLRN Object Library).

        What gives? It recognizes it as an array but can't manipulate it as one?
        PcDmis 2015.1 SP10 CAD++
        Global 7-10-7 DC800S

        Comment


        • AndersI
          AndersI commented
          Editing a comment
          Every [to me] imaginable way gave "Error: Type mismatch". Doesn't mean there isn't any way to do it, but I couldn't find out how.

      Related Topics

      Collapse

      Working...
      X