hexagon logo

PC-DMIS 2012 MR1 & Scripting

Is VB scripting the only form of code to use for pc-dmis 2012 mr1?
  • Pravin
    are you using visual basic to run this script?
  • My 2 cents worth works every time in every version with one caveat

    you must find and register "pcdmisutils.dll" first

    for 32 bit OS's register using regsvr32

    for 64 bit it must be placed in the "WOW" directory under windows and regsvr32 executed with admin privileges (cntrl - shift - enter)

    a sample application which brings in our automated PCDMIS TO EXCEL>>>

    Sub MAIN

    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    Dim Part As Object '<<<<<<<<<<<<<<<
    Set Part = App.ActivePartProgram '<<<<<<<<<<<<<
    Dim Cmds As Object
    Set Cmds = Part.Commands
    Dim Cmd As Object
    Dim DCmd As Object
    Dim DcmdID As Object
    Dim DimID As String
    Dim THISFILE As String
    Dim SOURCE As String
    Dim DEST As String
    On Error GoTo NOCOPY

    SOURCE = "C:\QTI\MASTER.xls"
    DEST = "C:\QTI\" & PART.PARTNAME & ".XLS"
    FILECOPY SOURCE, DEST
    NOCOPY:
    THISFILE = PART.PARTNAME & ".XLS"


    Dim oxl As Object
    Dim lsSheetName As String
    Dim lbReopenBetweenRuns As Boolean
    ' Set lbReopenBetweenRuns = False If you want the worksheet To stay Open between runs
    lbReopenBetweenRuns = False
    'If excel isnt running, we dont want the Next Line To cras
    'Get a handle To the running instance of excel
    Dim oExcelBroker As Object
    Set oExcelBroker = CreateObject("PCDMISUTILS.cExcelBroker")
    Set oxl = oExcelBroker.GetExcel()
    Set oExcelBroker = Nothing
    'Turn off Error checking
    On Error Resume Next
    ' make sure If the workbook is Open we Close it before we try To reopen it
    lsSheetName = ""
    lsSheetName = oxl.Workbooks(THISFILE).Name

    If lbReopenBetweenRuns Then
    If lsSheetName <> "" Then
    ' Workbook is currently Open -- Close it w/o saving changes
    oxl.Workbooks(THISFILE).Close False
    End If
    ' Resume the normal Error handling
    'On Error GoTo 0
    ' Open the workbook containing the macro we want To run
    oxl.Workbooks.Open DEST, 3, False
    Else
    'keep the workbook Open between runs
    If lsSheetName <> "" Then
    'If we're supposed To keep the workbook Open And treat it As an additional run
    'make sure this is the activ workbook
    oxl.Workbooks(THISFILE).Activate
    Else
    ' Resume the normal Error handling
    On Error GoTo 0
    ' Open the workbook containing the macro we want To run
    oxl.Workbooks.Open DEST, 3, False
    End If
    End If
    On Error Resume Next

    ' Run the main macro
    lsSheetName = oxl.ActiveWorkbook.Name
    oxl.Run lsSheetName & "!Sheet1.main"
    'Remove the ' In the begining of the Next Line To enable autosaving the sheet
    oxl.ActiveWorkbook.Save
    'Show excel To the user
    oxl.Visible = True
    'cleanup
    Set oxl = Nothing
    End Sub

    anyone who wants the excel spreadsheet to review and comment please pm me... it is IMHO the best interface out there for pcdmis

    After i have developed it since the first version of pcdmis after growing up with AVAIL

    WE ALSO HAVE MANY OTHER FIRST ARTICLE TEMPLATES ALL FOR FREE AND BETA REVIEW

    THANX

    Alvin
  • the script to run the above which you insert into pcdmis at the end

    CS1 =SCRIPT/FILENAME= C:\QTI\AUTOEXCEL2013.BAS
    FUNCTION/Main,SHOW=YES,,
    STARTSCRIPT/
    ENDSCRIPT/
  • Do you have multiple versions of PC-DMIS installed? I ask because you say it worked with the earlier version.
    Pravin- No. I have only PC-DMIS 2012 MR1 installed on machine.

    In the respective installations, did you copy the correct interface dll so that it can go on-line?
    Pravin-Yes. Installation is done properly as programs are running fine in online when we direct run it from PC-DMIS. Only problem is running through vb6 application.

    Is this a BASIC script or are you using VB6? or calling with VBA?
    Pravin- VB6.

    If its not a script, did you link it with the correct object library?
    Pravin-Its not script so Not Applicable..

    If you have VB6, can you try my code as a standalone project? Don't add any functions, just use it as the lone project, and hard code your own path for the program location.
    Pravin- Yes. I did same. Run your code alone.


  • Is this a BASIC script or are you using VB6? or calling with VBA?
    Pravin- VB6.

    If its not a script, did you link it with the correct object library?
    Pravin-Its not script so Not Applicable..


    Actually, as a VB6 project you DO need to register PC-DMIS 2012 MR1, link to the type/object library.


    If you have VB6, can you try my code as a standalone project? Don't add any functions, just use it as the lone project, and hard code your own path for the program location.
    Pravin- Yes. I did same. Run your code alone.


    I am confused by this last response. Did my code run your program on-line?
  • Actually, as a VB6 project you DO need to register PC-DMIS 2012 MR1, link to the type/object library.



    I am confused by this last response. Did my code run your program on-line?


    No your code also behaving same as mine in offline mode.

    which file we need to register from PC-DMIS 2012 and which TLB has to link in vb project? because till PC-DMIS 2011 we havent register or link any TLB file in vb project. Is it specifically needed for PC-DMIS 2012?
  • The file is called PCDLRN.TLB, but in reality you don't need to know the name. You show be able to use the VB6 menu to select Project - References and then scroll through to he list to look for (alphabetically) PC-DMIS 2012 MR1 Object Library. In fact, while you are there, look near the top of the list to see if any other PC-DMIS libraries are already linked in, such as the 2011 version. If there are others besides 2012 MR1, disable them.

    Thinking about what you said, I suppose its not required to link to the object library, but it sure makes programming much easier. When you link to the TLB it feeds you the objects automatically as you type.

    Also, VPT.SE had a great point. Make sure this is the FIRST program opened, because anything after the first is automatically offline.
  • Regarding VPT.SE's point, I have restarted PC and open with my VB application. so there isn't any program open. Also as you suggested I have added 10-20 sec puase between part.open and part.execute. so as per my best, I have tried all precautions mentioned in this complete thread and many more. But still problem remains same run program in offline only.

    OK, I will add PC-DMIS 2012 MR1 Object Library. in project and will give try once again and will post my comments on that.
  • I have an external program written in Delphi Pascal that starts PC-DMIS and then (among a lot of other things) allows you to start a partprogram using a barcode reader. This program has no problem running part programs in 2012 MR1 (I just tested that), it works there exactly the same as any other version.

    Essentialy, my program does

    PCD_Application := CreateOleObject(ServerName);
        PCD_PartPrograms := PCD_Application.PartPrograms;
        PCD_PartProgram := PCD_PartPrograms.Open(LocalFileName, 'CMM1');
        PCD_PartProgram.Activate;
        PCD_PartProgram.EXECUTE;


    and the part program executes (yes, I noted now that I use "CMM1" and it still works).