Hi,
I found this great article on CodeStack (https://www.codestack.net/solidworks-ap ... y-to-file/) on how to serialize a solid SOLIDWORKS body into a binary stream, and then save it to a local hard drive as a .dat file.
However, that article does not address on how to restore that file back into SOLIDWORKS (deserialize). In my macro, I need a following workflow:
1. Get solid bodies from an open part document;
2. Create temporary bodies from them;
3. Perform various geometric operations on these temporary bodies;
4. Save these temporary bodies into .dat files;
5. In another session, restore these temporary bodies back into the same (or different) model.
That last bit is what I can't figure out how to do. Any suggestions?
Serializing and deserializing a temporary body
Re: Serializing and deserializing a temporary body
@laukejas , here is the counter-part of the above example: https://www.codestack.net/solidworks-ap ... from-file/. Also this example might be helpful (this stores/restores the body into the file's 3rd party stream): https://www.codestack.net/solidworks-ap ... tore-body/. And here is one of my old blog posts how this can be used for fun: https://blog.codestack.net/solidworks-3d-watermark
Thanks,
Artem
xarial.com - making your CAD better
codestack.net - SOLIDWORKS API macros and tutorials
Artem
xarial.com - making your CAD better
codestack.net - SOLIDWORKS API macros and tutorials
Re: Serializing and deserializing a temporary body
What is the advantage of that over saving it as a parasolid, step or iges?
-
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
I may not have gone where I intended to go, but I think I have ended up where I needed to be. -Douglas Adams
Re: Serializing and deserializing a temporary body
That's amazing, thank you. I have no idea how I missed that on the website...artem wrote: ↑Sun Dec 12, 2021 11:33 pm @laukejas , here is the counter-part of the above example: https://www.codestack.net/solidworks-ap ... from-file/. Also this example might be helpful (this stores/restores the body into the file's 3rd party stream): https://www.codestack.net/solidworks-ap ... tore-body/. And here is one of my old blog posts how this can be used for fun: https://blog.codestack.net/solidworks-3d-watermark
It should be faster (even than parasolid), besides, I'm not even sure if it is possible to save temporary bodies as parasolids... As for step/iges - these are non-native formats for SOLIDWORKS, so it would be slower, less accurate and prone to geometry errors upon re-import.