<?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/cad/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.0</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>Fun With SolidWorks Equations</title>
		<link>http://extensiblecad.com/words/2008/03/26/fun-with-solidworks-equations/</link>
		<comments>http://extensiblecad.com/words/2008/03/26/fun-with-solidworks-equations/#comments</comments>
		<pubDate>Wed, 26 Mar 2008 14:40:33 +0000</pubDate>
		<dc:creator>Jeff Cope</dc:creator>
				<category><![CDATA[CAD]]></category>
		<category><![CDATA[SolidWorks]]></category>

		<guid isPermaLink="false">http://extensiblecad.com/words/2008/03/26/fun-with-solidworks-equations/</guid>
		<description><![CDATA[Disclaimer:  This post isn&#8217;t directly API-related but using logic statements in SolidWorks equations is so useful that I decided to post it.  Also, the syntax is in a kind of &#8220;techno-weenie-ese&#8221; so I thought I would help folks with the syntax.   The SolidWorks equation editor is a very useful, powerful and yet easy to use [...]]]></description>
			<content:encoded><![CDATA[<p><img border="1" vspace="10" align="top" width="323" src="http://extensiblecad.com/words/wp-content/uploads/2008/03/navier-stokes.png" hspace="10" alt="SolidWorks Equations Are Cool" height="49" /></p>
<p>Disclaimer:  This post isn&#8217;t directly API-related but using logic statements in SolidWorks equations is so useful that I decided to post it.  Also, the syntax is in a kind of &#8220;techno-weenie-ese&#8221; so I thought I would help folks with the syntax. </p>
<p> The SolidWorks equation editor is a very useful, powerful and yet easy to use tool for building design intent into your SolidWorks model.  However, most people don&#8217;t take full advantage of its power.  In addition to support for constants, which are nice, the equation editor allows If&#8230;Then type logic statements.  The idea is that you can set a dimension&#8217;s value to one of two values depending on the veracity of a logic statement pertaining to another/other dimension(s).  Say what?&#8230;.</p>
<p> Time for an example&#8230;</p>
<p><span id="more-82"></span></p>
<p> Let&#8217;s say I have dimensions A, B and C.  I want to set C = 4 if A+B&lt;5.  If however, A+B&gt;=5 then I want to set C=8.  This is relatively easy to do using the the IIF statement (if statement to lay people).  The syntax is like this:  IIF([test statement],[value if true],[value if false]).  In our example above, the statement would look like this:  IIF(A+B&lt;5, 4, 8).  Pretty simple, right?  I thought so.  In SolidWorks, it would look like this:  d2@extrude1=IIF(&#8220;d1@sketch4&#8243;+&#8221;d2@sketch4&#8243;&lt;5, 4, 8). </p>
<p> As the example video below shows, IIF statements can be extremely powerful in conjunction with the Instant3D functionality that was added in SolidWorks 2008.  Notice how the hub diameter and number of spokes is updated real-time as I drag the ID  accross the 3.00in threshhold.</p>
<p><object width="425" height="373"><param name="movie" value="http://www.youtube.com/v/UvOm0XK0Nvw&#038;rel=0&#038;border=1&#038;hl=en"></param><param name="wmode" value="transparent"></param><embed src="http://www.youtube.com/v/UvOm0XK0Nvw&#038;rel=0&#038;border=1&#038;hl=en" type="application/x-shockwave-flash" wmode="transparent" width="425" height="373"></embed></object></p>
<p>
You may download the example file show <a href="http://extensiblecad.com/words/wp-content/uploads/2008/03/circular-pattern-part-with-iif-statements-in-equations.zip" title="http://extensiblecad.com/words/wp-content/uploads/2008/03/circular-pattern-part-with-iif-statements-in-equations.zip">from here.</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/03/26/fun-with-solidworks-equations/">Permalink</a> |
	<a href="http://extensiblecad.com/words/2008/03/26/fun-with-solidworks-equations/#comments">13 comments</a> |
	Add to
	<a href="http://del.icio.us/post?url=http://extensiblecad.com/words/2008/03/26/fun-with-solidworks-equations/&amp;title=Fun With SolidWorks Equations"><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/03/26/fun-with-solidworks-equations/" 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/03/26/fun-with-solidworks-equations/" 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/03/26/fun-with-solidworks-equations/" 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/solidworks/" title="View all posts in SolidWorks" rel="category tag">SolidWorks</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/03/26/fun-with-solidworks-equations/feed/</wfw:commentRss>
		<slash:comments>13</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">12 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>12</slash:comments>
		</item>
		<item>
		<title>GetObject( ) or CreateObject( )? Is there a difference? &#8211; Part III</title>
		<link>http://extensiblecad.com/words/2007/10/11/getobject-or-createobject-is-there-a-difference-part-iii/</link>
		<comments>http://extensiblecad.com/words/2007/10/11/getobject-or-createobject-is-there-a-difference-part-iii/#comments</comments>
		<pubDate>Thu, 11 Oct 2007 05:24:59 +0000</pubDate>
		<dc:creator>Jeff Cope</dc:creator>
				<category><![CDATA[CAD]]></category>
		<category><![CDATA[MS Office]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[SolidWorks API]]></category>

		<guid isPermaLink="false">http://extensiblecad.com/words/?p=17</guid>
		<description><![CDATA[At the end of my last post on this topic, I promised you that I would share a &#8220;dirty secret&#8221; so I guess I now have to come clean. FYI &#8211; &#8220;Dirty secret&#8221; may have been a bit strong but it sounded cool (at least to me). Anyways, there is a difference between how SolidWorks [...]]]></description>
			<content:encoded><![CDATA[<p>At the end of my last post on this topic, I promised you that I would share a &#8220;dirty secret&#8221; so I guess I now have to come clean.  FYI &#8211; &#8220;Dirty secret&#8221; 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.</p>
<p>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&#8217;t already running.   This basically ensures that only one instance of SolidWorks at a time is ever automated by your Macro.  This is a <a href="http://en.wikipedia.org/wiki/Singleton_pattern" target="_blank" title="The Singleton Design Pattern">basic coding pattern called &#8220;the Singleton&#8221;</a> and it prevents untold suffering and countless tears.  SolidWorks is so kind to us and many of us didn&#8217;t even know it.</p>
<p>Below are two Macros <span id="more-17"></span>to illustrate the difference between SolidWorks and MS Office applications with regard to CreateObject( ).  The first is an Excel Macro that automates SolidWorks and the second is a SolidWorks Macro that automates Excel.  If you copy/paste the code, be sure you add references in each Macro project to the object library of the application you are automating.  If you don&#8217;t know what the heck I am talking about, then just download the complete files <a href="http://extensiblecad.com/words/wp-content/uploads/2007/10/createobjectxlvsswx.zip" title="CreateObjectXLvsSWX">from here. </a></p>
<ul>
<li>Excel Macro to automate SolidWorks:</li>
</ul>
<blockquote><p><font color="#009933">&#8216;Copyright 2007 by Extensible CAD Technologies, LLC &#8211; All rights reserved<br />
&#8216;Written 10/10/2007 by Jeff Cope<br />
&#8216;User assumes all risk for using the code below.</font></p>
<p>Sub AutomateSolidWorks()</p>
<p><font color="#009933">&#8216;Declare three handles to SolidWorks instances.</font><br />
<font color="#330099">Dim</font> swx1 <font color="#330099">As</font> SldWorks.SldWorks<br />
<font color="#330099">Dim</font> swx2 <font color="#330099">As</font> SldWorks.SldWorks<br />
<font color="#330099">Dim</font> swx3 <font color="#330099">As</font> SldWorks.SldWorks</p>
<p><font color="#009933">&#8216;Use CreateObject( ) for the first instance.  A new instance of SolidWorks IS NOT created.<br />
&#8216;Note:  As we showed previously, using GetObject( ) without a filepath argument here would<br />
&#8216;return an error since no instances of SolidWorks are available to attach to yet.</font><br />
<font color="#330099">Set</font> swx1 = CreateObject(&#8220;SldWorks.Application&#8221;)<br />
<font color="#009933">&#8216;Use CreateObject( ) for the first instance.  A new instance of SolidWorks IS NOT created.</font><br />
<font color="#330099">Set</font> swx2 = CreateObject(&#8220;SldWorks.Application&#8221;)<br />
<font color="#009933">&#8216;Use GetObject( ) for the first instance.  A new instance of SolidWorks IS NOT created.</font><br />
<font color="#330099">Set</font> swx3 = GetObject(, ”SldWorks.Application”)<br />
<font color="#009933">&#8216;At this point, we should only have one SolidWorks window open and one SolidWorks process running.<br />
&#8216;Add new parts using each of the three handles</font></p>
<p>swx1.NewPart<br />
swx2.NewPart<br />
swx3.NewPart<br />
<font color="#009933">&#8216;We should now have one SolidWorks window open with three new SolidWorks parts loaded.</font></p>
<p><font color="#009933"><font color="#330099">End Sub</font></font></p></blockquote>
<ul>
<li>SolidWorks Macro to automate Excel:</li>
</ul>
<blockquote><p><font color="#009933">&#8216;Copyright 2007 by Extensible CAD Technologies, LLC &#8211; All rights reserved<br />
&#8216;Written 10/10/2007 by Jeff Cope<br />
&#8216;User assumes all risk for using the code below.</font></p>
<p><font color="#009933">&#8216;Declare three instances of the Excel.Application interface</font><br />
<font color="#330099">Dim</font> xl1 <font color="#330099">As</font> Excel.Application<br />
<font color="#330099">Dim</font> xl2 <font color="#330099">As</font> Excel.Application<br />
<font color="#330099">Dim</font> xl3 <font color="#330099">As</font> Excel.Application</p>
<p><font color="#330099">Sub</font> main()</p>
<p><font color="#009933">&#8216;Use CreateObject( ) for the first instance.  A new instance of Excel is created.</font><br />
<font color="#330099">Set </font>xl1 = CreateObject(&#8220;Excel.Application&#8221;)<br />
<font color="#009933">&#8216;A new Workbook gets added to this instance</font><br />
xl1.Workbooks.Add<br />
<font color="#009933">&#8216;Make the instance visible so we can see what is happening</font><br />
xl1.Visible = True</p>
<p><font color="#009933">&#8216;Use CreateObject( )for the first instance.  A new instance of Excel is created.</font><br />
<font color="#330099">Set</font> xl2 = CreateObject(&#8220;Excel.Application&#8221;)<br />
<font color="#009933">&#8216;A new Workbook gets added to this instance</font><br />
xl2.Workbooks.Add<br />
<font color="#009933">&#8216;Make the instance visible so we can see what is happening</font><br />
xl2.Visible = True<br />
<font color="#009933">&#8216;At this point, we should be able to see two Excel windows running and each should have a</font><br />
<font color="#009933">&#8216;new Workbook added.</font></p>
<p><font color="#009933">&#8216;Use GetObject( ) for the first instance.  A new instance of Excel IS NOT created.  A handle<br />
&#8216;is simply returned to one of the existing instances (usually xl1).</font><br />
<font color="#330099">Set</font> xl3 = GetObject(, &#8220;Excel.Application&#8221;)<br />
<font color="#009933">&#8216;A new Workbook gets added to this instance</font><br />
xl3.Workbooks.Add<br />
<font color="#009933">&#8216;Make the instance visible so we can see what is happening</font><br />
xl3.Visible = True<br />
<font color="#009933">&#8216;At this point in the Macro&#8217;s execution, we should see two Excel windows (and two Excel processes)<br />
&#8216;running.  However, we have three handles to Excel instances so two of the handles are pointing<br />
&#8216;to the same Excel instance.</font></p>
<p><font color="#009933">&#8216;Release handles to COM objects</font><br />
<font color="#330099">Set</font> xl1 = Nothing<br />
<font color="#330099">Set</font> xl2 = Nothing<br />
<font color="#330099">Set</font> xl3 = Nothing</p>
<p><font color="#009933">&#8216;One of the Excel windows will have two Workbooks in it instead of one.  Note:  If you<br />
&#8216;want to know which one, then just leave one of the instances invisible.<br />
</font><font color="#330099">End Sub</font></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/10/11/getobject-or-createobject-is-there-a-difference-part-iii/">Permalink</a> |
	<a href="http://extensiblecad.com/words/2007/10/11/getobject-or-createobject-is-there-a-difference-part-iii/#comments">One comment</a> |
	Add to
	<a href="http://del.icio.us/post?url=http://extensiblecad.com/words/2007/10/11/getobject-or-createobject-is-there-a-difference-part-iii/&amp;title=GetObject( ) or CreateObject( )? Is there a difference? &#8211; Part III"><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/10/11/getobject-or-createobject-is-there-a-difference-part-iii/" 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/10/11/getobject-or-createobject-is-there-a-difference-part-iii/" 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/10/11/getobject-or-createobject-is-there-a-difference-part-iii/" 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/ms-office/" title="View all posts in MS Office" rel="category tag">MS Office</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/2007/10/11/getobject-or-createobject-is-there-a-difference-part-iii/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>GetObject( ) or CreateObject( )? Is there a difference? &#8211; Part II</title>
		<link>http://extensiblecad.com/words/2007/10/08/getobject-or-createobject-is-there-a-difference-part-ii/</link>
		<comments>http://extensiblecad.com/words/2007/10/08/getobject-or-createobject-is-there-a-difference-part-ii/#comments</comments>
		<pubDate>Mon, 08 Oct 2007 18:52:30 +0000</pubDate>
		<dc:creator>Jeff Cope</dc:creator>
				<category><![CDATA[CAD]]></category>
		<category><![CDATA[MS Office]]></category>
		<category><![CDATA[Macros]]></category>
		<category><![CDATA[SolidWorks]]></category>
		<category><![CDATA[SolidWorks API]]></category>

		<guid isPermaLink="false">http://extensiblecad.com/words/?p=13</guid>
		<description><![CDATA[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, &#8220;That&#8217;s it? That was too easy.&#8221; Well, I don&#8217;t want to be one to disappoint so I will let you in on the rest of the [...]]]></description>
			<content:encoded><![CDATA[<p>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, &#8220;That&#8217;s it? That was too easy.&#8221; Well, I don&#8217;t want to be one to disappoint so I will let you in on the rest of the story including a dirty little secret.</p>
<p>So what else is there? The GetObject( ) call has another trick up its sleeve that I didn&#8217;t discuss last time. Taking a look at its Intellisense signature provides a clue as to what this is.</p>
<p><img vspace="5" align="bottom" width="509" src="http://extensiblecad.com/words/wp-content/uploads/2007/10/intellisense.JPG" hspace="10" alt="GetObject signature" height="292" style="width: 509px; height: 292px" title="GetObject signature" /></p>
<p>In the method signature you actually see two parameters,<span id="more-13"></span> PathName and Class. We know the Class is &#8220;SldWorks.SldWorks&#8221; but what is this PathName and to where does this path lead? Well, it turns out that this is the path to a SolidWorks file and that GetObject is so cool that not only can it return a reference to a SolidWorks application interface (e.g. SldWorks.SldWorks), it can also return a reference to a SolidWorks file as well.</p>
<p>Below are some examples on how you can use GetObject( ).</p>
<ul>
<li>Example 1 &#8211; The first example is basically review from the last post.  This code will usually get you a handle to an already running session of SolidWorks (i.e. a handle to an instance of the SldWorks.SldWorks class)</li>
</ul>
<blockquote>
<blockquote><p><font color="#009933"><font color="#330099">Dim<font color="#009933"> </font><font color="#000000">swapp</font><font color="#009933"> </font><font color="#330099">As </font><font color="#009933">SldWorks.ModelDoc2</font></font><br />
</font><font color="#330099">Set<font color="#000000"> swapp = GetObject(, “SldWorks.Application”)</font></font></p></blockquote>
</blockquote>
<ul>
<li>Example 2 &#8211; Iff (if and only if) you have &#8220;SLDPRT&#8221; associated with SolidWorks on your machine, then the code below will usually get you a handle to a SolidWorks document (i.e. a handle to an instance of the ModelDoc2 class) that resides at the address of &#8220;C:\myFiles\myPart.SLDPRT.&#8221; Note: In this particular case, an instance of SolidWorks will be created even if one doesn&#8217;t already exist. This was glossed over last time.</li>
</ul>
<blockquote>
<blockquote><p><font color="#330099">Dim</font><font color="#009933"> </font><font color="#000000">swDoc</font><font color="#009933"> </font><font color="#330099">As </font><font color="#009933">SldWorks.SldWorks<br />
</font><font color="#330099">Set</font> swDoc = GetObject(&#8220;C:\MyFiles\myPart.SLDPRT&#8221;)</p></blockquote>
</blockquote>
<ul>
<li>Example 3 &#8211; The code below will usually get you a handle to a SolidWorks document (i.e. a handle to an instance of the ModelDoc2 class) that resides at the address of &#8220;C:\myFiles\myPart.SLDPRT.&#8221; This is irregardless of whether or not you have &#8220;SLDPRT&#8221; associated with SolidWorks on your machine. Again, in this particular case, an instance of SolidWorks will be created even if one doesn&#8217;t already exist.</li>
</ul>
<blockquote>
<blockquote><p><font color="#330099">Dim</font><font color="#009933"> </font><font color="#000000">swDoc</font><font color="#009933"> </font><font color="#330099">As </font><font color="#009933">SldWorks.SldWorks<br />
</font><font color="#330099">Set</font> swDoc = GetObject(&#8220;C:\MyFiles\myPart.SLDPRT&#8221;<font color="#330099"><font color="#000000">, _ “SldWorks.Application”</font></font>)</p></blockquote>
</blockquote>
<p>In a nutshell, GetObject can also be used to return a handle to a specific file.  To do this you simply include the path to the file as the first argument.  If you do this, then the second argument becomes optional unless you don&#8217;t have the particular file&#8217;s extension associated to the application in which you desire to open it.</p>
<p>&#8220;Ok Jeff. That&#8217;s pretty cool but what about that dirty little secret you promised us?&#8221;</p>
<p>We&#8217;ll have to save that for Part III and the final installment. I&#8217;ll give you a little hint, though. SolidWorks and Microsoft don&#8217;t make ALL of the same mistakes. Some but not ALL.</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>, 2007. |
	<a href="http://extensiblecad.com/words/2007/10/08/getobject-or-createobject-is-there-a-difference-part-ii/">Permalink</a> |
	<a href="http://extensiblecad.com/words/2007/10/08/getobject-or-createobject-is-there-a-difference-part-ii/#comments">No comment</a> |
	Add to
	<a href="http://del.icio.us/post?url=http://extensiblecad.com/words/2007/10/08/getobject-or-createobject-is-there-a-difference-part-ii/&amp;title=GetObject( ) or CreateObject( )? Is there a difference? &#8211; Part II"><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/10/08/getobject-or-createobject-is-there-a-difference-part-ii/" 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/10/08/getobject-or-createobject-is-there-a-difference-part-ii/" 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/10/08/getobject-or-createobject-is-there-a-difference-part-ii/" 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/ms-office/" title="View all posts in MS Office" rel="category tag">MS Office</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/2007/10/08/getobject-or-createobject-is-there-a-difference-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
