I have a macro that exports various filetypes. Below is a snippet of code.
If optSTEP Then<br> If DocType = swDocDRAWING Then<br> swRefModel.Extension.SaveAs filename + ".STEP", 0, 0, Nothing, Errors, Warnings<br> Else<br> swDocExt.SaveAs filename + ".STEP", 0, 0, Nothing, Errors, Warnings<br> End If<br> End If<br><br> If optSTL Then<br> If DocType = swDocDRAWING Then<br> swRefModel.Extension.SaveAs filename + ".STL", 0, 0, Nothing, Errors, Warnings<br> Else<br> swDocExt.SaveAs filename + ".STL", 0, 0, Nothing, Errors, Warnings<br> End If<br> End If<span class="line-numbers-rows"><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span><span></span></span>Line 11 causes SW to crash, but line 3 runs fine. Notice both if-blocks do basically the same thing. If the open document is a drawing, swRefModel (referenced from the drawing's default view) is used to create either an STL or STEP file. If it's a part/assembly then swDocExt is used to do the same. But for some reason exporting an STL with a drawing open crashes SW every time (both 2016 and 2019). All other filetypes I've tried (step, igs, edrw) work fine. With a part/assembly open the STL exports fine. For the time being I've just disabled the STL option if the macro is run with a drawing. Any insight is appreciated.
