Skip to content

Commit 1a6d98f

Browse files
committed
fix: added a specific error when timeline feature is disabled
1 parent a11077a commit 1a6d98f

File tree

3 files changed

+28
-5
lines changed

3 files changed

+28
-5
lines changed

commands/commandCreateBaseplate/entry.py

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from ...lib.gridfinityUtils import const
1313
from .inputState import InputState
1414
from ...lib.ui.commandUiState import CommandUiState
15+
from ...lib.ui.unsupportedDesignTypeException import UnsupportedDesignTypeException
1516

1617
app = adsk.core.Application.get()
1718
ui = app.userInterface
@@ -366,6 +367,8 @@ def generateBaseplate(args: adsk.core.CommandEventArgs):
366367

367368
try:
368369
des = adsk.fusion.Design.cast(app.activeProduct)
370+
if des.designType == 0:
371+
raise UnsupportedDesignTypeException('Timeline must be enabled for the generator to work, projects with disabled design history currently are not supported')
369372
root = adsk.fusion.Component.cast(des.rootComponent)
370373
baseplateName = 'Gridfinity baseplate {}x{}'.format(int(inputsState.plateLength), int(inputsState.plateWidth))
371374

@@ -398,12 +401,19 @@ def generateBaseplate(args: adsk.core.CommandEventArgs):
398401
baseplateBody = createGridfinityBaseplate(baseplateGeneratorInput, gridfinityBaseplateComponent)
399402
baseplateBody.name = baseplateName
400403

401-
# group features in timeline
402-
plateGroup = des.timeline.timelineGroups.add(newCmpOcc.timelineObject.index, newCmpOcc.timelineObject.index + gridfinityBaseplateComponent.features.count + gridfinityBaseplateComponent.constructionPlanes.count + gridfinityBaseplateComponent.sketches.count)
403-
plateGroup.name = baseplateName
404-
except:
404+
if des.designType == 1:
405+
# group features in timeline
406+
plateGroup = des.timeline.timelineGroups.add(newCmpOcc.timelineObject.index, newCmpOcc.timelineObject.index + gridfinityBaseplateComponent.features.count + gridfinityBaseplateComponent.constructionPlanes.count + gridfinityBaseplateComponent.sketches.count)
407+
plateGroup.name = baseplateName
408+
except UnsupportedDesignTypeException as err:
409+
args.executeFailed = True
410+
args.executeFailedMessage = 'Design type is unsupported. Projects with disabled design history are unsupported, please enable timeline feature to proceed.'
411+
return False
412+
except Exception as err:
405413
args.executeFailed = True
406414
args.executeFailedMessage = getErrorMessage()
415+
futil.log(f'{CMD_NAME} Error occurred, {err}, {getErrorMessage()}')
416+
return False
407417

408418
def initUiState():
409419
global uiState

commands/commandCreateBin/entry.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
import json
55
from dataclasses import asdict
66

7+
78
from ...lib import configUtils
89
from ...lib import fusion360utils as futil
910
from ... import config
@@ -21,6 +22,8 @@
2122
from ...lib.gridfinityUtils.binBodyTabGenerator import createGridfinityBinBodyTab
2223
from .inputState import InputState, CompartmentTableRow
2324
from .staticInputCache import StaticInputCache
25+
from ...lib.ui.commandUiState import CommandUiState
26+
from ...lib.ui.unsupportedDesignTypeException import UnsupportedDesignTypeException
2427

2528
app = adsk.core.Application.get()
2629
ui = app.userInterface
@@ -46,6 +49,7 @@
4649
ICON_FOLDER = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'resources', '')
4750

4851
CONFIG_FOLDER_PATH = os.path.join(os.path.dirname(os.path.abspath(__file__)), 'commandConfig')
52+
UI_INPUT_DEFAULTS_CONFIG_PATH = os.path.join(CONFIG_FOLDER_PATH, "ui_input_defaults.json")
4953

5054
# Local list of event handlers used to maintain a reference so
5155
# they are not released and garbage collected.
@@ -856,6 +860,8 @@ def generateBin(args: adsk.core.CommandEventArgs):
856860
# Do something interesting
857861
try:
858862
des = adsk.fusion.Design.cast(app.activeProduct)
863+
if des.designType == 0:
864+
raise UnsupportedDesignTypeException('Timeline must be enabled for the generator to work, projects with disabled design history currently are not supported')
859865
root = adsk.fusion.Component.cast(des.rootComponent)
860866
xyClearance = xy_clearance.value
861867
binName = 'Gridfinity bin {}x{}x{}'.format(int(bin_length.value), int(bin_width.value), int(bin_height.value))
@@ -1006,8 +1012,13 @@ def generateBin(args: adsk.core.CommandEventArgs):
10061012
# group features in timeline
10071013
binGroup = des.timeline.timelineGroups.add(newCmpOcc.timelineObject.index, newCmpOcc.timelineObject.index + gridfinityBinComponent.features.count + gridfinityBinComponent.constructionPlanes.count + gridfinityBinComponent.sketches.count)
10081014
binGroup.name = binName
1009-
except:
1015+
except UnsupportedDesignTypeException as err:
1016+
args.executeFailed = True
1017+
args.executeFailedMessage = 'Design type is unsupported. Projects with disabled design history are unsupported, please enable timeline feature to proceed.'
1018+
return False
1019+
except Exception as err:
10101020
args.executeFailed = True
10111021
args.executeFailedMessage = getErrorMessage()
1022+
futil.log(f'{CMD_NAME} Error occurred, {err}, {getErrorMessage()}')
10121023
return False
10131024
return True
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
class UnsupportedDesignTypeException(Exception):
2+
pass

0 commit comments

Comments
 (0)