hexagon logo

Changing nominals of certain features within an existing routine automatically...

Hello,

I had made a similar post on the common CMM forums but figured it might be better to get opinions from the scripting/coding side of things. Let me start of by giving an example. I have a very long existing inspection routine... The production department updates a handful... maybe 20% of the existing features within the routine to have new theoretical values (no other changes...just nominal values). The CAD for these nominal changes are not available. A .des file is given to me from production containing all of the features within the program at the most updated level (not all features need to change). Next, i would export the .des file from the "current routine" and compare both .des files, new and current, to see which features need to be changed. As of right now, the current method is to go into the current routine, do a manual search for each feature that needs a change... and then manually typing in each value. I'm looking for a way to make this automatic. I have considered a few options but I am not too experienced and have found myself at a dead end. One method would be to create a .txt file of the feature names that need to be changed as well as their respective nominals and use some sort of file i/o to create variables / arrays. Maybe use the GETTEXT command or GETCOMMAND functions... or the EQUAL(,) command to compare arrays and see which differ and somehow replace the features that need it? Or if its possible to change all the theo values from a .txt file of every feature (most features would remain exactly the same) that would work too. Another idea would be to change the necessary nominals in "current (exported)" .des file by using some sort of text editor (to make it automatic)... and then re-import the .des file back into the routine with the respective changes.... Maybe my thinking is way off or over thought... but does anyone have an idea about how this might be accomplished.
  • It can be done. For example:

    ' Replaces a [b]coordinate value[/b] in [b]DCC/measured features[/b]
    ' with a [b]variable[/b]. The example below replaces the
    ' theoretical and target Z-coordinate with the contents
    ' of RChar (currently "W").
    ' Custommade for user 233229920 @ PC-DMIS User Forum
    '
    ' Ex. <10,20,30>, <0,0,1>
    ' (X,Y,Z), (I,J,K) will become
    ' <10,20,W>, <0,0,1>
    '
    ' vpt.se 2011
    
    Sub Main
    Dim PCDApp, PCDPartPrograms, PCDPartProgram, PCDCommands, PCDCommand
    
    'Initialization
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    Dim iCnt As Integer
    Dim RChar As String
    
    RChar = "W"
    
    For iCnt = 1 To PCDCommands.Count
    Set PCDCommand = PCDCommands.Item(iCnt)
    
    If (PCDCommand.IsDCCFeature) or (PCDCommand.IsMeasuredFeature) Then
      retval = PCDCommand.SetExpression (RChar, THEO_Z, 0)
      retval = PCDCommand.SetExpression (RChar, TARG_Z, 0)
    End If
    PCDPartProgram.Refresh
    Next iCnt
    
    'Cleanup
    Set PCDCommands = Nothing
    Set PCDPartProgram = Nothing
    Set PCDPartPrograms = Nothing
    Set PCDApp = Nothing
    End Sub


    This does only replace the Z-value with a "W" in all DCC or measured/learned features. But it can be a springboard
    to use for your custom application. You would need to know the names of the features to change (maybe parse
    the .des file for the names, or simply update all features with whatever values exist in the .des file.