PC-DMIS to Excel script help please

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • PC-DMIS to Excel script help please

    I am a newbie to the PC-DMIS/VB/programming world. I've been running a script that has largely generated the data that we wish to incorporate into an EXCEL spreadsheet. (It continuously saves the data to a workbook that is given the name of the part programme.

    I would greatly appreciate your input in making modifications to the script namely:

    Generating a separate Excel-file (named e.g.: "prog name" + "link number") for each run (of up to 48 blades), i.e. not a separate file for each blade, but a new file for each SET of blades (including the data for up to 48 blades). How do I incorporate the "Link number" (which is a unique operator entered number each time the part programme is begun for a set of blades) in the file name?

    Apologies for the very long post - and look forward to some suggestions.

    This is part of the script:

    ''''''' THIS SCRIPT TAKES THE MEASURED VALUES FROM PC-DMIS And ADDS THEM In COL A On
    '''''''' A SPREADSHEET With THE SAME Name As THE PROGRAM, In A DIRECTORY/FOLDER NAMED BELOW
    ''''''''
    '''''''' If USED In A Loop, Or On MULTIPLE RUNS OF A PROGRAM, IT WILL ADD THE Next LOT OF DATA
    '''''''' To COL B, Then COL C... ETC.
    ''''''''
    ''''''''
    ''''''''


    'Declare Public Object variables
    Dim xcel As Object
    Dim wrkbook As Object

    Sub main()
    'Declare Object variables
    Dim pcdmis As Object
    Dim partprog As Object
    Dim cmds As Object
    Dim cmd As Object

    'create pointer To pcdmis, active part program, And it's commands
    Set pcdmis = createobject("PCDLRN.APPLICATION")
    Set partprog=pcdmis.activepartprogram
    Set cmds =partprog.commands

    ''''
    '''' ENTER THE PATH WHERE YOU WANT To SAVE THE REPORTS BELOW
    ''''
    savepath="E:\CMM Files\Excel Reports\"
    ''''
    '''' ENTER Your company Name - this will appear On the report
    ''''
    compname="XXXXXXXXXX"


    'Get the program Name (And remove the .prg file extension)
    progname = left(partprog.Name,len(partprog.Name)-4)

    'use workbookexists Function To determin whether a report already exists For this program
    If workbookexists(savepath & progname & ".xls")= True Then
    'If it does Then Open it
    Set wrkbook = getobject(savepath & progname & ".xls")
    Set xcel = wrkbook.application
    Else
    'If it doesn't Then create a new workbook And save it
    Set xcel=createobject("excel.application")
    Set wrkbook = xcel.workbooks.add
    wrkbook.SaveAs Filename:=savepath & progname & ".xls"
    End If

    'show excel And the workbook
    xcel.visible=True
    numbooks = xcel.workbooks.count
    xcel.windows(numbooks).visible=Tru

  • #2
    Code:
    ''''''' THIS SCRIPT TAKES THE MEASURED VALUES FROM PC-DMIS And ADDS THEM In COL A On 
    '''''''' A SPREADSHEET With THE SAME Name As THE PROGRAM, In A DIRECTORY/FOLDER NAMED BELOW
    ''''''''
    '''''''' If USED In A Loop, Or On MULTIPLE RUNS OF A PROGRAM, IT WILL ADD THE Next LOT OF DATA 
    '''''''' To COL B, Then COL C... ETC.
    ''''''''
    ''''''''
    ''''''''
    
    
    'Declare Public Object variables
    Dim xcel As Object
    Dim wrkbook As Object
    
    Sub main()
    'Declare Object variables
    Dim pcdmis As Object
    Dim partprog As Object
    Dim cmds As Object
    Dim cmd As Object
    
    'create pointer To pcdmis, active part program, And it's commands
    Set pcdmis = createobject("PCDLRN.APPLICATION")
    Set partprog=pcdmis.activepartprogram
    Set cmds =partprog.commands
    
    ''''
    '''' ENTER THE PATH WHERE YOU WANT To SAVE THE REPORTS BELOW
    ''''
    savepath="E:\CMM Files\Excel Reports\"
    ''''
    '''' ENTER Your company Name - this will appear On the report
    ''''
    compname="XXXXXXXXXX"
    
    
    'Get the program Name (And remove the .prg file extension)
    progname = left(partprog.Name,len(partprog.Name)-4)
    
    'use workbookexists Function To determin whether a report already exists For this program
    If workbookexists(savepath & progname & ".xls")= True Then
    'If it does Then Open it
    Set wrkbook = getobject(savepath & progname & ".xls")
    Set xcel = wrkbook.application
    Else
    'If it doesn't Then create a new workbook And save it
    Set xcel=createobject("excel.application")
    Set wrkbook = xcel.workbooks.add
    wrkbook.SaveAs Filename:=savepath & progname & ".xls"
    End If
    
    'show excel And the workbook
    xcel.visible=True
    numbooks = xcel.workbooks.count
    xcel.windows(numbooks).visible=True
    This should be moved to the forums code section instead...

    You seem to already have the saving/appending Excel code done, so you need to fetch the variable containing the linkname from PC-DMIS.

    Code:
    linkname = PartProg.GetVariableValue (your_PCDMIS_linkname_variable)
    progname = progname & linkname & ".xls"
    ...or something like that.
    Last edited by vpt.se; 06-17-2009, 01:38 AM.
    PC-DMIS CAD++ 2o19 R1 SP2

    Comment


    • #3
      Thanks very much indeed - and shall note posting etiquette in future.

      Comment


      • #4
        You're welcome.
        PC-DMIS CAD++ 2o19 R1 SP2

        Comment


        • #5
          Excuse my ignorance, but is this script ran from within PC-DMIS's script editor, or from a macro in a spreadsheet?

          Comment


          • #6
            The script is compiled in the script editor and then added to the end of the part programme. I then use an Excel macro on the file that has been produced by the script, once the part programme has completed its run, to carry out the necessary analysis.

            Comment

            Related Topics

            Collapse

            Working...
            X