Community
Fusion API and Scripts
Got a new add-in to share? Need something specialized to be scripted? Ask questions or share what you’ve discovered with the community.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Custom Graphics slows down document even after being deleted

6 REPLIES 6
Reply
Message 1 of 7
allan4EEKW
261 Views, 6 Replies

Custom Graphics slows down document even after being deleted

I'm working on an add-in for the Manufacture workspace. Part of it involves drawing custom graphics to the viewport for every setup in the document- of which there might be several. These graphics are tied to geometry on the setups' models and have to be updated when the model changes. The only clear way of updating the graphics is by deleting the CustomGraphicsGroups and re-adding them (one for each setup). However, I've noticed that each time I do this, the time it takes for the graphics to draw increases (say 2 seconds the first time, 4 the second time, 6 the third time, etc.). I've checked to make sure I'm actually deleting the CustomGraphicsGroups and it seems I am, but my hunch is that even after being "deleted" they are still bogging down the document (the draw-time resets when closing and re-opening the document). After enough iterations it's possible for a graphical update (with lots of curves) to take 30+ seconds.

 

Has anyone else had this problem? At first I thought it was user error but the more I've investigated it the more I suspect it might be a Fusion bug.

Tags (3)
Labels (3)
6 REPLIES 6
Message 2 of 7
j4n.vokurka
in reply to: allan4EEKW

Hello,

maybe just a stupid question but are you properly updating the collection of setups before creating custom graphics each time? I would expect there to be unhandled memory that is stacking either on your side or the side of Fusion but without any sample code it is hard to say 🙂 

I have used custom graphics before and I have not encountered this error.

 

Jan

Message 3 of 7
allan4EEKW
in reply to: allan4EEKW

Hey Jan,

 

I believe I am but maybe I am missing some fundamental understanding of Fusion/Python (fairly new to Python).

 

Either way I created a sample script to demonstrate the problem. It creates a custom graphics group for each BRep in the document and draws red curves to its edges (use caution when running on a document with lots of geometry).

 

The initial draw time (happens in CommandCreated) is what balloons out of control, meanwhile the button-controlled-refresh time remains constant.

 

It could definitely be something I'm doing wrong, but I have no idea what it is. Anyways if you could take a look I'd appreciate it.

 

Allan

Message 4 of 7
allan4EEKW
in reply to: allan4EEKW

Forgot to mention this script is for the Design workspace.
Message 5 of 7
allan4EEKW
in reply to: j4n.vokurka

I think I replied to my post instead or your response by mistake (new to this forum). Adding this so you get dinged.

Message 6 of 7
j4n.vokurka
in reply to: allan4EEKW

Hello,

sorry to keep you waiting. Quite busy these days 🙂

I have tested the script you have sent and I can see no weird stuff going on. Every time custom graphics are created the time is more or less the same. Certainly there is no gradual increase visible. 

j4nvokurka_1-1711644952845.png


Either I don't understand your issue well enough or the problem has not manifested itself in this script. Even though I consider it unlikely there might other differences which cause the problem on your side. What os do you run on?

Message 7 of 7
allan4EEKW
in reply to: j4n.vokurka

Thanks for taking the time to review it.

 

Have you tried running the script multiple times back-to-back? That's where I'm getting my issue with the load time.

I hope you can reproduce the issue, otherwise I might have bigger problems.

 

My specs are:

Windows 10 Pro V 22H2
Processor Intel(R) Core(TM) i9-9900K CPU @ 3.60GHz 3.60 GHz
Installed RAM 64.0 GB

 

Anyways I actually think I'm slowly figuring out the problem. I think it has to do with where I'm creating the graphics. Within a command, it seems it should only be within executePreview or execute. In both my sample script and my larger Add-In I'm creating graphics in commandCreated and commandInputChanged.

 

It was confusing me for a long time why many of the custom graphics samples I was seeing had no process for deleting them. Now I see that's something Fusion handles when the graphics are created during a preview event (so that if the command is canceled the graphics -and probably other document updates like geometry creation- can be "undone".)

 

I don't know how the graphics back-end works in Fusion but if there is an "undo" then I imagine there are something like multiple graphics objects who's existence/visibility are actively managed by Fusion depending on context. Maybe adding graphics during commandCreated/inputChanged buggers the system because it adds them to an un-anticipated graphical instance?

 

I'm still wrapping my head around all of it but I think I'm starting to understand. I'll update the thread if I get it fixed.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report