I have a macro that exports various filetypes. Below is a snippet of code.
If optSTEP Then
If DocType = swDocDRAWING Then
swRefModel.Extension.SaveAs filename + ".STEP", 0, 0, Nothing, Errors, Warnings
Else
swDocExt.SaveAs filename + ".STEP", 0, 0, Nothing, Errors, Warnings
End If
End If
If optSTL Then
If DocType = swDocDRAWING Then
swRefModel.Extension.SaveAs filename + ".STL", 0, 0, Nothing, Errors, Warnings
Else
swDocExt.SaveAs filename + ".STL", 0, 0, Nothing, Errors, Warnings
End If
End If
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.