hexagon logo

Move Increment to Move Point Conversion Script?

Confused Is anybody familiar with a script that will scour your program and replace all the Move Increments with Move Points in the alignment context in which the moves reside? My team really doesn't like Move increments, but I really like the convenience while programing. It would be neat if there were a macro that converts them all with a click of a button.Confused
  • Option 3? Just thinking out loud, but could a Read Point be inserted after each incremental move? That would get the XYZ coordinates. Might have to do this online. (May have to insert into an XYZ location dimension) Still have to extract from the readpoint or dimension and then insert into Move Points using variables. You would then have to go back in and delete the extra features/ dimensions.
    Disclaimer: I know diddly squat about PC DMIS scripting but have done programming in ancient versions of BASIC.


  • I'm a little bummed to be as busy as I am, this seems like a fun thing to play with. I am kinda working on it in the back of my mind and I think I have cleared some to the hurdles.

    You can identify move commands in the program with the IsMove Property. Link to Help file: https://docs.hexagonmi.com/pcdmis/2021.1/en/helpcenter/mergedProjects/automationobjects/webframe.html#PCDLRN~Command~IsMove.html

    I haven't gotten as far as finding how to distinguish incremental moves from the other types of moves. May need to use gettext to find the command information to sort it out.

    It looks like selecting the features to be executed can be done with the SetExecutionBlock Method. Link to Help file: https://docs.hexagonmi.com/pcdmis/2021.1/en/helpcenter/mergedProjects/automationobjects/webframe.html#PCDLRN~PartProgram~SetExecutionBlock.html

    I think it can be executed with the EXECUTE Method (Odd how it is in all caps in the documentation, as if it's extra important): Link to Help file: https://docs.hexagonmi.com/pcdmis/2021.1/en/helpcenter/mergedProjects/automationobjects/webframe.html#PCDLRN~Command~EXECUTE.html

    That's as far as I have got. I haven't gotten as far as finding a way to insert a move point command on the desired line of the measuring routine or deleting the move increment command that is replacing it.

    Once it is all figured out, I'm not sure if such a script can be run from the Basic Script Editor built into PC-DMIS or if it would need to be run externally from something like an Excel script or a .bas file. The later versions of windows 10 now support executing .bas files just by double clicking on them, so that wouldn't be too hard to implement if needed.



    This could be done via the basic script editor, I prefer using excel/visual studio so its external of pc-dmis.

    I think your idea is solid for this - selecting the feature before and after the move/increment then executing the block then creating a move point and cleaning up. I wish I could be of some assistance, however my current role I don't have the ability to test with our pc-dmis seat.

    Another way of accomplishing this may be a programmable keypad using find/replace now that I'm thinking about it. You could program a lot of these keystrokes in one or two button presses. I'm not an expert with keypads, but some other people on here might be able to give more insight on that.
  • OK, here are some thoughts I've had on this, now that the programmable keypad has been mentioned (I didn't even think about it being of any use).

    It would be doable, but would take some serious attention to detail, and some really screwy arrow control to get it to work, would probably take me less than an hour to come up with it, but Pcdmis is running so I can't play with it.
  • Got a chance to test it, seemed to work OK, not great, but OK. Of course, you could ALWAYS just skip using the increment move and create a MOVE/POINT, type in (or copy/paste) the THEO values from the feature, then put in a math operation of what you want the increment move to do, you want to move -50 in X, then in the MOVE/POINT, put -50 after the x the value you put in there. Not exact, but will be pretty dang close.
  • Hi friends,

    here is a script to convert increment movement into movement points.
    there are maybe bugs so be carful.

    * it calculates the move point from the last hit
    * it uses some string parsing, so it only work with english, german
    * I couldn't read the Clearence Cube parameters, so it won't work with it
    * it wont work if program uses some fancy alignment changes, but not re-set the Clearence-Plane parameters
    * The routine will be saved before changes are made, so you can always go back one step, by close it without saving
    * at the moment it only works with "mm" but "inch" can easily be added
    * it will not work while a routine is being executed

    moveincrement.txt

    Sub pcDMIS_replace_MOVE_INCREMENT()
    ' --- Error ------------------------------------------------------------------------------
    On Error GoTo ErrorHandler
    
    
    ' --- Dim something ------------------------------------------------------------------------------
    Dim vpcDMIS_App, vpcDMIS_Part, vpcDMIS_Cmds, vpcDMIS_Cmd, vpcDMIS_CmdIn As Object
    
    Set vpcDMIS_App = CreateObject("PCDLRN.Application")
    Set vpcDMIS_Part = vpcDMIS_App.ActivePartProgram
    Set vpcDMIS_Cmds = vpcDMIS_Part.Commands
    Set vpcDMIS_Cmd = Nothing
    
    Dim iHitIndex As Integer
    Dim sPuffer1, sPuffer2 As String
    Dim N1 As Integer
    Dim vN_HITS As String
    Dim retval
    
    Dim vMOVE_INCREMENT_THEO_X As Double
    Dim vMOVE_INCREMENT_THEO_Y As Double
    Dim vMOVE_INCREMENT_THEO_Z As Double
    Dim vLAST_HIT_X, vRETRACT_HIT_X, vDESTI_POINT_X As Double
    Dim vLAST_HIT_Y, vRETRACT_HIT_Y, vDESTI_POINT_Y As Double
    Dim vLAST_HIT_Z, vRETRACT_HIT_Z, vDESTI_POINT_Z As Double
    Dim vLAST_HIT_I As Double
    Dim vLAST_HIT_J As Double
    Dim vLAST_HIT_K As Double
    
    Dim bMOVE_CLEARP As Boolean
    Dim vRETRACT_DISTANCE, vPROBE_R As Double
    Dim vWORK_PLANE, vPROBE_ID, vPROBE_TIPID As String
    Dim vCPLANE_DISTANCE As Double
    Dim bAUTO_CLEAR_PLANE As Boolean
    
    Dim iLoopIndex, iChanged As Integer
    
    
    ' --- save part ------------------------------------------------------------------------------------
    vpcDMIS_Part.Save
    
    
    ' --- search Commands ------------------------------------------------------------------------------
    iLoopIndex = 0
    iChanged = 0
    For Each vpcDMIS_Cmd In vpcDMIS_Cmds
    ' *** user info **************
    iLoopIndex = iLoopIndex + 1
    vpcDMIS_App.StatusBar = "Script: Cycling through commands. Current command: " & iLoopIndex
    
    
    ' *** find Probe infos **************
    If vpcDMIS_Cmd.Type = GET_PROBE_DATA Then
    vPROBE_ID = vpcDMIS_Cmd.GetText(FILE_NAME, 0)
    End If
    If vpcDMIS_Cmd.Type = SET_ACTIVE_TIP Then
    vPROBE_TIPID = vpcDMIS_Cmd.GetText(REF_ID, 0)
    vPROBE_R = vpcDMIS_Part.Probes.Item(vPROBE_ID).Tips.Item(vPRO BE_TIPID).diam / 2
    End If
    
    
    ' *** find RETRACT_DISTANCE infos **************
    If vpcDMIS_Cmd.Type = RETRACT_DISTANCE Then
    vRETRACT_DISTANCE = vpcDMIS_Cmd.GetText(DISTANCE, 0)
    End If
    
    
    ' *** find CLEARANCE_PLANE infos **************
    If vpcDMIS_Cmd.Type = CLEARANCE_PLANE Then
    vWORK_PLANE = vpcDMIS_Cmd.GetText(WORK_PLANE, 1)
    vCPLANE_DISTANCE = vpcDMIS_Cmd.GetText(DISTANCE, 1)
    
    sPuffer1 = vpcDMIS_Cmd.GetToggleString(AUTO_CLEAR_PLANE, 0)
    N1 = InStr(1, sPuffer1, "|")
    sPuffer2 = Trim(Mid(sPuffer1, N1 + 1, Len(sPuffer1)))
    sPuffer1 = vpcDMIS_Cmd.GetText(AUTO_CLEAR_PLANE, 0)
    If sPuffer2 = sPuffer1 Then
    bAUTO_CLEAR_PLANE = True
    Else
    bAUTO_CLEAR_PLANE = False
    End If
    End If
    
    
    ' *** find CLEARANCE_CUBE infos **************
    ' ...
    
    
    ' *** find MOVE_CLEARP infos **************
    If vpcDMIS_Cmd.Type = MOVE_CLEARP Then
    bMOVE_CLEARP = True
    End If
    
    
    ' *** find last Hit infos **************
    vN_HITS = vpcDMIS_Cmd.GetText(N_HITS, 0)
    If (vN_HITS <> "") Or (vpcDMIS_Cmd.Type = BASIC_HIT) Then
    ' get the theos of the Hit
    If vpcDMIS_Cmd.Type = BASIC_HIT Then
    iHitIndex = 0
    Else
    iHitIndex = CInt(vN_HITS)
    End If
    
    vLAST_HIT_X = vpcDMIS_Cmd.GetText(THEO_X, iHitIndex)
    vLAST_HIT_Y = vpcDMIS_Cmd.GetText(THEO_Y, iHitIndex)
    vLAST_HIT_Z = vpcDMIS_Cmd.GetText(THEO_Z, iHitIndex)
    vLAST_HIT_I = vpcDMIS_Cmd.GetText(THEO_I, iHitIndex)
    vLAST_HIT_J = vpcDMIS_Cmd.GetText(THEO_J, iHitIndex)
    vLAST_HIT_K = vpcDMIS_Cmd.GetText(THEO_K, iHitIndex)
    
    ' reset MOVE_CLEARP
    bMOVE_CLEARP = False
    End If
    
    
    ' *** find MOVE_INCREMENT infos **************
    If vpcDMIS_Cmd.Type = MOVE_INCREMENT Then
    ' read the theos of MOVE_INCREMENT
    vMOVE_INCREMENT_THEO_X = vpcDMIS_Cmd.GetText(THEO_X, 0)
    vMOVE_INCREMENT_THEO_Y = vpcDMIS_Cmd.GetText(THEO_Y, 0)
    vMOVE_INCREMENT_THEO_Z = vpcDMIS_Cmd.GetText(THEO_Z, 0)
    End If
    
    
    ' *** if all infos are presend, we only need increment movement commands **************
    If vpcDMIS_Cmd.Type <> MOVE_INCREMENT Then GoTo nextLoopIndex
    If vpcDMIS_Cmd.Marked = False Then GoTo nextLoopIndex '(cmd is marked, it will not be calculated)
    
    
    ' *** debug **************
    sPuffer1 = ""
    sPuffer1 = sPuffer1 & "vPROBE_ID: " & vPROBE_ID & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vPROBE_TIPID: " & vPROBE_TIPID & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vPROBE_R: " & vPROBE_R & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vRETRACT_DISTANCE: " & vRETRACT_DISTANCE & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vWORK_PLANE: " & vWORK_PLANE & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vCPLANE_DISTANCE: " & vCPLANE_DISTANCE & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vLAST_HIT_X: " & CStr(vLAST_HIT_X) & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vLAST_HIT_y: " & CStr(vLAST_HIT_Y) & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vLAST_HIT_Z: " & CStr(vLAST_HIT_Z) & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vLAST_HIT_I: " & CStr(vLAST_HIT_I) & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vLAST_HIT_J: " & CStr(vLAST_HIT_J) & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vLAST_HIT_K: " & CStr(vLAST_HIT_K) & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vMOVE_INCREMENT_THEO_X: " & CStr(vMOVE_INCREMENT_THEO_X) & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vMOVE_INCREMENT_THEO_Y: " & CStr(vMOVE_INCREMENT_THEO_Y) & Chr(13) & Chr(10)
    sPuffer1 = sPuffer1 & "vMOVE_INCREMENT_THEO_Z: " & CStr(vMOVE_INCREMENT_THEO_Z) & Chr(13) & Chr(10)
    'MsgBox sPuffer1
    
    
    ' *** calculate RETRACT point **************
    vRETRACT_HIT_X = (vLAST_HIT_I * (vRETRACT_DISTANCE + vPROBE_R)) + vLAST_HIT_X
    vRETRACT_HIT_Y = (vLAST_HIT_J * (vRETRACT_DISTANCE + vPROBE_R)) + vLAST_HIT_Y
    vRETRACT_HIT_Z = (vLAST_HIT_K * (vRETRACT_DISTANCE + vPROBE_R)) + vLAST_HIT_Z
    
    
    ' *** calculate MOVE_CLEARP **************
    If bMOVE_CLEARP Then
    Select Case vWORK_PLANE
    Case "XPLUS"
    vRETRACT_HIT_X = vCPLANE_DISTANCE
    
    Case "YPLUS"
    vRETRACT_HIT_Y = vCPLANE_DISTANCE
    
    Case "ZPLUS"
    vRETRACT_HIT_Z = vCPLANE_DISTANCE
    
    Case "XMINUS"
    vRETRACT_HIT_X = vCPLANE_DISTANCE
    
    Case "YMINUS"
    vRETRACT_HIT_Y = vCPLANE_DISTANCE
    
    Case "ZMINUS"
    vRETRACT_HIT_Z = vCPLANE_DISTANCE
    
    Case Else
    End Select
    End If
    
    
    ' *** calculate destination Point from MOVE_INCREMENT **************
    vDESTI_POINT_X = vRETRACT_HIT_X + vMOVE_INCREMENT_THEO_X
    vDESTI_POINT_Y = vRETRACT_HIT_Y + vMOVE_INCREMENT_THEO_Y
    vDESTI_POINT_Z = vRETRACT_HIT_Z + vMOVE_INCREMENT_THEO_Z
    
    
    ' *** Insert and delete Command **************
    ' Insert new MOVE_POINT Command
    retval = vpcDMIS_Cmds.InsertionPointAfter(vpcDMIS_Cmd)
    If retval Then
    Set vpcDMIS_CmdIn = vpcDMIS_Cmds.Add(MOVE_POINT, True)
    vpcDMIS_CmdIn.Marked = True
    retval = vpcDMIS_CmdIn.SetToggleString(1, NORM_RELEARN, 0)
    retval = vpcDMIS_CmdIn.PutText(CStr(vDESTI_POINT_X), THEO_X, 0)
    retval = vpcDMIS_CmdIn.PutText(CStr(vDESTI_POINT_Y), THEO_Y, 0)
    retval = vpcDMIS_CmdIn.PutText(CStr(vDESTI_POINT_Z), THEO_Z, 0)
    End If
    
    
    ' Delete MOVE_INCREMENT Command
    retval = vpcDMIS_Cmds.RemoveCommandRange(vpcDMIS_Cmd, vpcDMIS_Cmd)
    
    
    iChanged = iChanged + 1
    
    nextLoopIndex:
    Next vpcDMIS_Cmd
    
    
    ' --- end -----------------------------------------------------------------------------------------
    ErrorHandler:
    vpcDMIS_App.StatusBar = "Script: " & iLoopIndex & " searched commands | " & iChanged & " changed commands"
    
    
    ' --- free something ------------------------------------------------------------------------------
    Set vpcDMIS_Cmd = Nothing
    Set vpcDMIS_Cmds = Nothing
    Set vpcDMIS_Part = Nothing
    Set vpcDMIS_App = Nothing
    End Sub
    

    Attached Files


  • I don't understand the use of the bMOVE_CLEARP variable? You create it, tie it to a condition, then hard set the variable as false. You even devoted a whole block to doing so, with a confusing lone "end if" command. So, clearance planes appear to be completely ignored.

    What do you mean by fancy alignments?

    what happens if there is a moving point, flow control command, or avoidence move preceding the Move increment?

    I'm guessing to make this work with imperial one would just divide the vDESTI_POINT_X, vDESTI_POINT_Y, and vDESTI_POINT_Z variables by 25.4 before passing them into the new command?



    This is great work, I won't be able to test it until probably at least Sunday, As I will write a measurement routine whose sole purpose is to test this. This won't be difficult, it's just a matter of fitting it around production.


    I still don't understand why it must be so complicated? Couldn't one simply execute each command one after another, testing afterwards if the previous command was an incremental move, and if so, reading the probe position and inputting the coordinates into a move point? This would have the same problems with flow control but would solve the problems with the clearance cube, clearance planes, avoidance moves, duplicate moves, alignments, ect. Someone, please explain to me the error in my train of thought.
  • hi,

    I don't understand the use of the bMOVE_CLEARP variable?

    I think you missed something. This variable is only set to FALSE after a new "hit", ie only where it is relevant for this task.
    if it doesn't work for you in your test, I'll look at it again

    What do you mean by fancy alignments?

    If the "Clearance Planes Definition" is NOT set after a aligment change, Then it sticks to the previous alignment, the script doesn't know that and calculates the point incorrectly
    i have to trace the changes between every Aligments that not reset the "Clearance Planes Definition", I admit that it was too difficult for me

    what happens if there is a moving point, flow control command, or avoidence move preceding the Move increment?

    I didn't think of that, it will be calculated incorrectly, but it should be possible to patch that

    I'm guessing to make this work with imperial one would just divide the vDESTI_POINT_X, vDESTI_POINT_Y, and vDESTI_POINT_Z variables by 25.4 before passing them into the new command?

    maybe he already outputs the values correctly, otherwise just convert them, yes
    have not tested it in inches


    ->
    When I think about it then the script is very useless at the moment because it doesn't even consider two increment movements that follow one another
    sorry

  • ->
    When I think about it then the script is very useless at the moment because it doesn't even consider two increment movements that follow one another
    sorry


    Don't Apologize, you've created a substantive and tremendous start point. Correct me if I'm wrong, but you are the first person to post code on this thread.


    I still don't understand why it must be so complicated? Couldn't one simply execute each command one after another, testing afterwards if the previous command was an incremental move, and if so, reading the probe position and inputting the coordinates into a move point? This would have the same problems with flow control but would solve the problems with the clearance cube, clearance planes, avoidance moves, duplicate moves, alignments, ect. Someone, please explain to me the error in my train of thought.


    Please answer this.
  • there is a huge problem with "Clearance Cube", because i cant think of solution to extract that infos.
    if you use this, i think it will never work with this.

    but i patch moving point, flow control command, or avoidence move also inch . the next week
  • I don't think the problem with the clearance cubes is as huge as you think. I have never used them in PC-DMIS, and i have never met another programmer in real life that used them in PC-DMIS... Including the hexagon instructors, They know how to do it, they'll teach it, they just don't use it programming unless a customer specifically demands it. If you hadn't mentioned the problem with clearance cubes, it probably would have been a year or two before somebody stumbled across the bug.

    Third time,
    I still don't understand why it must be so complicated? Couldn't one simply execute each command one after another, testing afterwards if the previous command was an incremental move, and if so, reading the probe position and inputting the coordinates into a move point? This would have the same problems with flow control but would solve the problems with the clearance cube, clearance planes, avoidance moves, duplicate moves, alignments, ect. Someone, please explain to me the error in my train of thought.