Your Products have been synced, click here to refresh
Another long shot:
Change:
objFolder = objFSO.CreateFolder(strFldr)
To:
[COLOR="#FF0000"]Set[/COLOR] objFolder = objFSO.CreateFolder(strFldr)
Sub Main() Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") 'Declares PC-DMIS As the Active Program/Application Dim PCDApp As Object Dim Part As Object Dim Cmds As Object Dim Cmd As Object Dim TCmd As Object Dim TCmds As Object Set PCDApp = CreateObject("PCDLRN.Application") Set Part = PCDApp.ActivePartProgram Set Cmds = Part.Commands Dim VPART, VDESCRIPTION, VPROGRAMID, VPROGRAMREV As Object Dim VSERIALNUMBER As String Dim RESULTS As String Set VPART = Part.GetVariableValue ("VPART") Set VDESCRIPTION = Part.GetVariableValue ("VDESCRIPTION") Set VPROGRAMID = Part.GetVariableValue ("VPROGRAMID") Set VPROGRAMREV = Part.GetVariableValue ("VPROGRAMREV") For Each Cmd In Cmds If Cmd.IsTraceField Then If Cmd.GetText(TRACE_NAME, 0) = "Serial Number" Then VSERIALNUMBER = Cmd.GetText(TRACE_VALUE, 0) End If End If Next Cmd strPath = "D:\\CMM_PROGRAMS\\" & VPART.StringValue & "_" & VDESCRIPTION.StringValue & "_" & VPROGRAMID.StringValue & "_" & VPROGRAMREV.StringValue strFldrPath = strPath & "\" & "RESULTS\" strFldrName = VSERIALNUMBER strFldr = strFldrPath & StrFldrName Set objFldr = objFSO.CreateFolder(strFldr) End Sub
Sub Main() Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFldr = objFSO.CreateFolder("C:\test") End Sub
Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") Set objFldr = objFSO.CreateFolder("C:\test")
Sub Main 'Declares the File System Object And Instantiates it Dim objFSO Set objFSO = CreateObject("Scripting.FileSystemObject") 'Declares PC-DMIS As the Active Program/Application Dim PCDApp, PCDPartProgram, PCDCommands, PCDCommand, retval Set PCDApp = CreateObject("PCDLRN.Application") Set Part = PCDApp.ActivePartProgram Set PCDCommands = PCDPartProgram.Commands 'Declares Variables from the prg As Objects Dim VPART As Object Dim VDESCRIPTION As Object Dim VSERIALNUMBER As Object Dim VDATE As Object Dim RESULTS As String 'Pulls the variables from the prg Set VPART = Part.GetVariableValue ("VPART") Set VDESCRIPTION = Part.GetVariableValue ("VDESCRIPTION") Set VSERIALNUMBER = Part.GetVariableValue ("VSERIALNUMBER") Set VDATE = Part.GetVariableValue ("VDATE") 'Declares the Filepath, Folder, And the Filename As a String strPath = Part.Path 'Uses the prg path As the path For the folder 'Sets the folder Name And the Path For the Folder strFolderName = VPART.StringValue & "_" & VDESCRIPTION.StringValue & "_" & VSERIALNUMBER.StringValue & "_" & VDATE.StringValue strFolder = strPath & "RESULTS\" & strFolderName If objFSO.FolderExists(strFolder) Then GoTo labelEnd 'This command creates the folder objFolder = objFSO.CreateFolder(strFolder) labelEnd End Sub
So, I believe that in order to use "out-of-process" objects, you'd need to code them differently (look in the PC-DMIS basic helpfile), or code the script as a VBS-script and call that from within PC-DMIS.
The folder hierarchy is different between the two scripts you've posted - is this intentional?
1) For "strPath=" you are using \\ for folder delimiter and for "strFldrName=" you are using \ - I think the single slash is correct.
Different how?
In the script you are working on you have
D:\CMM_PROGRAMS\DIRECTORY_FROM_A_BUNCH_OF_VARIABLES\ RESULTS\
In the script that works (except in bladerunner) you have
Part.Path\ RESULTS\DIRECTORY_FROM_A_BUNCH_OF_VARIABLES\
Where Part.Path is the directory the part program lives in. I was just noticing that the RESULTS folder is in a different spot.
edit: I tested the \\ vs \ thing - it seems that it doesn't matter. It works either way.
The folders are in the same spot. The reason I didn't use the Part.Path is that BladeRunner copies the chosen program and runs it in a "temp" folder. It would interpret Part.Path as the temp folder.
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |