hexagon logo

Run a Program from VB Application with PC-DMIS Open

Hello there,

I am trying to run a program from vb .exe application, but don't know how to leave PC-DMIS open, so that I can see which line it is running when the CMM stops.

Private Sub RunPartProgram(ByVal prg As String)

GetHeaderInfo()
app = CreateObject("PCDLRN.Application")
parts = app.PartPrograms
parts.Open(prg, "Test")
part = app.ActivePartProgram
part.Execute()
part.Close()
app.quit()

releaseObject(app)
releaseObject(parts)
releaseObject(part)

End Sub

Thanks,
Kai
  • IIRC, you can add "app.Visible = True" or "app.Visible = 1" after the CreateObject line.
  • IIRC, you can add "app.Visible = True" or "app.Visible = 1" after the CreateObject line.


    Thanks. It worked once, but didn't work again. Do you have any ideas?





  • I'm pretty surprised it's working at all, given that this ends up as a vb executable. None of the "rules" are being followed. I'm wondering what data type you're getting when you assign an object to an undeclared variable. This would end up as a Variant, I think? Very surprised it works.

    If you declare the pcdmis objects, the VB editor will assist you in very helpful ways.

    For .Open (), the 2nd argument is supposed to be either "OFFLINE" or "CMM1".

    I've found app.visible to work just fine. So maybe if you try to compile from the modified code below it will behave better. (Hope i got it right).




    Private Sub RunPartProgram(ByVal prg As String)

    GetHeaderInfo()
    dim app as application
    dim parts as partprograms
    dim part as partprogram


    Set app = CreateObject("PCDLRN.Application")
    Set parts = app.PartPrograms
    Set part = parts.Open(prg, "CMM1")
    'part = app.ActivePartProgram (delete this line)
    app.visible = true
    app.maximize 'I<-- I think this method exists. Working from memory here.
    part.Execute()
    part.Close()
    app.quit()

    releaseObject(app)
    releaseObject(parts)
    releaseObject(part)

    End Sub

    Thanks,
    Kai


  • If you want the partprogram to stay open after execution, remove the part.Close() and app.quit().