AnsweredAssumed Answered

Is SOLIDWORKS' macro recording really this bad?

Question asked by James Veale on Oct 4, 2019
Latest reply on Oct 4, 2019 by Josh Brady

I just recorded a macro in the hopes of editting it into a something that will loop over the task in mind for numerous configurations of a part (to save me fiddling around with understanding the API a bit and trying to get around a strange thing I had with API calls to SaveAs for a DXF generating a bunch of extra centrelines on top of my part).


The macro it generated doesn't even compile, however. (Generated macro copied into a text file for ease of comparison and attached here as Macro1.txt)


The issue I assume is that a reference to a view name hasn't been generated as a string (SOLIDWORKS bug?) aka


instead of


So here's the same macro 'fixed' (Macro2.txt).



However, it still won't run to completion - generating an error (something along the lines of no method for this object) on the line 

Set myView = Part.CreateDrawViewFromModelView3("C:\Users\james.veale\Desktop\MeshMaster.SLDPRT", "*Current", 0, 0, 0)

near the bottom of the macro.


This makes little sense to me, I'm running on the same software on the same PC mere seconds after recording the macro in the first place. Can SOLIDWORKS' macro recording implementation be just this bad, or am I missing something?


Either way, if anyone can help me patch up the macro recorder's sloppy work into something that actually runs, I'd be very thankful! (The macro should record me selecting a configuration of the SLDPRT that is open, and using SaveAs to generate a dxf of the *Current view of the part. Once this actually works I'll put it inside a loop which does this for every configuration of the part - which will be easy by comparison.)