hexagon logo

Set TOUCHSPEED from Visual Basic - Is it possible?

Hi All,

I have a VB6 program that references the pcdlrn.tlb (v4.2).

In my VB6 code I'm then able to open and execute a PC-DMIS part program.

Question is once I've opened my part program is it then possible to set the TOUCHSPEED before I execute it?

Kind Regards,
Chris
  • If you can add it as a command in your partprogram, then you should be able to do it through VB.
  • Hi vpt.se,
    TOUCHSPEED already exists in my part program - I just want to be able to modify the value berfore I execute it.
    I already do something similar to set other values in my part program, like this...

    Private WithEvents mobjCurrentPart As PCDLRN.PartProgram
    Dim pcdCommand As PCDLRN.Command
    Dim strID As String
    Dim lRAAngle As Long

    lRAAngle = 45

    For Each pcdCommand In mobjCurrentPart.Commands
    If pcdCommand.IsFlowControl = True Then
    strID = pcdCommand.GetText(DEST_EXPR, 0)
    Select Case strID
    Case "ANGLE"
    Call pcdCommand.PutText(QUOTES & lRAAngle & QUOTES, SRC_EXPR, 0)
    End Select
    Call pcdCommand.ReDraw
    End If
    Next pcdCommand


    Problem is TOUCHSPEED can't be set in the same way as it seems it's type is not FlowControl (i.e. pcdCommand.IsFlowControl).

    Any ideas?
  • A TOUCHSPEED command could be of the IsModalCommand type - I am not sure though, but could be worth a try.
  • This is what I use.

    Dim DmisApp As Object
    Dim DmisPart As Object
    Dim DmisCommands As Object
    Dim DmisCommand As Object

    Sub Main
    Set DmisApp = CreateObject("PCDLRN.Application")
    Set DmisPart = DmisApp.ActivePartProgram
    Set DmisCommands = DmisPart.Commands
    CommandCount = DmisCommands.Count
    Set DmisCommand = DmisCommands.Item(CommandCount)
    DmisCommands.InsertionPointAfter DmisCommand

    ' Set Move Speed = 100
    Set DmisCommand = DmisCommands.Add(MOVE_SPEED, TRUE)
    DmisCommand.Marked = TRUE
    retval = DmisCommand.PutText ("100", F_MOVESPEED, 0)

    ' Set Touch Speed = 4
    Set DmisCommand = DmisCommands.Add(TOUCH_SPEED, TRUE)
    DmisCommand.Marked = TRUE
    retval = DmisCommand.PutText ("4", F_TOUCHSPEED, 0)

    ' Set Scan Speed = 50
    Set DmisCommand = DmisCommands.Add(SCAN_SPEED, TRUE)
    DmisCommand.Marked = TRUE
    retval = DmisCommand.PutText ("50", F_SCANSPEED, 0)

    ' Set Max Acceleration
    Set DmisCommand = DmisCommands.Add(OPTIONMOTION, TRUE)
    DmisCommand.Marked = TRUE
    ' X = 1000
    retval = DmisCommand.PutText ("2500", F_MAXACCELX, 0)
    ' Y = 1000
    retval = DmisCommand.PutText ("2500", F_MAXACCELY, 0)
    ' Z = 1000
    retval = DmisCommand.PutText ("2500", F_MAXACCELZ, 0)

    ' Assign SAFE_Z = -10
    Set DmisCommand = DmisCommands.Add(ASSIGNMENT, TRUE)
    DmisCommand.Marked = TRUE
    retval = DmisCommand.PutText ("SAFE_Z", DEST_EXPR, 0)
    retval = DmisCommand.PutText ("-10", SRC_EXPR, 0)

    End Sub
  • Thanks granpagus,
    That code snipet looks promising, will give it ago later.
    Regards,
    Chris
  • Sorted!

    In case anyone is interested, here's my code...

    Dim pcdCommand As PCDLRN.Command

    If Not mdTouchSpeed = 0 Then
    For Each pcdCommand In mobjCurrentPart.Commands
    If pcdCommand.Type = TOUCH_SPEED Then
    Call pcdCommand.PutText(mdTouchSpeed, F_TOUCHSPEED, 0)
    Call pcdCommand.ReDraw
    End If
    Next pcdCommand
    End If

    Thanks for your replies guys.