hexagon logo

2020 R2 Visual Basic Script - Help...!!

Morning everyone,


I’m trying to get it to populate an excel spreadsheet automatically after the part program is ran.

How do get to output the worst true position deviation from nominal from a set of say 10 drilled holes in one fcf.. To get the first one I got worked out, which works for single drilled hole true position fcf.

Here is my example code for one:-

Dim Cmd As Object
Dim DmisCommand As Object
xlFile = "I Put My File Name Here.xlsx"
xlSheetName = "Sheet1"

Set xlApp = CreateObject("Excel.Application")
Set xlWorkbooks = xlApp.Workbooks
Set xlWorkbook = xlWorkbooks.Open(Filename:=xlFile)
Set xlSheet = xlWorkbook.Worksheets(xlSheetName)

Set PCDApp = CreateObject ("PCDLRN.Application")
Set PCDPart = PCDApp.ActivePartProgram
Set Cmds = PCDPart.Commands

For Each DmisCommand In Cmds
If (DmisCommand.Type = ISO_TOLERANCE_COMMAND) Or (DmisCommand.Type = ASME_TOLERANCE_COMMAND) Then
If DmisCommand.ID() = "FCFLOC1" Then 'This is the Multiple Hole Pos Example
‘This Below Just Outputs the first hole not the worst
xlSheet.Range("D1").Value = DmisCommand.GetTextEx(DIM_DEVIATION, 1, "SEG=1")
End If
End If
Next DmisCommand
xlApp.Visible = True

Question is what code is used to find the worst of the bunch?

Kind Regards & Thank you in advance...

Simon




​​
Parents
  • I believe you'll want to iterate over your total number of features with a while or for loop. The second argument of the GETTEXTEX command should be for the feature, so GETTEXTEX(DIM_DEVIATION, 2, "SEG=1") should report the deviation of the second feature. Loop over all features and extract the worst.

Reply
  • I believe you'll want to iterate over your total number of features with a while or for loop. The second argument of the GETTEXTEX command should be for the feature, so GETTEXTEX(DIM_DEVIATION, 2, "SEG=1") should report the deviation of the second feature. Loop over all features and extract the worst.

Children
No Data