hexagon logo

tolerances


I have a small code in vb6 that changes the tolerances of the program but it is very time consuming. how can I write the code to be faster?

Attached Files
Parents
  • Hi,
    you can try this: (but i doubt that will be any faster)
    And no, if you want to change a Command you must circle them in "For-Each"

    Sub test()
    Dim PCDApp, PCDPartProgram, PCDCommands, cmd As Object
    Dim VK, VT, Ptol, Mtol, retval, Ntext
    
    
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartProgram = PCDApp.ActivePartProgram
    Set PCDCommands = PCDPartProgram.Commands
    
    VK = 1
    'VT = GT.Text
    VT = 2.5
    
    Ptol = -(VT / 2 - 0.01)
    Mtol = (VT / 2 + 0.01)
    
    
    
    
    For Each cmd In PCDCommands
    Ntext = VK
    
    If cmd.IsDimension Then
    If cmd.ID = "" Then
    
    'DCmd.Plus = Ptol
    retval = cmd.PutText(CStr(Ptol), F_PLUS_TOL, 0)
    'DCmd.Minus = Mtol
    retval = cmd.PutText(CStr(Mtol), F_MINUS_TOL, 0)
    
    If (VK Mod 10) = 0 Then
    PCDApp.StatusBar = "Changing Toleranz, Command [" & CStr(VK) & "]"
    End If
    
    VK = VK + 1
    End If
    End If
    
    Next cmd
    PCDPartProgram.RefreshPart
    
    
    
    Ntext = "<END>"
    End Sub
    
  • Changing 850 dimensions with Excel ca 2min
    but if you run the script direct in pcDMIS it takes 2sec.
    like 'NinjaBadger' sayed
Reply Children
No Data