hexagon logo

Automate export?

Seeking a way to automate the export process, specifically to IGES.

Ideal would be code that happens at finish of program run.

Next best thing would be a button to click.

Any ideas as to where to start?

Thanks in advance!

- Josh
  • There is a scripting command for this but I am not in front of my PCDMIS to find it right now.
  • DMISPart.Export (CadFileName)

    set up your dmisapp, dmispart, etc. the usual way. PC-DMIS exports your file based on the extension of the variable cadfilename (it has to be a string).
  • Thanks Jonny

    Here's the completed working BAS:

    Sub main(AutomaticIGESout)
    
    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    
    Dim Part As Object
    Set Part = App.ActivePartProgram
    
    Dim strProgID As String
    strProgID = Part.FullName
    
    Dim strNewName As String
    Dim findDotPosition
    
    Part.Save
    
    findDotPosition = InStr(1, strProgID, ".")
    strNewName = Left(strProgID, findDotPosition - 1)
    
    Part.Export strNewName + ".igs"
    
    End Sub
    


    Now, how do I get it to either NOT skip the choosing-a-directory-to-export-to step that happens when program is exported manually, or even better to automatically dump it into my intended network folder?

    - Josh
  • hmmmm. When I do this I get the screen which allows me to process the igs file but it never asks where to put it. I haven't yet been able to get it to process automatically. There should be some way of send keys or something but I haven't come across a nice clean way.
  • Sorry to bump an old thread. Has anyone found a solution to the issues discussed in this thread? It seems that export an be almost automatic but not really fully automatic.
  • Here is a script based on the one above. This one takes some variable values that are passed from PC-DMIS and concatenates them into a full path that defines both the destination directory and the name of the exported CAD file. As always, the file extension determines the actual format of the file. This still isn't fully automated in that you still need to select the alignment that you want to use, click "process", and then click "OK". I'm not sure how to get around this.

    'This script will export the features In the active program To a file of the Type specified by the extension value
    'In the Part.Export Function Line. The export path And file Name are defined by concatenating the values of 
    'several variables defined In the PC-DMIS program.
    
    Sub Main(PN1 As String, OP1 As String, SN1 As String, RPTTIME1 As String, RPTDATE1 As String, IGS1 As String)
    
    Dim App As Object
    Set App = CreateObject("PCDLRN.Application")
    
    Dim Part As Object
    Set Part = App.ActivePartProgram
    
    Dim CADFullPath As String
    
    'Concatenate variable values passed from PCD To create full path for new CAD file
    CADFullPath=IGS1 & PN1 & "\Results\IGES\" & PN1 & "_" & OP1 & "_" & SN1 & "_" & RPTTIME1 & "_" & RPTDATE1
    
    'Call export Function. Change the value of the extension below To change the file Type exported.
    Part.Export CADFullPath + ".igs"
    
    End Sub




    P.S. The path MUST already exist. If it doesn't you will get a "Method Exception : Internal Application Error"
  • One more thing about this process: for whatever reason PC-DMIS has been very finicky about passing variables to this script. Not sure why. In order to successfully pass the values I had to reassign the variables right before the script is called. These variables are all read in from an external document at the top of the program and then the value is passed again to another PC-DMIS variable which is then passed to this script. I have no idea why that extra pass off is necessary. Perhaps there is some type conversion happening there for some reason, although there should be no reason that any of these would be seen as anything other than strings. Anyhow, if you do it like this it will work every time:

    $$ NO,
                *****************************************
                Export IGES
                *****************************************
                ASSIGN/PN1=PN
                ASSIGN/OP1=OP
                ASSIGN/SN1=SN
                ASSIGN/RPTTIME1=RPTTIME
                ASSIGN/RPTDATE1=RPTDATE
                ASSIGN/IGS1=IGS
                ASSIGN/DIRECT="\\Results\\IGES\\"
    CS3        =SCRIPT/FILENAME= C:\BLADERUNNER\SCRIPTS\IGS_EXPORT.BAS
                FUNCTION/Main,SHOW=YES,ARG1=PN1,ARG2=OP1,ARG3=SN1,ARG4=RPTTIME1,ARG5=RPTDATE1,ARG6=IGS1,ARG7=DIRECT,,
                STARTSCRIPT/
  • One more thing about this process: for whatever reason PC-DMIS has been very finicky about passing variables to this script. Not sure why.
    My experience has been the same. I resorted to using PartProgram.GetVariableValue in my scripts instead of passing arguments. I never much cared for this because the program variable names are hard-coded into the script.

    I'll have to give your approach a try. Thanks for posting your solution!
  • Hah! I was just thinking that I'm going to have to stop being lazy and do the extra coding for the .getvariablevalue method from now on. It seems random which scripts will easily accept the pass off and which will not. I have another script which is literally run on the very next line of this program and uses all of the same arguments. With that script I can pass the variables that were assigned way up at the top of the program without any trouble. With this script the only way to get it to work was to reassign them right above it. I even tried copy and paste of the argument names from the script call right below(the one that works) to this script call and still nothing. Very puzzling...
  • DeSalo and DJAMS, you guys are awesome.

    I am going to proceed with trying to fully automate IGES export, mostly because one of my customers suffers through doing it manually for every single part run and their operators are always choosing the wrong alignment.

    Apparently to access the "Process" and "OK" dialog buttons we must dwelve into the Windows system dialog window handles and sub-handles. Unknown territory for me, requires some mad IT hackskillz.


    FYI, JEC_31 was me. I first joined the forum with that username while at my first PC-DMIS gig in Nevada and when I left unexpectedly I lost access.