From King of Prussia, PA With Love
October 26, 2007
So here is what you missed out on if you were too lazy to weren’t able to attend the SWUGN Technical Summit - Philadelphia, which was held in King of Prussia, PA (right down the road from the city of brotherly love) :
- A chance to win a free pass to SolidWorks World 2008 in San Diego, CA
- A chance to win a 3D Connexion Motion Controller
- A chance to meet Dennis Miller (Susquehanna Valley SolidWorks User Group Leader) in person
If you enjoyed this post, make sure you subscribe to my RSS feed!
GetObject( ) or CreateObject( )? Is there a difference? - Part III
October 11, 2007
At the end of my last post on this topic, I promised you that I would share a “dirty secret” so I guess I now have to come clean. FYI - “Dirty secret” may have been a bit strong but it sounded cool (at least to me). Anyways, there is a difference between how SolidWorks handles CreateObject( ) and how MS Office products handle CreateObject( ). This is something to be aware of when automating across applications.
What is the difference? In a nutshell, calling CreateObject( ) on an MS Office application interface will always create a new instance of the application and then return a handle to that instance. Calling CreateObject( ) on the SldWorks.Application interface will only create a new instance of SolidWorks if one isn’t already running. This basically ensures that only one instance of SolidWorks at a time is ever automated by your Macro. This is a basic coding pattern called “the Singleton” and it prevents untold suffering and countless tears. SolidWorks is so kind to us and many of us didn’t even know it.
Below are two Macros Read more
If you enjoyed this post, make sure you subscribe to my RSS feed!
I couldn’t resist…”The Code To Ruin”
October 9, 2007
Although I like the old “Daily WTF” better than the newly named “Worse Than Failure,” it is still a great place to go in order to feel better about your projects.
The site’s latest post, “Avoiding Development Disasters,” discusses the now infamous FBI software fiasco known as Virtual Case File and is a pretty good read. For those short on time, I think their picture, “The Code To Ruin,” says it all.
If you enjoyed this post, make sure you subscribe to my RSS feed!
GetObject( ) or CreateObject( )? Is there a difference? - Part II
October 8, 2007
Last time I explained how the SolidWorks application object behaves differently depending on whether it is instantiated via CreateObject( ) or GetObject( ). So now you are probably thinking, “That’s it? That was too easy.” Well, I don’t want to be one to disappoint so I will let you in on the rest of the story including a dirty little secret.
So what else is there? The GetObject( ) call has another trick up its sleeve that I didn’t discuss last time. Taking a look at its Intellisense signature provides a clue as to what this is.
In the method signature you actually see two parameters, Read more
If you enjoyed this post, make sure you subscribe to my RSS feed!
GetObject( ) or CreateObject( )? Is there a difference? - Part I
October 4, 2007
Disclaimer: 99.9% of all the API programming I do these days is in .NET so for the times that I do answer a question incorrectly, 80% of the time it is a VBA (Visual Basic for Applications) question. Since most people start with VBA before they move on to .NET, however, I decided to cover this topic for VBA.
Set swApp = CreateObject(”SldWorks.Application”)
Almost all SolidWorks Macros start out with that same, famous line of code. In fact, whenever you record a Macro in SolidWorks, the SolidWorks Macro Recorder is kind enough to fill that line in for you. What does it really mean, though? And why do a few Macros begin instead with this line of code:
Set swApp = GetObject(,”SldWorks.Application”)
If you enjoyed this post, make sure you subscribe to my RSS feed!




