Your Products have been synced, click here to refresh
'decalre top level object variables (pcdmis / file scripting / excel) Dim pcapp As PCDLRN.Application Dim oxl As Excel.Application 'declare global variables (public/shared project wide) Dim mypath As String Dim cmdID As String Sub main() 'get the path from cell A1 Set oxl = CreateObject("Excel.Application") Dim wrkbooks As Excel.Workbooks Set wrkbooks = Excel.Application.Workbooks Dim wrkbook As Excel.Workbook For Each wrkbook In wrkbooks If wrkbook.Name = "DaSalo(ver1).xlsm" Then Dim wrksheet As Excel.Worksheet Set wrksheet = wrkbook.Worksheets(1) mypath = wrksheet.Range("A1") cmdID = wrksheet.Range("A2") Debug.Print mypath End If Next 'open pc-dmis Set pcapp = CreateObject("pcdlrn.application") Dim fname As String fname = Dir(mypath & "\*.prg") Do While fname <> "" Debug.Print fname ''Call pc-dmis subroutine here DoShitWithDmis (fname) fname = Dir() Loop End Sub
Sub DoShitWithDmis(fname As String) Dim progpath As String progpath = mypath & "\" & fname Dim pcpart As PCDLRN.PartProgram Debug.Print progpath Set pcpart = pcapp.PartPrograms.Open(progpath, "Offline") Dim cmds As PCDLRN.Commands Dim cmd As PCDLRN.Command Set cmds = pcpart.Commands Dim deletecommandflag As Boolean deletecommandflag = False 'loop through commands deleting once delete command flag has bees set to true For Each cmd In cmds If cmd.ID = cmdID Then deletecommandflag = True End If If deletecommandflag = True Then cmd.Remove End If Next Set cmd = cmds.LastCommand cmds.InsertionPointAfter cmd '>>>>>>>>>>>>>>>>> COMMANDS TO ADD EXPORTED FROM PC-DMIS HERE 'VIEW THE .BAS IN NOTEPAD AND REPLACE (CTRL+H) 'DmisCommand' WITH 'cmd' Set cmd = cmds.Add(DIMENSION_START_LOCATION, True) cmd.Marked = True ' Set Id = LOC1 retval = cmd.PutText("LOC1", ID, 0) ' Set Reference Id = CIR2 retval = cmd.PutText("CIR2", REF_ID, 0) ' Set Graphic Analysis = OFF retval = cmd.SetToggleString(1, GRAPH_ANALYSIS, 0) ' Set Textual Analysis = OFF retval = cmd.SetToggleString(1, TEXT_ANALYSIS, 0) ' Set Arrow Multiplier = 10.000000 retval = cmd.PutText("10.000000", ARROW_MULTIPLIER, 0) ' Set Output Type = BOTH retval = cmd.SetToggleString(3, OUTPUT_TYPE, 0) ' Set Unit Type = MM retval = cmd.SetToggleString(2, UNIT_TYPE, 0) ' Set Standard Deviation = 0.000000 retval = cmd.PutText("0.000000", STANDARD_DEVIATION, 0) ' Set Half Angle = NO retval = cmd.SetToggleString(1, DIM_HALF_ANGLE, 0) Set cmd = cmds.Add(DIMENSION_X_LOCATION, True) cmd.Marked = True ' Set Axis = X retval = cmd.PutText("X", Axis, 0) ' Set Nominal = 0.000 retval = cmd.PutText(" 0.000", Nominal, 0) ' Set Measured = 0.000 retval = cmd.PutText(" 0.000", DIM_MEASURED, 0) ' Set Plus Tolerance = 0.051 retval = cmd.PutText(" 0.051", F_PLUS_TOL, 0) ' Set Minus Tolerance = -0.051 retval = cmd.PutText(" -0.051", F_MINUS_TOL, 0) ' Set Max = 13.492 retval = cmd.PutText(" 13.492", DIM_MAX, 0) ' Set Min = -13.492 retval = cmd.PutText(" -13.492", DIM_MIN, 0) ' Set Deviation = 0.000 retval = cmd.PutText(" 0.000", DIM_DEVIATION, 0) ' Set Out Tol = 0 retval = cmd.PutText("0", DIM_OUTTOL, 0) Set cmd = cmds.Add(DIMENSION_Z_LOCATION, True) cmd.Marked = True ' Set Axis = Z retval = cmd.PutText("Z", Axis, 0) ' Set Nominal = 0.000 retval = cmd.PutText(" 0.000", Nominal, 0) ' Set Measured = 0.000 retval = cmd.PutText(" 0.000", DIM_MEASURED, 0) ' Set Plus Tolerance = 0.051 retval = cmd.PutText(" 0.051", F_PLUS_TOL, 0) ' Set Minus Tolerance = -0.051 retval = cmd.PutText(" -0.051", F_MINUS_TOL, 0) ' Set Max = -0.471 retval = cmd.PutText(" -0.471", DIM_MAX, 0) ' Set Min = -13.500 retval = cmd.PutText(" -13.500", DIM_MIN, 0) ' Set Deviation = 0.000 retval = cmd.PutText(" 0.000", DIM_DEVIATION, 0) ' Set Out Tol = 0 retval = cmd.PutText("0", DIM_OUTTOL, 0) Set cmd = cmds.Add(DIMENSION_D_LOCATION, True) cmd.Marked = True ' Set Axis = D retval = cmd.PutText("D", Axis, 0) ' Set Nominal = 27.000 retval = cmd.PutText(" 27.000", Nominal, 0) ' Set Measured = 27.000 retval = cmd.PutText(" 27.000", DIM_MEASURED, 0) ' Set Plus Tolerance = 0.051 retval = cmd.PutText(" 0.051", F_PLUS_TOL, 0) ' Set Minus Tolerance = -0.051 retval = cmd.PutText(" -0.051", F_MINUS_TOL, 0) ' Set Max = 0.000 retval = cmd.PutText(" 0.000", DIM_MAX, 0) ' Set Min = 0.000 retval = cmd.PutText(" 0.000", DIM_MIN, 0) ' Set Deviation = 0.000 retval = cmd.PutText(" 0.000", DIM_DEVIATION, 0) ' Set Out Tol = 0 retval = cmd.PutText("0", DIM_OUTTOL, 0) Set cmd = cmds.Add(DIMENSION_END_LOCATION, True) cmd.Marked = True Set cmd = cmds.Add(DIMENSION_START_LOCATION, True) cmd.Marked = True ' Set Id = LOC2 retval = cmd.PutText("LOC2", ID, 0) ' Set Reference Id = CIR3 retval = cmd.PutText("CIR3", REF_ID, 0) ' Set Graphic Analysis = OFF retval = cmd.SetToggleString(1, GRAPH_ANALYSIS, 0) ' Set Textual Analysis = OFF retval = cmd.SetToggleString(1, TEXT_ANALYSIS, 0) ' Set Arrow Multiplier = 10.000000 retval = cmd.PutText("10.000000", ARROW_MULTIPLIER, 0) ' Set Output Type = BOTH retval = cmd.SetToggleString(3, OUTPUT_TYPE, 0) ' Set Unit Type = MM retval = cmd.SetToggleString(2, UNIT_TYPE, 0) ' Set Standard Deviation = 0.000000 retval = cmd.PutText("0.000000", STANDARD_DEVIATION, 0) ' Set Half Angle = NO retval = cmd.SetToggleString(1, DIM_HALF_ANGLE, 0) Set cmd = cmds.Add(DIMENSION_X_LOCATION, True) cmd.Marked = True ' Set Axis = X retval = cmd.PutText("X", Axis, 0) ' Set Nominal = 0.000 retval = cmd.PutText(" 0.000", Nominal, 0) ' Set Measured = 0.000 retval = cmd.PutText(" 0.000", DIM_MEASURED, 0) ' Set Plus Tolerance = 0.051 retval = cmd.PutText(" 0.051", F_PLUS_TOL, 0) ' Set Minus Tolerance = -0.051 retval = cmd.PutText(" -0.051", F_MINUS_TOL, 0) ' Set Max = 13.492 retval = cmd.PutText(" 13.492", DIM_MAX, 0) ' Set Min = -13.492 retval = cmd.PutText(" -13.492", DIM_MIN, 0) ' Set Deviation = 0.000 retval = cmd.PutText(" 0.000", DIM_DEVIATION, 0) ' Set Out Tol = 0 retval = cmd.PutText("0", DIM_OUTTOL, 0) Set cmd = cmds.Add(DIMENSION_Z_LOCATION, True) cmd.Marked = True ' Set Axis = Z retval = cmd.PutText("Z", Axis, 0) ' Set Nominal = 0.000 retval = cmd.PutText(" 0.000", Nominal, 0) ' Set Measured = 0.000 retval = cmd.PutText(" 0.000", DIM_MEASURED, 0) ' Set Plus Tolerance = 0.051 retval = cmd.PutText(" 0.051", F_PLUS_TOL, 0) ' Set Minus Tolerance = -0.051 retval = cmd.PutText(" -0.051", F_MINUS_TOL, 0) ' Set Max = -0.471 retval = cmd.PutText(" -0.471", DIM_MAX, 0) ' Set Min = -13.500 retval = cmd.PutText(" -13.500", DIM_MIN, 0) ' Set Deviation = 0.000 retval = cmd.PutText(" 0.000", DIM_DEVIATION, 0) ' Set Out Tol = 0 retval = cmd.PutText("0", DIM_OUTTOL, 0) Set cmd = cmds.Add(DIMENSION_D_LOCATION, True) cmd.Marked = True ' Set Axis = D retval = cmd.PutText("D", Axis, 0) ' Set Nominal = 27.000 retval = cmd.PutText(" 27.000", Nominal, 0) ' Set Measured = 27.000 retval = cmd.PutText(" 27.000", DIM_MEASURED, 0) ' Set Plus Tolerance = 0.051 retval = cmd.PutText(" 0.051", F_PLUS_TOL, 0) ' Set Minus Tolerance = -0.051 retval = cmd.PutText(" -0.051", F_MINUS_TOL, 0) ' Set Max = 0.000 retval = cmd.PutText(" 0.000", DIM_MAX, 0) ' Set Min = 0.000 retval = cmd.PutText(" 0.000", DIM_MIN, 0) ' Set Deviation = 0.000 retval = cmd.PutText(" 0.000", DIM_DEVIATION, 0) ' Set Out Tol = 0 retval = cmd.PutText("0", DIM_OUTTOL, 0) Set cmd = cmds.Add(DIMENSION_END_LOCATION, True) cmd.Marked = True '>>>>>>>>>>>>>>>>> COMMANDS TO ADD EXPORTED FROM PC-DMIS ABOVE HERE pcpart.SaveAs (mypath & "\Processed files\" & fname) 'Shell ("C:\Program Files (x86)\WAI\PC-DMIS 2012 MR1 (Release)\Wizards\PCD2EXCEL.exe /A") Debug.Print fname & " : file processed" pcpart.Quit End Sub
'Launch PCD2Excel Wizard to generate .CSV Shell ("C:\BladeRunner\PCD2EXCEL.exe /A") 'Wait for process to end 'Wait for process to end While IsExeRunning("PCD2Excel.exe") Sleep (5000) 'MsgBox "PCD2Excel is running", 0, "Debug" Wend
© 2024 Hexagon AB and/or its subsidiaries. | Privacy Policy | Cloud Services Agreement |