Skip to content

Commit 4725866

Browse files
committed
rename generated file to use 'part name'_'setup name'
1 parent 2fcf884 commit 4725866

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

src/fusion_api/Handlers.py

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -151,33 +151,33 @@ def postToolpaths(ui, cam, viewResult):
151151
os.startfile(outputFolder)
152152

153153

154-
def postCamToolpath(ui, cam, setup, units, outputFolder):
155-
setupOperationType = None
154+
def postCamToolpath(ui, cam, setup, units, output_folder, part_name):
155+
setup_operation_type = None
156156
# verify there are operations in setup
157157
if setup.operations.count == 0:
158158
ui.messageBox('No CAM operations exist in {}.'.format(setup.name))
159159
return
160160

161161
try:
162-
setupOperationType = setup.operationType
162+
setup_operation_type = setup.operationType
163163
except:
164164
pass # there is a bug in Fusion as of writing that means Additive setups don't have an operation type
165165

166-
if setupOperationType == adsk.cam.OperationTypes.MillingOperation:
166+
if setup_operation_type == adsk.cam.OperationTypes.MillingOperation:
167167
# remove old files
168-
programName = 'tmp_' + setup.name
169-
remove_old_file(outputFolder, programName)
168+
programName = part_name + '_' + setup.name
169+
remove_old_file(output_folder, programName)
170170

171171
# get post processor
172172
postConfig = os.path.join(Path(__file__).parents[2], 'post_processors', 'asmbl_cam.cps')
173173

174174
# create the postInput object
175-
postInput = adsk.cam.PostProcessInput.create(programName, postConfig, outputFolder, units)
175+
postInput = adsk.cam.PostProcessInput.create(programName, postConfig, output_folder, units)
176176

177177
cam.postProcess(setup, postInput)
178178

179179
start = time.time()
180-
file_path = os.path.join(outputFolder, programName + '.gcode')
180+
file_path = os.path.join(output_folder, programName + '.gcode')
181181
while not os.path.exists(file_path):
182182
if time.time() > start + 10:
183183
ui.messageBox('Posting timed out')
@@ -458,24 +458,27 @@ def notify(self, args):
458458
return
459459

460460
try:
461-
outputFolder = os.path.expanduser('~/Asmbl/output/standalone/')
461+
output_folder = os.path.expanduser('~/Asmbl/output/standalone/')
462462

463463
# get any unsuppressed setups.
464464
setups = get_setups(ui, cam)
465465

466466
# specify the NC file output units
467467
units = adsk.cam.PostOutputUnitOptions.DocumentUnitsOutput
468468

469+
# find part name
470+
part_name = doc.name
471+
469472
for setup in setups:
470-
postCamToolpath(ui, cam, setup, units, outputFolder)
473+
postCamToolpath(ui, cam, setup, units, output_folder, part_name)
471474

472475
except:
473476
ui.messageBox('Failed posting toolpaths:\n{}'.format(traceback.format_exc()))
474477
return
475478

476479
if (os.name == 'posix'):
477-
os.system('open "%s"' % outputFolder)
480+
os.system('open "%s"' % output_folder)
478481
elif (os.name == 'nt'):
479-
os.startfile(outputFolder)
482+
os.startfile(output_folder)
480483

481-
ui.messageBox('Milling Setup Post Processing Complete.\nFile saved in \'{}\''.format(outputFolder))
484+
ui.messageBox('Milling Setup Post Processing Complete.\nFile saved in \'{}\''.format(output_folder))

0 commit comments

Comments
 (0)