hexagon logo

Accessing a feature from VB

Got another one that stumped me. What's the proper way to get at feature info in a PC-DMIS part program from VB?

To explain, I have a hole named H1. I want to grab X,Y,Z,D values for this hole in a script run at the end of the part program.

I know at least 20 ways that do not work! Blush
Parents
  • Untested:

    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim cnt as Integer
    Dim Tx, Ty, Tz, Td, Mx, My, Mz, Md as String
    
    for cnt = 1 to PCDCommands.Count
    Set PCDCommand = PCDCommands.Item(cnt)
    
    if PCDCommand.ID = "H1" then
      Tx = PCDCommand.GetText(THEO_X, 0)
      Ty = PCDCommand.GetText(THEO_Y, 0)
      Tz = PCDCommand.GetText(THEO_Z, 0)
      Td = PCDCommand.GetText(THEO_DIAM, 0)
      Mx = PCDCommand.GetText(MEAS_X, 0)
      My = PCDCommand.GetText(MEAS_Y, 0)
      Mz = PCDCommand.GetText(MEAS_Z, 0)
      Md = PCDCommand.GetText(MEAS_DIAM, 0)
    End If
    
    Next cnt
    
    End Sub


    The values should be available in T n and M n variables.
Reply
  • Untested:

    Sub Main()
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim cnt as Integer
    Dim Tx, Ty, Tz, Td, Mx, My, Mz, Md as String
    
    for cnt = 1 to PCDCommands.Count
    Set PCDCommand = PCDCommands.Item(cnt)
    
    if PCDCommand.ID = "H1" then
      Tx = PCDCommand.GetText(THEO_X, 0)
      Ty = PCDCommand.GetText(THEO_Y, 0)
      Tz = PCDCommand.GetText(THEO_Z, 0)
      Td = PCDCommand.GetText(THEO_DIAM, 0)
      Mx = PCDCommand.GetText(MEAS_X, 0)
      My = PCDCommand.GetText(MEAS_Y, 0)
      Mz = PCDCommand.GetText(MEAS_Z, 0)
      Md = PCDCommand.GetText(MEAS_DIAM, 0)
    End If
    
    Next cnt
    
    End Sub


    The values should be available in T n and M n variables.
Children
No Data