Extensible CAD Technologies
SolidWorks and PDMWorks Enterprise Development Blog

Archive for December, 2007

How To Destroy References To SolidWorks From Managed Code

Posted by Jeff Cope at 20 December, 2007, 10:48 am
0

 

Memory management in the COM world is a lot more straightforward in the COM world than it is in the .NET world.  Destroying COM references from .NET applications typically includes trial and error, calls to mysterious APIs, prayer and in the end, frustration.  It always reminds me of tying to kill a vampire, werewolf or some other bloodsucking, mythical creature that just won’t die.  It is because of this that my heart warmed with joy when I saw that some kind soul over at SolidWorks wrote a post to once and for all clarify how to destroy references to SolidWorks’  COM objects.

Tech Tip From SolidWorks On Destroying References To Unmanaged (i.e. COM) Components

 We have all heard about the promised land of .NET where you don’t have to worry about memory management.  The garbage collector handles all of the memory management for you.  You just instantiate your objects, use them and then forget them.  Santa Clause The .NET Garbage Collector determines when the objects are no longer needed and then destroys them and reallocates the memory.  Anyone who does API programming with SolidWorks in .NET either knows or should know that this is not the case for unmanaged (i.e.  COM) components (e.g. the SolidWorks class library used for interfacing with SolidWorks).  Some CAD systems (e.g. Unigraphics) have implemented a .NET API interface but SolidWorks still uses a COM  API interface.  This means that SolidWorks API developers using .NET must destroy SolidWorks objects “they d@mn self.” 

And remember…

…Even a man who is pure in heart
and says his prayers by night
may become a wolf when the wolfbane blooms
and the autumn moon is bright.

If you enjoyed this post, make sure you subscribe to my RSS feed!

Category : .NET | SolidWorks API

Development Tools

Posted by Jeff Cope at 17 December, 2007, 5:55 pm
1

Every developer has a set of tools, books and websites that they rely upon for help in their quest to build quality software.  I thought there might be some folks out there doing SolidWorks API programming/development that would appreciate finding out tools other developers are using.  Hence, this post.

Below is a partial list of some of the tools that I rely on.  I hope you find something that is useful to you.  You may also have some tools that you rely upon that might benefit the rest of us.  If so, then let us know with a comment.  I will be posting a list of books and websites that I use also.

continue

If you enjoyed this post, make sure you subscribe to my RSS feed!

Category : General

Manipulating Filepaths In .NET

Posted by Jeff Cope at 12 December, 2007, 2:32 am
1

If I had a Dollar for every time I wrote a few lines of code to change a file extension on a path (e.g. MyPart.slddrw to MyPart.pdf) or to build a filepath from a folderpath and a filename then I would probably have a few thousand dollars.  In other words, enough to buy a loaf of bread in any developed country outside the US.  (Note to self:  Stay on topic and don’t get distracted by a rant on the pathetic state of the dollar)

 Anyways, my colleague Evan Basalik showed me a very easy way to do this with minimal code.  Even though I thought I had been all over the System.IO namespace, I never checked out the System.IO.Path section.  Here are some of the cool functions you will find in there:

continue

If you enjoyed this post, make sure you subscribe to my RSS feed!

Category : .NET
Generate First-Article Inspection Reports From TIF, PDF and CAD Drawing Files With InspectionXpert. Generate First-Article Inspection Reports From SolidWorks Drawing Files With InspectionXpert.