Message 1 of 8

Not applicable
06-15-2018
10:29 AM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Trying to automate the process which is possible via fusion 360 user interface, running in quite a few syntax problems, and other stuff which I don't know where to even begin troubleshoot. Hopping to get a piece of working code which I can tweak further. Thanks in advance.
Need a script, or addon (whatever takes lesser toll on the computer memory while not in use)
"Export bundle"
In the f3d document there is 6 or more occurences, four of which are named. The other two or more will have a deffault name.
Names:
CompOne:1
CompTwo:1
CompThree:1
CompFour:1
Componnent 1:1
Componnent 2:1
,etc.
The prefix for exports in a unitless expression (12345) of the user parameter named "name_ID"
The script or add-on should be a button on the ribbon in the solid model workspace, promoted by default.
This is how i see the flow:
define exp_bundle()
{
nID=user parameter ('nameID')
eID=nID.expression
tID=str(eID)
Show open/save dialog
Populate save dialog with tID+'.txt'
dFile=dialog's filename with path and extension
pFile=filepath of (dFile)
fnFile=only the filename without the path or extension
pID=pFile + fnFile
exp_f(pID)
exp_m(pID)
exp_s(pID)
exp_g(pID)
if there are no errors then
Display mesage (fnFile + 'bundle has been saved')
}
define exp_f(pID)
{
#compose name
ena =(pID)
export fusion archive to (ena)
if export fails show message-box (ena + ' failed to export') # preferably without the path somehow
}
define exp_m(pID)
{
#compose name
ena =(pID+'_m.stl')
#turn on required objects
turn lightbulb on (CompTwo:1)
turn lightbulb on (CompThree:1)
#perform export
export root component (all visible) to stl (ena)
#turn off required objects
turn lightbulb off (CompTwo:1)
turn lightbulb off (CompThree:1)
if export fails show message-box (ena + ' failed to export') # preferably without the path somehow
}
define exp_s(pID)
{
#compose name
ena =(pID+'_s.stl')
#turn on required objects
turn lightbulb on (CompThree:1)
#perform export
export root component (all visible) to stl (ena)
#turn off required objects
turn lightbulb off (CompThree:1)
if export fails show message-box (ena + ' failed to export') # preferably without the path somehow
}
define exp_g(pID)
{
#compose name
ena =(pID+'_g.stl')
#isolate on required objects
isolate on (CompTwo:1)
#perform export
export root component (all visible) to stl (ena)
#unisolate required objects
turn lightbulb off (CompTwo:1)
if export fails show message-box (ena + ' failed to export') # preferably without the path somehow
}
When I tweaked some add-on code to do something like this I remember hiting following issues:
1. while f3d file saves locally and overrides if file with the same name exists, stl file will most certanly give me an error when trying to save on top of an existing file.
My goal is to click this one button and export as is configuration and I would preffer override action by default.
2. when saving more then one stl consecutively most of the times I get an error while saving the second file. Maybe it need some delay or clear export-manager's buffer??
3. isolate script-step worked as expected, but un-isolate didnt, so at the completion of the script the picture in the ui dramatically changes with different stuff displaying. I would like it to work more like export progress kind of action, so after execution of the script or add-on the assembly to be in the same visibility and isolation states as at the beginning of the script, so the used can hit that export button all day long.
Thanks Everyone
Solved! Go to Solution.