Fusioin delete created sketch if it's in event

Fusioin delete created sketch if it's in event

maurizio_manzi
Advocate Advocate
519 Views
8 Replies
Message 1 of 9

Fusioin delete created sketch if it's in event

maurizio_manzi
Advocate
Advocate

Hello,
Fusion is deleteting the sketch created with the function  drawVector() because it's called in the event:

class MyCommandInputChangedHandler(adsk.core.InputChangedEventHandler😞
If it's called in run, the sketch will be not deleted.
Best regards
Maurizio

 

0 Likes
Accepted solutions (1)
520 Views
8 Replies
Replies (8)
Message 2 of 9

kandennti
Mentor
Mentor

Hi @maurizio_manzi -San.

I do not believe that the CAD side should be manipulated with the InputChanged event, but only with the elements in the dialog.

 

If you want to leave the CAD side manipulated, the only way is to use the execute event.
I think it is better to use the executePreview event to let the user see it in advance.

 

I feel that each event has its own role to play, rather than simply firing at different times.

0 Likes
Message 3 of 9

maurizio_manzi
Advocate
Advocate

Hello,

The point is that the user clicks the button, and the sketch appears as a preview for the vector. When they later close the window with OK, the Add-In should delete the sketch again.

That’s not a problem in itself. However, the sketch should appear while the settings window is still open and not only when it is closed with OK.

It seems to me like a software bug. If the sketch were not allowed in the event, there should be an error message.

Why is the sketch created and immediately deleted? That makes absolutely no sense.

Best regards
Maurizio

 

0 Likes
Message 4 of 9

kandennti
Mentor
Mentor

@maurizio_manzi -San.

 

That move is not a bug. It is a mechanism called a transaction at work.
If the movement is such that it remains, some people will have trouble with add-ins and scripts that were created with an understanding of how to work with events, because they will not work correctly.

 

I don't understand what you are trying to do, but if you have something you want to display temporarily, you might want to display it in the executePreview event and let the final shape be handled in the execute event.

If it is the executePreview event, it will continue to be displayed until the next event fires. If it is no longer needed, it will disappear on its own.

0 Likes
Message 5 of 9

maurizio_manzi
Advocate
Advocate

hello,
I want to see the sketch as a preview before the window closes so that the user can change values if needed.
I tried using MyCommandExecutePreviewHandler, but it seems completely useless to me because even if I set eventArgs.isValidResult = False there, MyExecuteHandler still gets executed. And than is the windows closed..
Best regards
Maurizio

0 Likes
Message 6 of 9

Jorge_Jaramillo
Collaborator
Collaborator

hi,

 

If you want the ExecuteEvent not being fired you can do either (or both):

1) Don't register the execute event at all

2) In the ExecutePreview event you need to set isValidResult to TRUE once make the changes to the model according with the user selections.

 

I'd recommend reading this paragraph from https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-3922697A-7BF1-4799-9A5B-C8539DF57051 about the ExecutePreview Event:

Jorge_Jaramillo_0-1743174975206.png

 

It worked for me in other implementations.  And also think about some Fusion's command like the Extrude command, which let you see the result even before you choose the OK.

 

Regards,

Jorge Jaramillo

 

Message 7 of 9

maurizio_manzi
Advocate
Advocate

Hello,
Thank you for your detailed response. What I absolutely don’t understand is this: If I write eventArgs.isValidResult = True in MyCommandExecutePreviewHandler, then MyExecuteHandler gets executed. If I write eventArgs.isValidResult = False in MyCommandExecutePreviewHandler, MyExecuteHandler still gets executed.
And in both cases, MyExecuteHandler is executed, and the window is closed.

So what’s the point of MyCommandExecutePreviewHandler if I can’t use it to prevent MyExecuteHandler from being executed under certain circumstances?
Best regards
Maurizio

0 Likes
Message 8 of 9

kandennti
Mentor
Mentor
Accepted solution

@maurizio_manzi -San.

If eventArgs.isValidResult=true, the command will exit with whatever was created in the preview; it should not be calling the execute event.

 

The ExecutePreview event fires when the OK button is ready to be pressed.
The OK button can only be controlled by the ValidateInputsEventArgs.areInputsValid property of the ValidateInputs event.
https://help.autodesk.com/view/fusion360/ENU/?guid=GUID-dcf60135-6fcf-4ca5-bd53-b9df4cbea341 

 

0 Likes
Message 9 of 9

maurizio_manzi
Advocate
Advocate

Thank you very much

0 Likes