Is it possible to cache a model in an addin?

Is it possible to cache a model in an addin?

ababhirupbose21
Explorer Explorer
628 Views
4 Replies
Message 1 of 5

Is it possible to cache a model in an addin?

ababhirupbose21
Explorer
Explorer

For the optimization of my add-in, I am wondering if I could save a .f3d file in cache so that the add-in can work on the file once it is reopened, instead of needing to import it once again. Even a solution to just save the BRepBody is also welcome.

0 Likes
Accepted solutions (1)
629 Views
4 Replies
Replies (4)
Message 2 of 5

tykapl.breuil
Advocate
Advocate

There are tools to create a body directly through the API (see here), maybe it's possible to extract the information from an existing body to use it to recreate it. Not sure if it works as I've never used it but it's worth a try.

0 Likes
Message 3 of 5

BrianEkins
Mentor
Mentor

I have some ideas but it's difficult to give an answer without more information about what you're trying to do.  There would be different ways to approach it depending on the specific problem you're trying to solve.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
Message 4 of 5

ababhirupbose21
Explorer
Explorer

Hello, Thanks for your replies. What I am trying to do is to compare 2 models for similarity. One of them is the one open in the active document and the other will be the control .f3d file against which comparison will take place. Right now, I am having to import this file each and every time I want to compare using the code attached. What I want the addin to do is to somehow save the model for repeatable comparisons without needing to import it again and again.

0 Likes
Message 5 of 5

BrianEkins
Mentor
Mentor
Accepted solution

It's still a bit unclear what the workflow is.  Is this all happening in a single session of Fusion or do you expect the cache to be available in different sessions?  Also, what in the design are you using to compare the two models; are you just comparing geometry, or are you also looking at features and other information like sketches and construction geometry?

 

If it's in a single session, then you should only need to read it once and then that document will be available for the remainder of the session and can be used for multiple comparisons. If it's being used in multiple sessions, you'll have to cache the data to disk somehow and an f3d file is the most complete option. It gives you access to everything in the design. If you only care about geometry, it will probably be more efficient to save the model as a .smt file. You can create that either in the UI or using the ExportManager. Instead of using the ImportManager to read it in, you can use the createFromFile method of the TemporaryBRepManager object. This will create the BRepBody in-memory and you can use that do to your comparison.

---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com