hexagon logo

Being dimension specific with VB script

Someone was checking thickness of a part with PCDMIS using distance. The part program had over 150 dimensions. Wanting to know the minimum distance he asked me if it could be coded instead of sifting through a 150+ dimension report. Knowing that distance is the only type of dimension in the program I wrote him this .bas

Sub Main()

Dim pcdmis As Object
Dim Part As Object
Dim Cmds As Object
Dim Cmd As Object
Dim DimCmd As Object

Set pcdmis = CreateObject("pcdlrn.application")
Set Part = pcdmis.ActivePartProgram
Set Cmds = Part.Commands

Dim dblMeasurment As Double
Dim dblMinimum As Double
Dim intCounter As Integer

intCounter = 0


For Each Cmd In Cmds

    If Cmd.IsDimension Then
    Set DimCmd = Cmd.DimensionCommand
    dblMeasurment = DimCmd.Measured
    
        If intCounter = 0 Or dblMeasurment < dblMinimum Then
        dblMinimum = dblMeasurment
        End If
        
    intCounter = intCounter + 1
    End If

Next Cmd

Dim strTheFile As String
strTheFile = "C:\Minimum.txt"
Open strTheFile For Output As #1
Write #1, dblMinimum
Close #1

End Sub


My question is how do I check what type of dimension I am looking at? If there are any other dimensions in the program this will not ignore them and they will be used in the calculation of finding the minimum. I want to be able to go through and only use distance data. For now this works fine for him but I think it would be nice to be able to be specific as to the exact type of dimension. Right now because he has 3.2063 (does not support SetVariableValue) he reads it in from the text file with PCDMIS to set a variable. The variable has to be reported in a comment of some kind (either report or operator). If it is assigned to a generic feature and dimensioned that dimension gets evaluated by the .bas and returns 0 because it has not been set at the time the script runs. Does anyone know how to evaluate dimensions to get their specific type (ie location, true position, concentricity, flatness etc)?

Craig
Parents Reply Children
No Data