hexagon logo

Perimeter Scan

Hello all,
I'm trying to extract the xyz values from a perimeter scan edge hit.
I'm having trouble navigating down the object hierarchy.
I see a PCDSCANHITTYPE and PCD_EDGEHIT, but
I don't know enough to get the xyz values into variables.

Any help would be appreciated.

Thanks in advance.
  • Hi.


    Edge-point variant in PCDMIS:
    PNT1       =FEAT/CONTACT/EDGE POINT/DEFAULT,CARTESIAN
                THEO/<0,-50,97.137>,<0,-0.7071068,0.7071068>,<0,-0.7071068,0.7071068>
                ACTL/<0,-50,97.137>,<-1,0,0>,<0,-0.7071068,0.7071068>
                TARG/<0,-50,97.137>,<0,-0.7071068,0.7071068>,<0,-0.7071068,0.7071068>
                MEASURE ORDER=SURFACE
                SHOW FEATURE PARAMETERS=NO
                SHOW CONTACT PARAMETERS=NO
    PNT2       =FEAT/POINT,CARTESIAN,NO
                THEO/<0,-50,97.137>,<0,-0.7071068,0.7071068>
                ACTL/<0,0,0>,<0,0,1>
                CONSTR/POINT,CAST,PNT1.XYZ
    


    Perimeter scan variant (with N hits) in PCDMIS:
    SCN1       =FEAT/SCAN,SECTIONSCAN,NUMBER OF HITS=14,SHOW HITS=NO,SHOWALLPARAMS=NO
                MEAS/SCAN
                  BASICSCAN/LINE,NUMBER OF HITS=14,SHOW HITS=NO,SHOWALLPARAMS=NO
                  ENDSCAN
                ENDMEAS/
    SCAN_PNT1       =FEAT/POINT,CARTESIAN,NO
                THEO/<0,0,0>,<0,0,1>
                ACTL/<0,0,0>,<0,0,1>
                CONSTR/POINT,CAST,SCN1.HIT[1].XYZ​
    SCAN_PNT2       =FEAT/POINT,CARTESIAN,NO
                THEO/<0,0,0>,<0,0,1>
                ACTL/<0,0,0>,<0,0,1>
                CONSTR/POINT,CAST,SCN1.HIT[2].XYZ​​
    



    do you want to extract the data in a script?
    Edge-point variant in SCRIPT:
      [...]
      if DmisCommand.Type = CONTACT_EDGE_POINT_FEATURE then
        retval = DmisCommand.GetText (MEAS_X, 0)  
        retval = DmisCommand.GetText (MEAS_Y, 0)
        retval = DmisCommand.GetText (MEAS_Z, 0)
      end if
      [...]
    


    Perimeter scan variant (with N hits) in SCRIPT:
      [...]
      if DmisCommand.Type = BASIC_SCAN_OBJECT then
        For iCount = 1 To DmisCommand.GetText (N_HITS, 0)
          retval = DmisCommand.GetText(MEAS_X, iCount)  
          retval = DmisCommand.GetText(MEAS_Y, iCount)
          retval = DmisCommand.GetText(MEAS_Z, iCount)
        Next iCount
      end if
      [...]
    
    ​​​
  • WOW!!
    Thanks Henniger123.
    You've pulled me out of the quick (script) -sand again!
    I'll give the script option a try.
  • you must of course loop through all the commands (for each DmisCommand in DmisCommands ...)
    and replace the retval with dMeasX, dMeasY, dMeasZ as Double
  • Hello Henniger123,
    I did something like that.
    This was just a test to output the xyz's to a file.

    Open "H:\sc.bas" FOR OUTPUT AS #1

    For each Cmd in Cmds

    IF Cmd.Type = BASIC_SCAN_OBJECT then
    For iCount = 1 To Cmd.GetText (N_HITS, 0)
    xm = Cmd.GetText(MEAS_X, iCount)
    ym = Cmd.GetText(MEAS_Y, iCount)
    zm = Cmd.GetText(MEAS_Z, iCount)

    Cmd.Redraw
    PRINT #1, "MOVE/POINT,NORMAL,<",xm,",",ym,",",zm,">"

    Next iCount
    END IF

    Next Cmd

    CLOSE #1

    I would like to be able to add those move points to the end of the
    program with something like

    Set Cmd = Cmds.Add(MOVE_POINT, TRUE)
    Cmd.SetToggleString 1, NORM_RELEARN, 0
    Cmd.PutText Xm, THEO_X, 0
    Cmd.PutText Ym, THEO_Y, 0
    Cmd.PutText Zm, THEO_Z, 0

    but I can't seem to squeeze that into the loop correctly.
    Maybe cause code is pointing to another Cmd?

    That would be the icing on the cake to add that.
    Thanks again.​
  • Hello,

    why do you want to insert movement points based on touch points.. doesn't that always lead to a collision?​
    what exactly do you want to achieve?


    ...
    this code only works if there is only one scan in the measurement program (only the points from the last scan are recorded).
    the measurement points are stored in an array​

    and since the movement points are aimed at the contact points, this definitely leads to a collision...
    I hope you know what you're doing

    Sub Main_230709()
    ' Dim something ---------------------------
      Dim App As Object
      Set App = CreateObject("PCDLRN.Application")
      Dim Part As Object
      Set Part = App.ActivePartProgram
      Dim Cmds As Object
      Set Cmds = Part.Commands
      Dim Cmd As Object
      Set Cmd = Nothing
     
      Dim sPath As String
      Dim iPoints As Integer
      Dim mx(), my(), mz() As Double
     
     
    ' File
      sPath = "C:\Test.txt"
      Open sPath For Output As #1
     
    ' search
      For Each Cmd In Cmds
        If Cmd.Type = BASIC_SCAN_OBJECT Then
          iPoints = Cmd.GetText(N_HITS, 0)
          ReDim mx(iPoints)
          ReDim my(iPoints)
          ReDim mz(iPoints)
          
          For iCount = 1 To iPoints
            mx(iCount) = Cmd.GetText(MEAS_X, iCount)
            my(iCount) = Cmd.GetText(MEAS_Y, iCount)
            mz(iCount) = Cmd.GetText(MEAS_Z, iCount)
            
            'Print #1, "MOVE/POINT,NORMAL,<", xm, ",", ym, ",", zm, ">"
          Next iCount
        End If
      Next Cmd
     
      Close #1
     
    ' add
      retVal = Cmds.InsertionPointAfter(Cmds.LastCommand)
      For iCount = 1 To iPoints
        Set Cmd = Cmds.Add(MOVE_POINT, True)
        Cmd.Marked = True
        retVal = Cmd.SetToggleString(1, NORM_RELEARN, 0)
        retVal = Cmd.PutText(CStr(mx(iCount)), THEO_X, 0)
        retVal = Cmd.PutText(CStr(my(iCount)), THEO_Y, 0)
        retVal = Cmd.PutText(CStr(mz(iCount)), THEO_Z, 0)
      Next iCount
      Part.RefreshPart
     
    End Sub​
    
  • Thanks Henniger123,
    Once the move points are added to the end of the program,
    The scan points would be deleted.
    The move/points would be used for a proprietary scribing device
    attached to the PH10.
    Hope that makes sense..
    I'll give the code you provided a try.
    Thanks again.