Visual Basic Shell

Collapse
X
 
  • Time
  • Show
Clear All
new posts

  • Visual Basic Shell

    I've posted before on about a VB shell program to launch other programs. I'm working on mine at the moment but am currently stuck. (Object errors).

    Keep in mind this is an external independent program, not a script inserted into a PCDMIS program.

    The reason I use VB to make an external shell is because it's easier to design and offers help when you need it. I'm using VB 2005 express edition (free from microsoft) and it doesn't import VB 6.0 programs well. (Allgui from the wilcox site won't convert over).

    Anyone have a working external independent shell sample that I can use to build on? Gimme a very basic working template and I can go from there. Not asking for handouts, besides I want to customize my own. Any out there that is willing to share a cut/paste template?
    I used to be high on life but I built up a tolerance.

    Brown & Sharpe Global Advantage
    PCDMIS CAD++ v2011mr2
    PH10MQ/SP600M


    sigpic

  • #2
    I got the majority of the core from the Wilcox site. Not sure what vb2005 express is, but you can buy vb 6 for around $100. Compared to 15K+ for pcdmis, it seems like a bargain...

    This example below may contain some code you don't need since I borrowed from one of my apps, but it will generally give you the idea

    ******************First you need to start PCDMIS.....

    Sub StartPCDMIS(Optional NotHidden As Boolean = False)

    On Error GoTo PCDMISStartError
    Set PCDMISApp = CreateObject("PCDLRN.Application")
    PCDMISApp.WaitUntilReady 30
    If NotHidden = True Then
    PCDMISApp.SetActive
    PCDMISApp.Maximize
    PCDMISApp.Visible = True
    Else
    PCDMISApp.Visible = False
    End If

    On Error GoTo 0
    Exit Sub

    PCDMISStartError:

    MsgBox "No PCDMIS Hasp or software found", vbOKOnly, "PCDMIS Error"

    Shutdown

    End Sub

    *****************Then you need to launch your programs.....

    Public Function StartPCDMISProgram(sDMISProgram As String) As Boolean

    Dim Parts As Object
    Set Parts = PCDMISApp.PartPrograms
    Dim Prog As String
    Dim a As Integer
    Dim v As Integer
    Dim Tmp As String
    Dim iFileNum As Integer

    If Not bCMMSoftwareOFF Then
    On Error GoTo ErrHandler
    Set Part = Parts.Open(sDMISProgram, "CMM1")
    PCDMISApp.Visible = 0
    PCDMISApp.SetActive
    PCDMISApp.Maximize
    Part.EXECUTE
    StartPCDMISProgram = True
    PCDMISApp.Visible = False
    Part.Close
    Set Part = Nothing
    End If

    Exit Function
    ErrHandler:
    StartPCDMISProgram = False
    On Error GoTo 0
    CMMLog "Error loading PCDMIS Program: " & sDMISProgram
    MsgBox "Error during CMM program load" & vbCrLf & _
    "CMM program: " & sDMISProgram & vbCrLf & _
    "Possible Causes:" & vbCrLf & _
    "Program file is missing." & vbCrLf & _
    "Program file is mislocated." & vbCrLf & _
    "CMMMaster.ini file has the wrong program or path." & vbCrLf, _
    vbOKOnly, "PCDMIS ERROR"


    End Function
    Links to my utilities for PCDMIS

    Comment


    • #3
      VB Execute PC-DMIS

      Here is an example of a program I was working with. It opens up a "named" PC-DMIS program and then executes it from one specific command to another. These are all fixed in the VB program (PC-DMIS program name, start command, end command) but it is just an example. You can substitute variables for any or all of these to make it behave the way you want. If you leave out the Start CMD and End CMD stufff, it will exsecute the entire program.

      Obviously, to make it real pretty, you would add a GUI to have the operator pick a program from a list.

      ******************************************

      Private Sub Command1_Click()
      ' Create Object Variable to point to application
      Dim app As Object
      ' Create Object Variable to point to partprograms
      Dim Parts As Object
      ' Create Object Variable to point to the partprogram
      Dim part As Object

      Open "f:\pcdmisw_v36\AutomationStartupOptions.txt" For Output As #1
      Print #1, "/f"
      Close #1


      ' Launch PC-Dmis by creating the app object
      Set app = CreateObject("PCDLRN.Application")
      ' Ask the App object for the partprograms object
      Set Parts = app.PartPrograms
      ' Ask the Partprograms object to display the file
      ' open dialog and return the opened part program object
      Set part = Parts.Open("dn3.prg", "OFFLINE")

      app.Visible = True

      Dim cmds As PCDLRN.Commands
      Set cmds = part.Commands

      Dim cmd As PCDLRN.Command
      Dim cmd_stt As PCDLRN.Command
      Dim cmd_end As PCDLRN.Command

      For Each cmd In cmds

      If cmd.ID = "Cir4" Then
      MsgBox cmd.Type & " - " & cmd.TypeDescription
      Set cmd_stt = cmd
      End If

      If cmd.ID = "Cir6" Then
      MsgBox cmd.Type & " - " & cmd.TypeDescription
      Set cmd_end = cmd
      End If

      Next cmd



      Dim test As Boolean
      test = part.SetExecutionBlock(cmd_stt, cmd_end)


      ' Execute the opened part program
      part.EXECUTE
      ' Close the part program
      part.Close
      ' Quit the Application (shut down PC-Dmis)
      app.Quit
      End
      End Sub

      **********************************************

      Comment


      • #4
        Good Morning,
        I hate to sound stupid,,,,,,but what is the purpose of this application and what are the advantages?????????

        A.Gore
        sigpicA.Gore

        Comment


        • #5
          Don,
          It looks like that will execute between cir4 and cir6 - correct? I have not played with executing particular commands in a program.

          Have you tried this much with any success?

          Have you tried or found a way to turn certain marked sets on?


          Just a comment about my first post.
          When you start PCDMIS that way, it is silent. No visible interface except for the run control box or what ever you call it.
          When the program is finished PCDMIS is invisible but still running. Also, don't start PCDMIS every time you run a program, only at the beginning of the your vb app. It take up to a minute to initialize PCDMIS each time
          Links to my utilities for PCDMIS

          Comment


          • #6
            AG162,
            Purpose?
            To start pcdmis programs independent of the normal frontend.
            To control the CMM as part of an automated cell.
            For fun...
            Links to my utilities for PCDMIS

            Comment

            Related Topics

            Collapse

            Working...
            X
            😀
            🥰
            🤢
            😎
            😡
            👍
            👎