Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix manual preview button #132

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions commands/commandCreateBin/entry.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
actualDimensionsTableUiState = CommandUiState(CMD_NAME)
actualCompartmentDimensionsUiState = CommandUiState(CMD_NAME)
commandCompartmentsTableUIState: list[CommandUiState] = []
showPreviewManualState = False

# Specify that the command will be promoted to the panel.
IS_PROMOTED = True
Expand Down Expand Up @@ -670,7 +671,7 @@ def command_created(args: adsk.core.CommandCreatedEventArgs):
commandUIState.registerCommandInput(userChangesGroup)
showPreviewCheckboxInput = previewGroup.children.addBoolValueInput(SHOW_PREVIEW_INPUT, 'Show auto update preview (slow)', True, '', False)
commandUIState.registerCommandInput(showPreviewCheckboxInput)
showPreviewManual = previewGroup.children.addBoolValueInput(SHOW_PREVIEW_MANUAL_INPUT, 'Update preview once', False, '', False)
showPreviewManual = previewGroup.children.addBoolValueInput(SHOW_PREVIEW_MANUAL_INPUT, 'Update preview once', False, '', showPreviewManualState)
showPreviewManual.isFullWidth = True
commandUIState.registerCommandInput(showPreviewManual)

Expand All @@ -692,13 +693,19 @@ def command_execute(args: adsk.core.CommandEventArgs):
# This event handler is called when the command needs to compute a new preview in the graphics window.
def command_preview(args: adsk.core.CommandEventArgs):
futil.log(f'{CMD_NAME} Command Preview Event')
global showPreviewManualState
inputs = args.command.commandInputs
if is_all_input_valid(inputs):
showPreview: adsk.core.BoolValueCommandInput = inputs.itemById(SHOW_PREVIEW_INPUT)
showPreviewManual: adsk.core.BoolValueCommandInput = inputs.itemById(SHOW_PREVIEW_MANUAL_INPUT)
if showPreview.value or showPreviewManual.value:
if showPreview.value or (showPreviewManual.value != showPreviewManualState):
if showPreview.value:
futil.log(f'{CMD_NAME} Command Preview Event - generating preview because showPreview.value is {showPreview.value}')
if showPreviewManual.value != showPreviewManualState:
futil.log(f'{CMD_NAME} Command Preview Event - generating preview because showPreviewManual.value is {showPreviewManual.value}')

args.isValidResult = generateBin(args)
showPreviewManual.value = False
showPreviewManualState = showPreviewManual.value
else:
args.executeFailed = True
args.executeFailedMessage = "Some inputs are invalid, unable to generate preview"
Expand Down