AnsweredAssumed Answered

API/Macro to save assembly as eDrawings file

Question asked by Xavier Rodríguez Nieto on Apr 12, 2018

I want to create a macro to save an assembly as an eDrawings file (.EASM).

 

I started with the "SaveAs" method from the "IModelDocExtension", as it worked OK for me when exporting to PDF or DWG, but I had some issues when trying to export assemblies with in-context references (pop-up windows to save components with in-context references). After digging a little in the documentation I found this in the remarks of the "SaveAs" method:

 

"Do not use ModelDocExtension::SaveAs to copy assemblies, drawings, or parts with in-context references. Instead, use ISldWorks::CopyDocument or ISldWorks::ICopyDocument."

 

First problem is that, for running these two methods, there can be no documents open, as stated again in the remarks. Apart from that, I tried to run the 2 examples shown in the documentation ("Copy Document (VBA)" and "Copy Document and Its Dependencies (VBA)"), but none of them worked OK for me:

 

· "Copy Document (VBA)": It generates the EASM file property (no errors returned), but when I open the file with eDrawings, the assembly is empty (no component shown).

· "Copy Document and Its Dependencies (VBA)": First, this example generates a file for every single component, and this is not what I want, I want only the eDrawings file for an specific assembly. Apart from that, I have the same problem that with the first example, the EASM file for the assembly is well generated, but when I open it in eDrawings it's empty.

 

Any help? I'm sure that somebody has done something similar, but after some hours of searching, I haven't find anything.

 

Thanks in advance

Outcomes