Results 1 to 10 of 10

Thread: VB.NET Open Pcdmis with selected program file

  1. #1
    Junior Member
    • Additional Information
      • Years CMM Experience:
      • 5
      • Software Version:
      • 2013 MR1
      • Machine Type:
      • Global Performance Silver
      • Location:
      • Oklahoma City
      • Job Function:
      • Quality Systems Director

    Join Date
    Jul 2013
    Location
    Oklahoma City
    Posts
    16

    Question VB.NET Open Pcdmis with selected program file

    I am trying to write an application that will organize our programs by customer. I have everything written and complete but I have one issue when I try to open pcdmis with the selected file loaded, depending on what method i'm using at the time i get the following results

    1. Pcdmis opens but the program file doesn't
    2. pcdmis opens and brings up the new program dialog box with the program name list in the first textbox
    3. my application crashes saying file not found.

    I have done this numerous times with other applications and nothing seems to work.

    I have tried system.diagnostics.process.start, I have tried the shell command it just doesn't seem to work. It does work if I double click the program file in the explorer app. I have seen other programs similar to this but they don't have source code available. Has any one got this to work in vb.net(not vbscript)? I'm starting to get frustrated as I have tried 36 different ways as of right now. Taking a break and hope some one will have some insight.

  2. #2
    PC-DMIS Guru
    • Additional Information
      • Years CMM Experience:
      • Since 1994
      • Software Version:
      • PC-DMIS CAD++ 2014.1
      • Machine Type:
      • CEJ12C, CEJ12000
      • Location:
      • Sweden
      • Job Function:
      • Quality tech., CMM programmer/operator
    vpt.se's Avatar
    Join Date
    Feb 2007
    Location
    Sweden
    Posts
    4,869

    Default

    Please post the code you are using.

    IIRC, there is another thread in here with the exact same issue as you.

    A snippet from one of my VBS:

    Code:
    ...
    Set PCDApp = CreateObject("PCDLRN.Application")
    Set PCDPartPrograms = PCDApp.PartPrograms
    PCDPartPrograms.Open objDLG.FileName, "CMM1"
    ...
    PC-DMIS CAD++ 2o14.1

  3. #3
    Junior Member
    • Additional Information
      • Years CMM Experience:
      • 5
      • Software Version:
      • 2013 MR1
      • Machine Type:
      • Global Performance Silver
      • Location:
      • Oklahoma City
      • Job Function:
      • Quality Systems Director

    Join Date
    Jul 2013
    Location
    Oklahoma City
    Posts
    16

    Default

    I can't remember all the different things i have tried but the last two where this.

    Code:
      fname = "Y:\" + Label1.Text + "\" + ListBox1.SelectedItem
            Dim cmstart As String
            cmstart = "C:\Program Files (x86)\WAI\PC-DMIS 2012 MR1 (Release)\PCDLRN.exe""" + """" + fname
            Start(cmstart)
    Code:
      fname = "Y:\" + Label1.Text + "\" + ListBox1.SelectedItem
            Dim cmstart As String
            cmstart = "C:\Program Files (x86)\WAI\PC-DMIS 2012 MR1 (Release)\PCDLRN.exe""" + """" + fname
            Shell(cmstart)
    I have seen the other post and have tried code similiar to what you have. The one question I have is are you using visual studio? If so do you have to have a import command to use the pcdmis commands like what you have?


    Edit: What is the "CMM1" for?

  4. #4
    Junior Member
    • Additional Information
      • Years CMM Experience:
      • 5
      • Software Version:
      • 2013 MR1
      • Machine Type:
      • Global Performance Silver
      • Location:
      • Oklahoma City
      • Job Function:
      • Quality Systems Director

    Join Date
    Jul 2013
    Location
    Oklahoma City
    Posts
    16

    Default

    Reading through the forums I have tried this

    Code:
       PCDApp = CreateObject("PCDLRN.Application")
            PCDPartPrograms = PCDApp.partprograms
            PCDApp.visible = True
            PCDApp.setactive()
            PCDApp.maximize()
            PCDPartPrograms.open(fname, "Machine1")
    pcdmis will open briefly then close. Could me issue be that I don't have pcdmis installed on the machine i develop vb.net on? It will be as soon as my offline seat gets here.

  5. #5
    Senior Member ewe0006's Avatar
    Join Date
    May 2011
    Location
    North Texas
    Posts
    396

    Default

    This is a simple example of the method I use to start PC-DMIS:

    Code:
    PcdApp = CreateObject("PCDLRN.Application")
    PcdApp.WaitUntilReady(60)
    Threading.Thread.Sleep(2000)
    I'll add other properties like PcdApp.Visible = True after the Thread.Sleep call.

  6. #6
    PC-DMIS Guru
    • Additional Information
      • Years CMM Experience:
      • Since 1994
      • Software Version:
      • PC-DMIS CAD++ 2014.1
      • Machine Type:
      • CEJ12C, CEJ12000
      • Location:
      • Sweden
      • Job Function:
      • Quality tech., CMM programmer/operator
    vpt.se's Avatar
    Join Date
    Feb 2007
    Location
    Sweden
    Posts
    4,869

    Default

    I do not use VS/VB on the CMM computers - I code mainly in the internal scripting engine in PC-DMIS or VB script.
    I do have a VS installation on my workstation, but haven't begun fiddling with that yet. I'd like my stuff to be as transparent as possible (ie. not needing extra IDE/compilers) and be able to edit the sources with a texteditor.
    PC-DMIS CAD++ 2o14.1

  7. #7
    Senior Member ewe0006's Avatar
    Join Date
    May 2011
    Location
    North Texas
    Posts
    396

    Default

    By the way, did you get PC-DMIS installed on the PC you're developing on? Doing so registers the PC-DMIS type library on your system, making it easy to add a reference in your VS project. You can then add an "Imports PCDLRN" namespace reference if you so desire.

    I would need to test this to be fully certain it would work, but you might also be able to use GetObject with an invalid argument ("" or " ") to get your application to first try connecting to an existing instance of PC-DMIS before creating a new one:

    Code:
    PcdApp = GetObject("","PCDLRN.Application")
    PcdApp.WaitUntilReady(60)
    Threading.Thread.Sleep(2000)
    The more important part of this is the WaitUntilReady and Thread.Sleep methods. If you start addressing properties on your application object before PC-DMIS is really ready, it may ignore the properties or occasionally get confused and start another instance. The WaitUntilReady method provides a flag for PC-DMIS to say it is ready to start responding to automation, and the extra two second sleep provides a bit of extra buffer for slow systems.

  8. #8
    Junior Member
    • Additional Information
      • Years CMM Experience:
      • 5
      • Software Version:
      • 2013 MR1
      • Machine Type:
      • Global Performance Silver
      • Location:
      • Oklahoma City
      • Job Function:
      • Quality Systems Director

    Join Date
    Jul 2013
    Location
    Oklahoma City
    Posts
    16

    Default

    Ok got it to work. I had to do several things. First thing I had to do was add a reference to interop.pcdlrn.dll to my project.

    Then I added this at the very beginning of my program.

    Code:
    Imports PCDLRN
    Public Class Form1
        Dim PCDApp As PCDLRN.Application
        Dim pcdpartprograms As PCDLRN.PartPrograms
    Then once program to open is selected I did this.

    Code:
    Dim fname As String
            fname = "Y:\" + Label1.Text + "\" + ListBox1.SelectedItem
            PCDApp = CreateObject("PCDLRN.Application")
            PCDApp.WaitUntilReady(60)
            Threading.Thread.Sleep(2000)
            PCDPartPrograms = PCDApp.partprograms
            PCDApp.visible = True
            PCDApp.setactive()
            PCDApp.maximize()
            PCDPartPrograms.open(fname, "Machine1")
    The only issue I have now is that it opens PCDmis then closes then reopens with the part program. I haven't figured out how to keep it from opening first.

  9. #9
    Senior Member ewe0006's Avatar
    Join Date
    May 2011
    Location
    North Texas
    Posts
    396

    Default

    Did you give the GetObject method instead of CreateObject a try?

    Code:
    PCDApp = GetObject("","PCDLRN.Application")
    This might help as your not automatically trying to create a new instance of PC-DMIS each time, but first looking for a running instance to attach to. It's possible this will keep PC-DMIS from disappearing/reappearing.

  10. #10
    Junior Member
    • Additional Information
      • Years CMM Experience:
      • 5
      • Software Version:
      • 2013 MR1
      • Machine Type:
      • Global Performance Silver
      • Location:
      • Oklahoma City
      • Job Function:
      • Quality Systems Director

    Join Date
    Jul 2013
    Location
    Oklahoma City
    Posts
    16

    Default

    My code will check to see if PC-DMIS is running then close if it is then open new instance with selected program. This is occurring with no DMIS running. I am also trying to figure out how to open a PC-DMIS and automatically show new program dialog box.

Similar Threads

  1. How-To: Output selected data to a CSV file
    By JEC_31 in forum PC-DMIS Code Samples
    Replies: 9
    Last Post: 02-06-2014, 01:14 PM
  2. Replies: 2
    Last Post: 04-24-2013, 02:06 AM
  3. PCDMIS Crash now my program won't open
    By GEATER MACHINING in forum PC-DMIS for CMMs
    Replies: 53
    Last Post: 03-06-2013, 05:30 PM
  4. Editing an ini file to open PCDMIS in Operator mode
    By DeWain Hodge in forum PC-DMIS for CMMs
    Replies: 4
    Last Post: 07-22-2010, 10:18 PM
  5. Can't open program file
    By Nguyen in forum PC-DMIS for CMMs
    Replies: 6
    Last Post: 01-16-2009, 04:12 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •