<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Extensible By Design &#187; Extensible By Design</title>
	<atom:link href="http://extensiblecad.com/words/category/solidworks/solidworks-api/feed/" rel="self" type="application/rss+xml" />
	<link>http://extensiblecad.com/words</link>
	<description>SolidWorks and PDMWorks Enterprise Development Blog</description>
	<lastBuildDate>Mon, 02 Feb 2009 09:02:20 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>SolidWorks API Presentation &#8211; Beginner&#8217;s Guide To The API</title>
		<link>http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/</link>
		<comments>http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/#comments</comments>
		<pubDate>Wed, 17 Dec 2008 17:40:11 +0000</pubDate>
		<dc:creator>Jeff Cope</dc:creator>
				<category><![CDATA[CAD]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[SolidWorks API]]></category>

		<guid isPermaLink="false">http://extensiblecad.com/words/?p=150</guid>
		<description><![CDATA[From time to time I do presentations on the SolidWorks API and one that gets requested fairly often is the Beginner&#8217;s Guide To The API.  I just presented this in Roanoke, VA at the Blue Ridge SolidWorks User&#8217;s Group headed up by Jeremy Marks.  They were a good bunch of guys (although there was a [...]]]></description>
			<content:encoded><![CDATA[<p>From time to time I do presentations on the SolidWorks API and one that gets requested fairly often is the Beginner&#8217;s Guide To The API.  I just presented this in Roanoke, VA at the Blue Ridge SolidWorks User&#8217;s Group headed up by Jeremy Marks.  They were a good bunch of guys (although there was a University of North Carolina fan in attendance) and it seems like a well-run group.  However, after risking my life to get there by driving through what seemed the rain-storm of the century on unfamiliar mountain highways with almost no visibility I have decided that in the future it might be safer for me to simply make the presentation available on my blog : )</p>
<p><a href="http://extensiblecad.com/words/wp-content/uploads/2008/12/beginners-guide-to-the-api.pdf">beginners-guide-to-the-api</a></p>
<p>Also, the SolidWorks Autonumbering Macro (w/ MS Access Database) that I usually show has been written up for ConnectPress with a link to download the Macro and Database.  You can view that article here:</p>
<p><a href="http://www.solidworkscommunity.com/feature_full.php?cpfeatureid=32314">http://www.solidworkscommunity.com/feature_full.php?cpfeatureid=32314</a></p>
	<p></p>
	<hr noshade style="margin:0;height:1px" />
	<small><p>&copy; Jeff Cope for <a href="http://extensiblecad.com/words">Extensible By Design</a>, 2008. |
	<a href="http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/">Permalink</a> |
	<a href="http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/#comments">One comment</a> |
	Add to
	<a href="http://del.icio.us/post?url=http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/&amp;title=SolidWorks API Presentation &#8211; Beginner&#8217;s Guide To The API"><img src="http://yoursite.com/images/icons/delicious.gif" border="0"> del.icio.us</a>
	<a href="http://www.digg.com/submit"><img src="http://yoursite.com/images/digg.gif" border="0"> digg</a><br/>
	Who's linking ?
	<a href="http://www.technorati.com/search/http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/" title="Search on Technorati"><img src="http://yoursite.com/images/icons/technorati.gif" border="0">Technorati</a>
	<a href="http://www.blogpulse.com/search?query=http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/" title="Search on Blogpulse"><img src="http://yoursite.com/images/icons/blogpulse.gif" border="0">BlogPulse</a>
	<a href="http://google.com/blogsearch?q=http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/" title="Search on Google Blog Search"><img src="http://yoursite.com/images/icons/google.gif" border="0">Google</a><br/>
	Want more on these topics ? Browse the archive of posts filed under <a href="http://extensiblecad.com/words/category/cad/" title="View all posts in CAD" rel="category tag">CAD</a>, <a href="http://extensiblecad.com/words/category/macros/" title="View all posts in Macros" rel="category tag">Macros</a>, <a href="http://extensiblecad.com/words/category/solidworks/" title="View all posts in SolidWorks" rel="category tag">SolidWorks</a>, <a href="http://extensiblecad.com/words/category/solidworks/solidworks-api/" title="View all posts in SolidWorks API" rel="category tag">SolidWorks API</a>.</small></p>
<p>Copyright 2007 <a href=http://extensiblecad.com/words>Extensible By Design.</a>  All rights reserved.</p>]]></content:encoded>
			<wfw:commentRss>http://extensiblecad.com/words/2008/12/17/solidworks-api-presentation-beginners-guide-to-the-api/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Setting Up and Troubleshooting Your SolidWorks Add-in Development Environment.  Take off, eh&#8230;</title>
		<link>http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/</link>
		<comments>http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/#comments</comments>
		<pubDate>Thu, 12 Jun 2008 05:31:31 +0000</pubDate>
		<dc:creator>Jeff Cope</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[SolidWorks API]]></category>

		<guid isPermaLink="false">http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/</guid>
		<description><![CDATA[  Writing Add-ins in SolidWorks can be tricky stuff as it involves class libraries, COM, interfaces, etc&#8230;  It can be argued whether it is easier or harder in .NET (ease of use of .NET versus pain in the rear of COM Interop) but your good friends at SolidWorks set out to make it easy on [...]]]></description>
			<content:encoded><![CDATA[<p> <img border="0" vspace="15" width="450" src="http://extensiblecad.com/words/wp-content/uploads/2007/12/mckenzie_bros.jpg" hspace="15" height="348" /></p>
<p>Writing Add-ins in SolidWorks can be tricky stuff as it involves class libraries, COM, interfaces, etc&#8230;  It can be argued whether it is easier or harder in .NET (ease of use of .NET versus pain in the rear of COM Interop) but your good friends at SolidWorks set out to make it easy on all of us by creating Visual Studio templates for quickly creating SolidWorks Add-ins.  <span id="more-85"></span>The templates are packaged with the SolidWorks API SDK, support VB and C# and are analagous to having a SolidWorks part template that already has some geometry in it, custom properties, material assigned, etc&#8230;  When it was introduced back in the day, it was a Godsend.  It does have its issues from time to time though.  For some reason, I have had trouble deploying both on SolidWorks 2007 and 2008.  The SolidWorks API SDK installer runs without errors but when I attempt to create a new SolidWorks Add-in, I see this unfriendly message:</p>
<p> <img border="0" vspace="10" align="middle" width="783" src="http://extensiblecad.com/words/wp-content/uploads/2008/06/solidworks-developmentenvironmentthree.png" hspace="10" alt="SolidWorks Add-in Template Error" height="142" /></p>
<p>The I have spoken to a few other developers and concluded that I am not the only one so I decided to write a post on it.  Besides, I go through this everytime I have to reinstall SolidWorks, which is just often enough to be a real pain but not quite often enough for me to ever remember the steps to fix the issue.  I should admit then I am writing this as much for myself as I am for you.  Here goes&#8230;</p>
<p> The Cause:</p>
<p>Based on the error message, you might get the impression that this is a trust or security issue.  That might lead you down a path of signing the dll with a strong name, configuring .NET security policy on your machine, etc&#8230; (i.e. the path to frustration).  To find the real cause, we must examine the Global Assembly Cache, GAC, to take a look at this SolidWorksTools dll file.  The GAC is where shared .NET assemblies are placed so that they can be made available to other applications.  On Windows XP, the GAC is located at &#8220;C:Windows\assemblies\&#8221;.  Taking a look at the GAC, we see that it contains a different version of the SolidWorksTools dll file than that which is expected by the SolidWorks Add-in Template for Visual Studio.  The version in the GAC is version 2.0.0.0 and not version 1.0.0.1, which is what the SolidWorks Add-in Template for Visual Studio is looking for.</p>
<p> <img border="0" vspace="10" align="middle" width="1014" src="http://extensiblecad.com/words/wp-content/uploads/2008/06/solidworks-developmentenvironmentone.png" hspace="10" height="724" /></p>
<p> If we take a look at the template itself, then we can see where the version is specified for the SolidWorks Add-in Template for Visual Studio.  FYI, the template is contained in a zip file (SWVBAddin.zip for Visual Basic) which in turn is contained in the &#8220;&#8230;Templates\Project Templates\&lt;Visual Basic or Visual C#&gt;&#8221; folder of your Visual Studio 2005 directory.  Note:  I have Visual Studio 2008 but it is still in the box so I&#8217;ll let you know once I try it if the templates go in the same place. </p>
<p><img border="0" vspace="15" width="844" src="http://extensiblecad.com/words/wp-content/uploads/2008/06/solidworks-developmentenvironmenteleven.png" hspace="15" alt="SWAddin.zip file containing SolidWorks Add-in Template" height="399" /></p>
<p>The zip file contains various bitmaps, icons, classes and modules as you would expect to see in an Add-in but it also a file called VBAddin.vstemplate which is a Visual Studio template file.  Once you open it, you see that indeed a different version of the SolidWorksTools dll file has been specified than the one which is installed in the GAC.  .</p>
<p> <img border="0" vspace="15" align="middle" width="870" src="http://extensiblecad.com/words/wp-content/uploads/2008/06/solidworks-developmentenvironmentfour.png" hspace="15" alt="SolidWorksTools dll issue" height="100" /></p>
<p>In theory, one should be able to update the VBAddin.vstemplate file above to refer to the insalled version of the SolidWorkTools dll file.  One of my favorite philosophers once explained why this might not work for me:</p>
<p> &#8221;In theory there is no difference between theory and practice.  In practice there is.&#8221;  &#8211; Yogi Berra</p>
<p>What I do is just to uninstall the SolidWorksTools dll file in the GAC (right mouse button on the file in the GAC and select uninstall) and replace it with the version 1.0.0.1 file that SolidWorks API support gave me the first time I ever reported this issue (a long time ago, in a galaxy far, far away&#8230;) .  You can do this by simply dropping the file in the GAC folder (e.g. C:\Windows\assemblies). </p>
<p>Once you add the version 1.0.0.1 SolidWorksTools dll file to the GAC, you can go into Visual Studio and attempt to create a new SolidWorks project from the SolidWorks Add-in Template for Visual Studio.</p>
<p> <img border="0" vspace="15" width="690" src="http://extensiblecad.com/words/wp-content/uploads/2008/06/solidworks-developmentenvironmenttwo.png" hspace="15" alt="SolidWorks Add-in Template for Visual Studio" height="478" /></p>
<p>And it works!  Now you can begin writing that Add-in (i.e. the one that is now a few days late while you fought with the SolidWorks SDK).</p>
<p>Note:  For any SolidWorks Add-ins that were previously compiling using the 1.0.0.1 dll, you will have to change your Visual Studio Project to reference the newer version.</p>
<p> Good luck.</p>
	<p></p>
	<hr noshade style="margin:0;height:1px" />
	<small><p>&copy; Jeff Cope for <a href="http://extensiblecad.com/words">Extensible By Design</a>, 2008. |
	<a href="http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/">Permalink</a> |
	<a href="http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/#comments">10 comments</a> |
	Add to
	<a href="http://del.icio.us/post?url=http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/&amp;title=Setting Up and Troubleshooting Your SolidWorks Add-in Development Environment.  Take off, eh&#8230;"><img src="http://yoursite.com/images/icons/delicious.gif" border="0"> del.icio.us</a>
	<a href="http://www.digg.com/submit"><img src="http://yoursite.com/images/digg.gif" border="0"> digg</a><br/>
	Who's linking ?
	<a href="http://www.technorati.com/search/http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/" title="Search on Technorati"><img src="http://yoursite.com/images/icons/technorati.gif" border="0">Technorati</a>
	<a href="http://www.blogpulse.com/search?query=http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/" title="Search on Blogpulse"><img src="http://yoursite.com/images/icons/blogpulse.gif" border="0">BlogPulse</a>
	<a href="http://google.com/blogsearch?q=http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/" title="Search on Google Blog Search"><img src="http://yoursite.com/images/icons/google.gif" border="0">Google</a><br/>
	Want more on these topics ? Browse the archive of posts filed under <a href="http://extensiblecad.com/words/category/net/" title="View all posts in .NET" rel="category tag">.NET</a>, <a href="http://extensiblecad.com/words/category/com/" title="View all posts in COM" rel="category tag">COM</a>, <a href="http://extensiblecad.com/words/category/solidworks/" title="View all posts in SolidWorks" rel="category tag">SolidWorks</a>, <a href="http://extensiblecad.com/words/category/solidworks/solidworks-api/" title="View all posts in SolidWorks API" rel="category tag">SolidWorks API</a>.</small></p>
<p>Copyright 2007 <a href=http://extensiblecad.com/words>Extensible By Design.</a>  All rights reserved.</p>]]></content:encoded>
			<wfw:commentRss>http://extensiblecad.com/words/2008/06/12/setting-up-and-troubleshooting-your-solidworks-add-in-development-environment-take-off-eh/feed/</wfw:commentRss>
		<slash:comments>10</slash:comments>
		</item>
		<item>
		<title>Free SolidWorks Add-In To Remind You To Eat Your Custom Properties</title>
		<link>http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/</link>
		<comments>http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/#comments</comments>
		<pubDate>Sun, 24 Feb 2008 02:50:51 +0000</pubDate>
		<dc:creator>Jeff Cope</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[CAD]]></category>
		<category><![CDATA[COM]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[SolidWorks API]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/</guid>
		<description><![CDATA[ In spite of all their positive benefits, which are many, more than a few SolidWorks users look upon custom properties with the same disdain that a pre-schooler would have for green leafy vegetables.  You can explain the benefits of custom properties, how they help you find things, how they lead to healthy drawing title blocks, [...]]]></description>
			<content:encoded><![CDATA[<p><img border="0" vspace="5" align="baseline" width="319" src="http://extensiblecad.com/words/wp-content/uploads/2008/02/pyramid.gif" hspace="5" height="249" /></p>
<p> In spite of all their positive benefits, which are many, more than a few SolidWorks users look upon custom properties with the same disdain that a pre-schooler would have for green leafy vegetables.  You can explain the benefits of custom properties, how they help you find things, how they lead to healthy drawing title blocks, how they improve PDM implementations, etc&#8230; until you are blue in the face and with some individuals you still won&#8217;t make a dent.  There might be a change for a few days even a few weeks but inevitably you are back to files with no custom properties filled out. </p>
<p>In order to increase the life-expectancy of CAD administrators everywhere, I have posted a free .NET Add-In for SolidWorks that will &#8220;remind&#8221; your users to enter certain custom properties whenever they create a new file or save an existing one (after the initial save).  The list of custom properties is configurable and</p>
<p> <span id="more-80"></span></p>
<p>the user cannot proceed with their file until they enter the custom properties.  I am sure the program can be improved upon but for those without SolidWorks API skills of their own this should be a nice little app.  Also, for those who do have SolidWorks API skills using Visual Basic.NET, I am more than happy to share the code if you request it.</p>
<p> The Add-In, called &#8220;Big Brother&#8221; is written for SolidWorks 2008 and targets the 2.0 .NET Framework, which means if you have SolidWorks 2008 installed on your machine then you can use it.</p>
<p> To get started,</p>
<p>1.  Download the installer package for Big Brother from <a target="_blank" href="http://extensiblecad.com/words/wp-content/uploads/2008/02/big-brother.msi" title="SolidWorks VB.NET Add-In">here.</a></p>
<p>2.  Run the installer, agreeing to the overly wordy license agreement on the way.</p>
<p><img border="0" vspace="5" align="baseline" width="503" src="http://extensiblecad.com/words/wp-content/uploads/2008/02/extensible_bigbrother03.gif" hspace="5" alt="SolidWorks API Add-In Written In Visual Basic.NET" height="414" /></p>
<p>3.  After installing the software, run the &#8220;Register Big Brother.bat&#8221; file in the installation directory.  Running this batch file will register Big Brother with COM and add the appropriate registry entries for SolidWorks to load Big Brother when SolidWorks is run.</p>
<p><img border="0" vspace="5" width="820" src="http://extensiblecad.com/words/wp-content/uploads/2008/02/extensible_bigbrother05.gif" hspace="5" alt=".NET Add-In for SolidWorks 2008 Using The SolidWorks API" height="416" /></p>
<p>4. This is an optional step but if you don&#8217;t already have a decent XML editor, then I recommend you<a target="_blank" href="http://www.microsoft.com/downloads/details.aspx?familyid=72D6AA49-787D-4118-BA5F-4F30FE913628&amp;displaylang=en" title="Download XML Notepad, A Free XML Editor"> download XML Notepad</a> which is a free XML editor from Microsoft.</p>
<p><img border="0" vspace="5" width="891" src="http://extensiblecad.com/words/wp-content/uploads/2008/02/extensible_bigbrother06.gif" hspace="5" alt="Download Microsoft XML Notepad" height="814" /></p>
<p>5.  Use XML Notepad to edit the XML configuration files in the installation directory.  The installation has three XML files which are used to configure which custom properties are managed by Big Brother for each of the three main part types in SolidWorks.</p>
<ul>
<li>AssemblyPropertiesToManage.XML &#8211; Represents custom properties for assemblies.</li>
<li>DrawingPropertiesToManage.XML &#8211; Represents custom properties for drawings.</li>
<li>PartPropertiesToManage.XML &#8211; Represents custom properties for parts.</li>
</ul>
<p><img border="0" vspace="5" width="744" src="http://extensiblecad.com/words/wp-content/uploads/2008/02/extensible_bigbrother07.gif" hspace="5" alt="XML Configuration Files For SolidWorks Add-In Written In Visual Basic.NET" height="558" /></p>
<p>Edit the list of custom properties to manage for each document type using XML Notepad.  Each &#8220;ExtProperty&#8221; node represents a custom property.  PropName represents the name of the custom property to be managed.  PropValue and PropType should not be touched.  Leave those alone.  Save the file(s) when finished.</p>
<p>6.  Open SolidWorks and create a new part.  After selecting your template, you should be prompted to verify or fill in the values for the custom properties in your PartPropertiesToManage.XML file.  The same thing should happen for subsequent file saves.  The original Save (for new documents) doessnot trigger the FileSaveNotify event.  I suspect that it is triggered by the FileSaveAsNotify event.  If anyone tries that and gets the answer then please let me know.</p>
<p><img border="0" vspace="5" width="800" src="http://extensiblecad.com/words/wp-content/uploads/2008/02/extensible_bigbrother09.gif" hspace="5" alt="SolidWorks API Add-In Written For .NET 2.0 Using Visual Basic" height="572" /></p>
<p>7.   Additional configuration of the Add-In may be performed by editing the &#8220;ExtensibleEventManager.dll.config&#8221; file, which you should also use XML Notepad to edit. </p>
<ul>
<li>If BigBrotherMode=True then it is mandatory that users enter values for all custom properties.  If BigBrotherMode=False then the dialog pops up as an FYI.</li>
<li>If CatchFileNewEvent=True then files are managed on FileNew in addition to FileSave.</li>
</ul>
	<p></p>
	<hr noshade style="margin:0;height:1px" />
	<small><p>&copy; Jeff Cope for <a href="http://extensiblecad.com/words">Extensible By Design</a>, 2008. |
	<a href="http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/">Permalink</a> |
	<a href="http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/#comments">14 comments</a> |
	Add to
	<a href="http://del.icio.us/post?url=http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/&amp;title=Free SolidWorks Add-In To Remind You To Eat Your Custom Properties"><img src="http://yoursite.com/images/icons/delicious.gif" border="0"> del.icio.us</a>
	<a href="http://www.digg.com/submit"><img src="http://yoursite.com/images/digg.gif" border="0"> digg</a><br/>
	Who's linking ?
	<a href="http://www.technorati.com/search/http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/" title="Search on Technorati"><img src="http://yoursite.com/images/icons/technorati.gif" border="0">Technorati</a>
	<a href="http://www.blogpulse.com/search?query=http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/" title="Search on Blogpulse"><img src="http://yoursite.com/images/icons/blogpulse.gif" border="0">BlogPulse</a>
	<a href="http://google.com/blogsearch?q=http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/" title="Search on Google Blog Search"><img src="http://yoursite.com/images/icons/google.gif" border="0">Google</a><br/>
	Want more on these topics ? Browse the archive of posts filed under <a href="http://extensiblecad.com/words/category/net/" title="View all posts in .NET" rel="category tag">.NET</a>, <a href="http://extensiblecad.com/words/category/cad/" title="View all posts in CAD" rel="category tag">CAD</a>, <a href="http://extensiblecad.com/words/category/com/" title="View all posts in COM" rel="category tag">COM</a>, <a href="http://extensiblecad.com/words/category/solidworks/" title="View all posts in SolidWorks" rel="category tag">SolidWorks</a>, <a href="http://extensiblecad.com/words/category/solidworks/solidworks-api/" title="View all posts in SolidWorks API" rel="category tag">SolidWorks API</a>, <a href="http://extensiblecad.com/words/category/xml/" title="View all posts in XML" rel="category tag">XML</a>.</small></p>
<p>Copyright 2007 <a href=http://extensiblecad.com/words>Extensible By Design.</a>  All rights reserved.</p>]]></content:encoded>
			<wfw:commentRss>http://extensiblecad.com/words/2008/02/23/free-solidworks-add-in-to-remind-you-to-eat-your-custom-properties/feed/</wfw:commentRss>
		<slash:comments>14</slash:comments>
		</item>
		<item>
		<title>Macros 301 &#8211; Generate Document Numbers From MS Access Database And Auto Insert Them Into New Documents</title>
		<link>http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/</link>
		<comments>http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/#comments</comments>
		<pubDate>Sat, 09 Feb 2008 04:04:27 +0000</pubDate>
		<dc:creator>Jeff Cope</dc:creator>
				<category><![CDATA[Database]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[SolidWorks API]]></category>

		<guid isPermaLink="false">http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/</guid>
		<description><![CDATA[Father forgive me.  It has been two weeks since my last blog post.  I apologize everyone for the long interval but things have been crazy.  In addition to some long nights at my day job, I am in the process of releasing a new version of InspectionXpert, the Quality Inspection Sheet generating software from my [...]]]></description>
			<content:encoded><![CDATA[<p>Father forgive me.  It has been two weeks since my last blog post.  I apologize everyone for the long interval but things have been crazy.  In addition to some long nights at my day job, I am in the process of releasing a new version of <a target="_blank" href="http://www.inspectionxpert.com" title="Generate Quality Inspection Sheets From SolidWorks Fast">InspectionXpert, the Quality Inspection Sheet generating software</a> from my company Extensible CAD.  It is a rewarding endeavor but also very demanding.</p>
<p> Anyways&#8230; not so long ago I posted a <a target="_blank" href="http://extensiblecad.com/words/2007/11/01/macros-201-how-to-register-your-solidworks-macro-to-receive-notifications-for-solidworks-events/" title="How To Register Your Macro For SolidWorks Events">Macro &amp; tutorial on how to register for SolidWorks events.</a>  One application of that technique that I mentioned was to automatically generate document numbers for your SolidWorks document and insert them into SolidWorks &#8220;auto-magically.&#8221;  Well, not too long thereafter I was bombarded with emails asking me to post that little Macro and I promised to do so.  This post is the fullfillment of that promise.  I&#8217;m sorry it took so long but I think you guys will like it.  I feel it is &#8220;auto-magically delicious&#8221; myself : )</p>
<p><a href="http://extensiblecad.com/words/wp-content/uploads/2008/02/docnumbersfrommsaccess.zip" title="Auto-magically Generate Document Numbers For SolidWorks Documents From An MS Access Database"> You can download the database and the macro from here.</a></p>
<p>Keep reading to see a flash video of the macro in action&#8230;</p>
<p><span id="more-61"></span></p>
<p><script type="text/javascript" src="swfobject.js"></script></p>
<p id="flashcontent"> <strong>The Macro In Full Effizact</strong></p>
<p><script type="text/javascript">                                 var so = new SWFObject("http://extensiblecad.com/words/wp-content/uploads/2008/02/runmacro.swf", "Run Macro", "800", "600", "8", "#336699");     so.write("flashcontent");</script></p>
<p>Disclaimer:  As I am pretty pressed for time, as usual, I have not added any error handling to this macro.  You will have to do that yourselves.  At some point in the future (here I go making promises again), I will add a post on error handling with VBA. </p>
<p>What this Macro does:  If you didn&#8217;t understand the movie then (please check your home&#8217;s water for lead contamination) this macro registers with SolidWorks to receive notification (aka &#8216;callback&#8217;) when a new file is created in SolidWorks (i.e. File, New).  The official Event is &#8216;FileNewNotify2&#8242; and when fired, the macro will determine the type of file (e.g. SLDASM, SLDDRW or SLDPRT) and then use ActiveX Data Objects, ADO, to contact an MS Access database to find out the next available document number for that document type.  The document number is then written to the new document title, in essence the filename, and then the number in the database is incremented by one so that next time the document will have a unique number.</p>
<p> How Do You Set It Up?</p>
<ol>
<li> Create a database (I used VBA and MS Access because they are friendlier for newbs but SQLServer Express would be more appropriate for a production solution) that contains three colums;  a primary key (i.e. unique identifier for each record), a lookup key (we used file extension) and a column to hold the next number in sequence for each record-type.  In other words, we have a number series for each file type and the number gets incremented by one everytime a number is assigned.</li>
<li>Determine the connection string to connect to the database.  The easiest way to do this is with a little trick I picked up from an awesome SQL Server book (name escapes me right now). 
<ol>
<li>First you create a new text file and then you change the extension from .txt to .udl</li>
<li>Double-click on the file to open it and you will be prompted with a dialog that you can use to test and obtain the connection.  It is a completely un-intuitive GUI but it is better than the typing it by hand.</li>
<p><strong>Getting the Conection String To The Database</strong><br />
<a target="_blank" href="http://extensiblecad.com/words/wp-content/uploads/2008/02/create-connection-string.swf" title="Video Demonstration Of How To Obtain A Database Connection String">Here is a link to a flash video showing how to get the connection string. </a> I tried to add it to the post but I can only have one flash in the same post with the flash video player that I am using.  FYI &#8211; I tried a few flash players but I&#8217;m not that happy with any of them.  If anyone is aware of a stellar flash plugin for wordpress, then please suggest it. </p>
<li>Write a macro that connects to the database using the connection string gained from step #2.  To get the connection string, you just open the .udl file in notepad and copy out the text in the last row.  The macro should obtain an ADO Recordset object from the document numbers table.  I used a query as my filter but you there are other ways.  The query is the simplest.  I designed my query in Access&#8217; query builder GUI and copy/pasted the text from there to the macro.</li>
<li>Test the macro and verify that it is retrieving the correct value (i.e. from the correct row and column) and that it is correctly incrementing the value for next time.</li>
<li>Once you are correctly accessing the database and obtaining the correct information, write a SolidWorks macro to register for notification of the <strong>File, New</strong> event.  It is officially known as the FileNewNotify2 event.  If you don&#8217;t know how to do this, then see <a target="_blank" href="http://extensiblecad.com/words/2007/11/01/macros-201-how-to-register-your-solidworks-macro-to-receive-notifications-for-solidworks-events/" title="Register Your SolidWorks Macro To Receive Event Notifications From SolidWorks">my post on registering your macro to receive event notifications from SolidWorks.</a></li>
<li>Once your new macro is getting called reliable for the FileNewNotify2 event, copy the code from the first macro (the database macro) into the new macro.  Add the database function so that it is called by your FileNewNotify2 event handler.  The new macro should then copy the document number returned from the database function to the new document&#8217;s title.</li>
<p>That&#8217;s it.  That wasn&#8217;t too bad now was it?</p>
<p>Note:  If anyone wants to turn this into a SolidWorks Add-in then you can post it here for the masses.  I will give you full credit.  I am too busy right now to do that (unless it was for money :  )</ol>
</li>
</ol>
	<p></p>
	<hr noshade style="margin:0;height:1px" />
	<small><p>&copy; Jeff Cope for <a href="http://extensiblecad.com/words">Extensible By Design</a>, 2008. |
	<a href="http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/">Permalink</a> |
	<a href="http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/#comments">7 comments</a> |
	Add to
	<a href="http://del.icio.us/post?url=http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/&amp;title=Macros 301 &#8211; Generate Document Numbers From MS Access Database And Auto Insert Them Into New Documents"><img src="http://yoursite.com/images/icons/delicious.gif" border="0"> del.icio.us</a>
	<a href="http://www.digg.com/submit"><img src="http://yoursite.com/images/digg.gif" border="0"> digg</a><br/>
	Who's linking ?
	<a href="http://www.technorati.com/search/http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/" title="Search on Technorati"><img src="http://yoursite.com/images/icons/technorati.gif" border="0">Technorati</a>
	<a href="http://www.blogpulse.com/search?query=http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/" title="Search on Blogpulse"><img src="http://yoursite.com/images/icons/blogpulse.gif" border="0">BlogPulse</a>
	<a href="http://google.com/blogsearch?q=http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/" title="Search on Google Blog Search"><img src="http://yoursite.com/images/icons/google.gif" border="0">Google</a><br/>
	Want more on these topics ? Browse the archive of posts filed under <a href="http://extensiblecad.com/words/category/database/" title="View all posts in Database" rel="category tag">Database</a>, <a href="http://extensiblecad.com/words/category/solidworks/" title="View all posts in SolidWorks" rel="category tag">SolidWorks</a>, <a href="http://extensiblecad.com/words/category/solidworks/solidworks-api/" title="View all posts in SolidWorks API" rel="category tag">SolidWorks API</a>.</small></p>
<p>Copyright 2007 <a href=http://extensiblecad.com/words>Extensible By Design.</a>  All rights reserved.</p>]]></content:encoded>
			<wfw:commentRss>http://extensiblecad.com/words/2008/02/09/macros-301-generate-document-numbers-from-ms-access-database-and-auto-insert-them-into-new-documents/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>How To Destroy References To SolidWorks From Managed Code</title>
		<link>http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/</link>
		<comments>http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/#comments</comments>
		<pubDate>Thu, 20 Dec 2007 14:48:13 +0000</pubDate>
		<dc:creator>Jeff Cope</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[SolidWorks API]]></category>

		<guid isPermaLink="false">http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/</guid>
		<description><![CDATA[  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 [...]]]></description>
			<content:encoded><![CDATA[<p><img border="0" vspace="10" align="absMiddle" width="300" src="http://extensiblecad.com/words/wp-content/uploads/2007/12/wolf_man.jpg" hspace="10" height="228" /> </p>
<p>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&#8217;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&#8217;  COM objects.</p>
<p><a href=" http://www.solidworks.com/pages/services/Tech_Tips/api/TT_HowToExitSolidworksFromNetApplication.html">Tech Tip From SolidWorks On Destroying References To Unmanaged (i.e. COM) Components</a></p>
<p> We have all heard about the promised land of .NET where you don&#8217;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.  <strike>Santa Clause</strike> 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 &#8220;they d@mn self.&#8221; </p>
<p>And remember&#8230;</p>
<blockquote><p>&#8230;Even a man who is pure in heart<br />
and says his prayers by night<br />
may become a wolf when the wolfbane blooms<br />
and the autumn moon is bright.</p></blockquote>
	<p></p>
	<hr noshade style="margin:0;height:1px" />
	<small><p>&copy; Jeff Cope for <a href="http://extensiblecad.com/words">Extensible By Design</a>, 2007. |
	<a href="http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/">Permalink</a> |
	<a href="http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/#comments">No comment</a> |
	Add to
	<a href="http://del.icio.us/post?url=http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/&amp;title=How To Destroy References To SolidWorks From Managed Code"><img src="http://yoursite.com/images/icons/delicious.gif" border="0"> del.icio.us</a>
	<a href="http://www.digg.com/submit"><img src="http://yoursite.com/images/digg.gif" border="0"> digg</a><br/>
	Who's linking ?
	<a href="http://www.technorati.com/search/http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/" title="Search on Technorati"><img src="http://yoursite.com/images/icons/technorati.gif" border="0">Technorati</a>
	<a href="http://www.blogpulse.com/search?query=http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/" title="Search on Blogpulse"><img src="http://yoursite.com/images/icons/blogpulse.gif" border="0">BlogPulse</a>
	<a href="http://google.com/blogsearch?q=http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/" title="Search on Google Blog Search"><img src="http://yoursite.com/images/icons/google.gif" border="0">Google</a><br/>
	Want more on these topics ? Browse the archive of posts filed under <a href="http://extensiblecad.com/words/category/net/" title="View all posts in .NET" rel="category tag">.NET</a>, <a href="http://extensiblecad.com/words/category/solidworks/solidworks-api/" title="View all posts in SolidWorks API" rel="category tag">SolidWorks API</a>.</small></p>
<p>Copyright 2007 <a href=http://extensiblecad.com/words>Extensible By Design.</a>  All rights reserved.</p>]]></content:encoded>
			<wfw:commentRss>http://extensiblecad.com/words/2007/12/20/how-to-destroy-references-to-solidworks-from-managed-code/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

