Using solidworks 2006. Record a macro (part elongation). undo change (recorded) or load assembly again (or even another assembly. Try to invoke macro. no change to part. Seems to me this should work without much ado. I am in the process of re-installing SW now. In the meantime, any ideas as to how/why it is not working for me?
You have to understand that macro recordings are not one for one keystroke recordings. Way back in SW95 they were, but no more. In addition, not all GUI functionality is possible in a macro.
When you say part elongation what are you doing to elongate the part?
Recording a macro will capture the commands you issue, but you have to remember that it's possible that it will only work again if ALL other variables are kept the same the next time you run the macro. For example, changing the length on a part should be easy, but may not work if you change window size, view orientation, part name, etc. when you run the macro the next time.
Recording macros are a great way to start an API project, and also helpful if you can't figure out a certain command. I have never ever simply recorded a macro without editing it heavily after the fact. Of course this take a bit of API knowledge.
I always keep a "temp.swp" macro which I use to record new stuff to (overwrites it all the time) so I can use the recorded code later.
TOP hit the issue right on the head. Not all commands are reproducible in VBA. Most of the time, you have to replace the recorded one with a valid call.
Taking a pin and enlongating the shaft by changing it's value. Tried some examples of macros off the web, but they also did not work. I don't mind programming (have a lot of VB and other expereince), prehaps I have had better APIs to work from in past....
'
****************************************************************************** ' C:\DOCUME~1\KELLNERP\LOCALS~1\Temp\swx132\Macro1.swb - macro recorded on 04/10/06 by kellnerp ' ' REQUIRES A NEW EMPTY PART BEING OPEN ' '
****************************************************************************** Dim swApp As Object Dim Part As Object Dim boolstatus As Boolean Dim longstatus As Long, longwarnings As Long Dim FeatureData As Object Dim Feature As Object Dim Component As Object Dim ANNOTATION As Object 'HAD TO ADD THIS LINE BECAUSE SW FORGOT, SEE OPTION EXPLICIT
Heh - so true. The Macro recorder is really a POS, but once you trudge your way through a few basic macros (RTFM), it's not hard to figure out what to do to make the macros work.
Best advice would be to find someone with a macro similar to what you need (that works of course), and use it as a basis for your program.
I would say that the macro recorder doesn't come up to customer expectations. The vast majority of SW users don't know much about VB and much less about object oriented programming. The API does not capture many useful and important GUI commands. And, as in this example, it misses something very simple. For all that it is much better than, say , SolidEdge which has no macro recorder at all. And it is helpful for getting started. For the average user something that captured keystrokes would probably be more helpful, but on the whole the macro/API has been quite usefull to me even with its steep learning curve.
PolyTech Forum website is not affiliated with any of the manufacturers or service providers discussed here.
All logos and trade names are the property of their respective owners.