hexagon logo

Script help needed - export point data to txt file

I have a program that measures 700+ points on an airfoil surface. I'm looking for an easy way to export the nominal and measured values into a txt file as feature name, X nom, Y nom, Z nom, X meas, Y meas, Z meas, X dev, Y dev, Z dev. I'm currently programming to put the values into an array and write to a file after every point measurement.

It would obviously be easier to have a script that would look for all feature names in a certain format, i.e. PNT_1, PNT_2, etc, write the data to a file, then look for the next feature. I wasn't planning on dimensioning any of the points but will if I have to. If someone can point me in the right direction I would greatly appreciate it.
Parents
  • Ok, this is a deadlisting I just made - with deadlisting I mean that I have typed without syntax check and without a compiler to test it.
    In other words, coded in Notepad @ home = run it at your own risk.

    ' vpt.se in 2013
    
    Sub Main
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    Dim tX, tY, tZ, mX, mY, mZ As String
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim iCnt as integer
    
    Open PCDPartProgram.Path & "POINTDATA.TXT" For Append As #1
    For iCnt = 1 To PCDCommands.Count
    Set PCDCommand = PCDCommands.Item(iCnt)
    
    If Left(PCDCommand.ID, 3) = "PNT" Then
    
      tX = PCDCommand.GetText(THEO_X, 0)
      tY = PCDCommand.GetText(THEO_Y, 0)
      tZ = PCDCommand.GetText(THEO_Z, 0)
      
      mX = PCDCommand.GetText(MEAS_X, 0)
      mY = PCDCommand.GetText(MEAS_Y, 0)
      mZ = PCDCommand.GetText(MEAS_Z, 0)
      
      Write #1, PCDCommand.ID & " " & tX & " " & tY & " " & tZ & " " & mX & " " & mY & " " & mZ
    
    End If
    
    Next iCnt
    
    Close #1
    Set PCDCommands = Nothing
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub


    It will look for features where the feature name begins with PNT. If a feature is found, the ID and theo X, Y, Z and meas X, Y and Z will be saved to a file called POINTDATA.TXT in the same folder as the current partprogram.
    The file is appended everytime the script is run, which means it will add to the textfile. If you want the deviation, you'll have to add that calculation to the script.

    Hopefully it will work, if it doesn't it will give you a nice foundation to build on.
Reply
  • Ok, this is a deadlisting I just made - with deadlisting I mean that I have typed without syntax check and without a compiler to test it.
    In other words, coded in Notepad @ home = run it at your own risk.

    ' vpt.se in 2013
    
    Sub Main
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    Dim tX, tY, tZ, mX, mY, mZ As String
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim iCnt as integer
    
    Open PCDPartProgram.Path & "POINTDATA.TXT" For Append As #1
    For iCnt = 1 To PCDCommands.Count
    Set PCDCommand = PCDCommands.Item(iCnt)
    
    If Left(PCDCommand.ID, 3) = "PNT" Then
    
      tX = PCDCommand.GetText(THEO_X, 0)
      tY = PCDCommand.GetText(THEO_Y, 0)
      tZ = PCDCommand.GetText(THEO_Z, 0)
      
      mX = PCDCommand.GetText(MEAS_X, 0)
      mY = PCDCommand.GetText(MEAS_Y, 0)
      mZ = PCDCommand.GetText(MEAS_Z, 0)
      
      Write #1, PCDCommand.ID & " " & tX & " " & tY & " " & tZ & " " & mX & " " & mY & " " & mZ
    
    End If
    
    Next iCnt
    
    Close #1
    Set PCDCommands = Nothing
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub


    It will look for features where the feature name begins with PNT. If a feature is found, the ID and theo X, Y, Z and meas X, Y and Z will be saved to a file called POINTDATA.TXT in the same folder as the current partprogram.
    The file is appended everytime the script is run, which means it will add to the textfile. If you want the deviation, you'll have to add that calculation to the script.

    Hopefully it will work, if it doesn't it will give you a nice foundation to build on.
Children
No Data