<?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>SolidWorks &#187; Macro</title>
	<atom:link href="http://solidworks.burkesys.com/category/macro/feed/" rel="self" type="application/rss+xml" />
	<link>http://solidworks.burkesys.com</link>
	<description>Information and tricks not to be forgotten</description>
	<lastBuildDate>Mon, 14 Nov 2011 21:49:21 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Workgroup PDM Macro 4 – Export PDFs of Drawings in a Project</title>
		<link>http://solidworks.burkesys.com/2010/09/pdm-macro-4-export-pdfs-in-a-project/</link>
		<comments>http://solidworks.burkesys.com/2010/09/pdm-macro-4-export-pdfs-in-a-project/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 21:28:28 +0000</pubDate>
		<dc:creator>sburke</dc:creator>
				<category><![CDATA[Macro]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[pdm]]></category>
		<category><![CDATA[pdmworks]]></category>
		<category><![CDATA[vb]]></category>

		<guid isPermaLink="false">http://solidworks.burkesys.com/?p=299</guid>
		<description><![CDATA[Again in this series of Workgroup PDM Macros, this one builds upon the previous. It&#8217;s actually nearly identical, but instead of going &#8220;doc.Save&#8221;, we go &#8220;doc.SaveAsPDF&#8221;. The Macro This macro saves/exports the PDF of all Drawings in a Project in the PDM Vault onto a local computer. ' Title of Macro: Save/Export PDFs from all [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/export-pdfs-from-pdm.jpg"><img class="alignright size-full wp-image-325" title="export-pdfs-from-pdm" src="http://solidworks.burkesys.com/wp-content/uploads/2010/09/export-pdfs-from-pdm.jpg" alt="" width="123" height="45" /></a>Again in this <a href="http://solidworks.burkesys.com/tag/pdm/">series of Workgroup PDM Macros</a>, this one builds upon the previous. It&#8217;s actually nearly identical, but instead of going &#8220;doc.Save&#8221;, we go &#8220;doc.SaveAsPDF&#8221;.</p>
<h3>The Macro</h3>
<p><strong><em>This macro saves/exports the PDF of all Drawings in a Project in the PDM Vault onto a local computer.</em></strong></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">' Title of Macro: Save/Export PDFs from all Drawings in a Workgroup PDM Project
</span><span style="color: #008000;">' Further info: http://solidworks.burkesys.com/category/macro/
</span><span style="color: #008000;">' Author: Stephen Burke | www.sburke.eu
</span><span style="color: #008000;">' Version: SolidWorks 2010
</span><span style="color: #008000;">' Add in &quot;SolidWorks Workgroup PDM 1.0 Type Library&quot; under: Tools - References
</span><span style="color: #008000;">' Date: 23/09/2010
</span>
<span style="color: #E56717; font-weight: bold;">Option</span> <span style="color: #E56717; font-weight: bold;">Explicit</span>
<span style="color: #151B8D; font-weight: bold;">Dim</span> swApp <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Object</span>
<span style="color: #E56717; font-weight: bold;">Sub</span> main()
    <span style="color: #151B8D; font-weight: bold;">Dim</span> connection <span style="color: #151B8D; font-weight: bold;">As</span> PDMWConnection
    <span style="color: #151B8D; font-weight: bold;">Set</span> connection = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;PDMWorks.PDMWConnection&quot;</span>)
    connection.Login <span style="color: #800000;">&quot;pdmwadmin&quot;</span>, <span style="color: #800000;">&quot;pdmwadmin&quot;</span>, <span style="color: #800000;">&quot;localhost&quot;</span>
    <span style="color: #008000;">'Enter your PDM Login details above, &quot;username&quot;, &quot;password&quot;, &quot;pdmserver&quot;
</span>
    <span style="color: #151B8D; font-weight: bold;">Dim</span> alldocs <span style="color: #151B8D; font-weight: bold;">As</span> PDMWDocuments
    <span style="color: #151B8D; font-weight: bold;">Dim</span> doc <span style="color: #151B8D; font-weight: bold;">As</span> PDMWDocument
    <span style="color: #151B8D; font-weight: bold;">Dim</span> project
    <span style="color: #151B8D; font-weight: bold;">Dim</span> item
    <span style="color: #151B8D; font-weight: bold;">Dim</span> msg
    <span style="color: #151B8D; font-weight: bold;">Dim</span> filename
    <span style="color: #151B8D; font-weight: bold;">Set</span> alldocs = connection.Documents
&nbsp;
    <span style="color: #151B8D; font-weight: bold;">Dim</span> options <span style="color: #151B8D; font-weight: bold;">As</span> PDMWorks.PDMWSearchOptions
    <span style="color: #151B8D; font-weight: bold;">Dim</span> criteria <span style="color: #151B8D; font-weight: bold;">As</span> PDMWorks.PDMWSearchCriteria
    <span style="color: #151B8D; font-weight: bold;">Dim</span> results <span style="color: #151B8D; font-weight: bold;">As</span> PDMWorks.PDMWSearchResults
    <span style="color: #151B8D; font-weight: bold;">Dim</span> result <span style="color: #151B8D; font-weight: bold;">As</span> PDMWorks.PDMWSearchResult
    <span style="color: #151B8D; font-weight: bold;">Dim</span> i
    <span style="color: #151B8D; font-weight: bold;">Dim</span> cnt
&nbsp;
    <span style="color: #151B8D; font-weight: bold;">Set</span> options = connection.GetSearchOptionsObject
    options.SearchOnlyChildrenOf = <span style="color: #800000;">&quot;Project1&quot;</span>
    <span style="color: #008000;">' ^ Type in the name of the Project you wish to save the files out of.
</span>
    options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, <span style="color: #800000;">&quot;All&quot;</span>, pdmwContains, <span style="color: #800000;">&quot;slddrw&quot;</span>
    <span style="color: #008000;">' ^ set the search query: look for &quot;All&quot; (everything/*) in slddrw.
</span>
    <span style="color: #151B8D; font-weight: bold;">Set</span> results = connection.Search(options)
    cnt = results.Count
&nbsp;
    <span style="color: #8D38C9; font-weight: bold;">For</span> i = 0 <span style="color: #8D38C9; font-weight: bold;">To</span> cnt - 1
        <span style="color: #151B8D; font-weight: bold;">Set</span> result = results(i)
        <span style="color: #008000;">'msg = MsgBox(result.Name, vbCritical)
</span>        <span style="color: #151B8D; font-weight: bold;">Set</span> doc = alldocs(result.Name)
        doc.SaveAsPDF <span style="color: #800000;">&quot;C:\Temp\&quot;</span>
&nbsp;
        <span style="color: #008000;">'filename = &quot;C:\Temp\&quot; &amp; Replace(result.Name, &quot;.SLDDRW&quot;, &quot; &quot;) &amp; result.Revision &amp; &quot;.pdf&quot;
</span>        <span style="color: #008000;">'If Dir(filename) &lt;&gt; &quot;&quot; Then Kill filename
</span>        <span style="color: #008000;">'Name &quot;C:\Temp\&quot; &amp; result.Name &amp; &quot;.pdf&quot; As filename
</span>        <span style="color: #008000;">''Uncomment the above 3 lines. This will output the file &quot;drawing 01.pdf&quot;, where 01 is the current revision of the drawing.
</span>    <span style="color: #8D38C9; font-weight: bold;">Next</span> i
&nbsp;
    connection.Logout
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span></pre></div></div>

<p>Make sure to scroll to the right in the code area above ^. <a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/workgroup-pdm-macro-4_Export-PDFs-of-Drawings-in-a-Project.txt">Link to Macro Download</a></p>
<p><strong><em>Note:</em></strong> The default filename which will be created is &#8220;filename.SLDDRW.pdf&#8221;. I read on the SolidWorks Forums of a person requesting an output file name: &#8220;filename 01.pdf&#8221; where 01 is the current revision. This functionality is in the above code. Uncomment the 3 lines underneath &#8220;doc.SaveAsPDF&#8221; (do so by removing the single quotation mark &#8216; ). This is quite nice, because if this macro was being run by the Task Scheduler every night, it would be evident from looking at C:\Temp (or outbox folder specified) that  a new revision is available.</p>
<h3>Readme</h3>
<p>New in SolidWorks 2008 was the option to automatically have PDM create a PDF for every drawing upon check-in. This macro saves/exports this PDF, and is much quicker than if we were to re-print a PDF. If however, the option to create PDFs on check-in is not set in the Vault Admin Tool, this Macro will not work. See image below for where this option is within the VaultAdmin Tool.</p>
<div id="attachment_302" class="wp-caption aligncenter" style="width: 410px"><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/workgroup-pdm-vault-admin-setting-create-pdf.gif"><img class="size-full wp-image-302" title="workgroup-pdm-vault-admin-setting-create-pdf" src="http://solidworks.burkesys.com/wp-content/uploads/2010/09/workgroup-pdm-vault-admin-setting-create-pdf.gif" alt="" width="400" height="158" /></a><p class="wp-caption-text">The setting to create PDFs must be set in the Vault Admin Tool.</p></div>
<p>If this setting was not turned on, and you just enabled it, this macro still won&#8217;t work. The PDF only gets created upon check-in of drawings after this above setting is enabled. To check to see if a PDF is available for drawings in the Vault, right-click on a Drawing and see if the option &#8220;View Document as PDF&#8221; is available (see image below). If this method works, then the macro should too. If a drawing does not have a PDF, you may get the error &#8220;An unknown filesystem error occurred. (50)&#8221;. In this case, set the above option, checkout and checkin the drawing to have the PDF created automatically.</p>
<div id="attachment_303" class="wp-caption aligncenter" style="width: 377px"><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/workgroup-pdm-view-drawing-as-pdf-manual.gif"><img class="size-full wp-image-303" title="workgroup-pdm-view-drawing-as-pdf-manual" src="http://solidworks.burkesys.com/wp-content/uploads/2010/09/workgroup-pdm-view-drawing-as-pdf-manual.gif" alt="" width="367" height="89" /></a><p class="wp-caption-text">Right-click on a drawing and go &quot;View Document as PDF&quot; to check if the PDF shows.</p></div>
<h3>Cautionary Warning</h3>
<p>While macros are very powerful and can perform a lot of tasks in a short space of time, you need to be very careful. Manually, the PDFs exported, need to be checked by hand, individually, to make sure the contents are correct and accurate. A disaster can occur if someone runs the above macro and sends them off to manufacture, but never checks to see if the exported PDFs are correct and accurate. Check and check again. Unfortunately issues for whatever reason can occur, and its not enough just to say &#8220;it should have worked, its not my fault, I just ran the macro and emailed the pdfs&#8221;. Manual checking of the actions carried out by the macro must be done.</p>
]]></content:encoded>
			<wfw:commentRss>http://solidworks.burkesys.com/2010/09/pdm-macro-4-export-pdfs-in-a-project/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Workgroup PDM Macro 3 – Save out all files &amp; linked files in a Project</title>
		<link>http://solidworks.burkesys.com/2010/09/pdm-macro-3-save-out-all-files-linked-files/</link>
		<comments>http://solidworks.burkesys.com/2010/09/pdm-macro-3-save-out-all-files-linked-files/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 18:02:46 +0000</pubDate>
		<dc:creator>sburke</dc:creator>
				<category><![CDATA[Macro]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[pdm]]></category>
		<category><![CDATA[pdmworks]]></category>
		<category><![CDATA[vb]]></category>

		<guid isPermaLink="false">http://solidworks.burkesys.com/?p=285</guid>
		<description><![CDATA[In the previous Workgroup PDM Macro, there was a limitation when saving files in a Project, in that linked files were not saved. That was because &#8220;PDMWConnection::DocumentList&#8221; listed document names for the specified project, and has no option to include referenced/linked files. The Macro This macro saves all files including linked files in a particular [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/07/macro-toolbar-sw.jpg"><img class="alignright size-full wp-image-168" title="macro-toolbar-sw" src="http://solidworks.burkesys.com/wp-content/uploads/2010/07/macro-toolbar-sw.jpg" alt="" width="177" height="98" /></a>In the <a href="http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-2-save-out-all-files-in-a-project/">previous Workgroup PDM Macro</a>, there was a limitation when saving files in a Project, in that linked files were not saved. That was because &#8220;PDMWConnection::DocumentList&#8221; listed document names for the specified project, and has no option to include referenced/linked files.</p>
<h3>The Macro</h3>
<p><strong><em>This macro saves all files including linked files in a particular Project in the PDM Vault, to the local computer.</em></strong></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">' Title of Macro: Save all files &amp; linked files from a Project in Workgroup PDM
</span><span style="color: #008000;">' Further info: http://solidworks.burkesys.com/category/macro/
</span><span style="color: #008000;">' Author: Stephen Burke | www.sburke.eu
</span><span style="color: #008000;">' Version: SolidWorks 2010
</span><span style="color: #008000;">' Add in &quot;SolidWorks Workgroup PDM 1.0 Type Library&quot; under: Tools - References
</span><span style="color: #008000;">' Date: 23/09/2010
</span>
<span style="color: #E56717; font-weight: bold;">Option</span> <span style="color: #E56717; font-weight: bold;">Explicit</span>
<span style="color: #151B8D; font-weight: bold;">Dim</span> swApp <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Object</span>
<span style="color: #E56717; font-weight: bold;">Sub</span> main()
    <span style="color: #151B8D; font-weight: bold;">Dim</span> connection <span style="color: #151B8D; font-weight: bold;">As</span> PDMWConnection
    <span style="color: #151B8D; font-weight: bold;">Set</span> connection = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;PDMWorks.PDMWConnection&quot;</span>)
    connection.Login <span style="color: #800000;">&quot;pdmwadmin&quot;</span>, <span style="color: #800000;">&quot;pdmwadmin&quot;</span>, <span style="color: #800000;">&quot;localhost&quot;</span>
    <span style="color: #008000;">'Enter your PDM Login details above, &quot;username&quot;, &quot;password&quot;, &quot;pdmserver&quot;
</span>
    <span style="color: #151B8D; font-weight: bold;">Dim</span> alldocs <span style="color: #151B8D; font-weight: bold;">As</span> PDMWDocuments
    <span style="color: #151B8D; font-weight: bold;">Dim</span> doc <span style="color: #151B8D; font-weight: bold;">As</span> PDMWDocument
    <span style="color: #151B8D; font-weight: bold;">Dim</span> project
    <span style="color: #151B8D; font-weight: bold;">Dim</span> item
    <span style="color: #008000;">'Dim msg
</span>    <span style="color: #151B8D; font-weight: bold;">Set</span> alldocs = connection.Documents
&nbsp;
    <span style="color: #151B8D; font-weight: bold;">Dim</span> options <span style="color: #151B8D; font-weight: bold;">As</span> PDMWorks.PDMWSearchOptions
    <span style="color: #151B8D; font-weight: bold;">Dim</span> criteria <span style="color: #151B8D; font-weight: bold;">As</span> PDMWorks.PDMWSearchCriteria
    <span style="color: #151B8D; font-weight: bold;">Dim</span> results <span style="color: #151B8D; font-weight: bold;">As</span> PDMWorks.PDMWSearchResults
    <span style="color: #151B8D; font-weight: bold;">Dim</span> result <span style="color: #151B8D; font-weight: bold;">As</span> PDMWorks.PDMWSearchResult
    <span style="color: #151B8D; font-weight: bold;">Dim</span> i
    <span style="color: #151B8D; font-weight: bold;">Dim</span> cnt
&nbsp;
    <span style="color: #151B8D; font-weight: bold;">Set</span> options = connection.GetSearchOptionsObject
    options.SearchOnlyChildrenOf = <span style="color: #800000;">&quot;Project2&quot;</span>
    <span style="color: #008000;">' ^ Type in the name of the Project you wish to save the files out of.
</span>
    options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, <span style="color: #800000;">&quot;All&quot;</span>, pdmwContains, <span style="color: #800000;">&quot;sldprt&quot;</span>
    options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, <span style="color: #800000;">&quot;All&quot;</span>, pdmwContains, <span style="color: #800000;">&quot;slddrw&quot;</span>
    options.SearchCriteria.AddCriteria pdmwOr, pdmwDocumentName, <span style="color: #800000;">&quot;All&quot;</span>, pdmwContains, <span style="color: #800000;">&quot;sldasm&quot;</span>
    <span style="color: #008000;">' ^ set the search query: look for &quot;All&quot; (everything/*) in sldprt,sldasm,slddrw.
</span>
    <span style="color: #151B8D; font-weight: bold;">Set</span> results = connection.Search(options)
    cnt = results.Count
&nbsp;
    <span style="color: #8D38C9; font-weight: bold;">For</span> i = 0 <span style="color: #8D38C9; font-weight: bold;">To</span> cnt - 1
        <span style="color: #151B8D; font-weight: bold;">Set</span> result = results(i)
        <span style="color: #008000;">'msg = MsgBox(result.Name, vbCritical)
</span>        <span style="color: #151B8D; font-weight: bold;">Set</span> doc = alldocs(result.Name)
        doc.Save <span style="color: #800000;">&quot;C:\Temp\&quot;</span>
    <span style="color: #8D38C9; font-weight: bold;">Next</span> i
&nbsp;
    connection.Logout
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span></pre></div></div>

<p>Make sure to scroll to the right in the code area above ^.</p>
<p>If you are having issues or errors make sure you look at the previous two posts with details on using the PDM API <a href="http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-save-single-file/">#1</a>, <a href="http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-2-save-out-all-files-in-a-project/">#2</a>.</p>
<p>This macro searches for all files in a particular project. It may not be the most efficient macro, but it works, and provides an excellent building block from which to make more intelligent and useful macros. It opens a lot more possibilities of been able to search the Workgroup PDM Vault in a scripted manner and carry out various operations such as saving out files. Again, the SolidWorks Task Scheduler can be set to run this macro periodically. Comments are welcome.</p>
]]></content:encoded>
			<wfw:commentRss>http://solidworks.burkesys.com/2010/09/pdm-macro-3-save-out-all-files-linked-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Workgroup PDM Macro 2 – Save out all files in a Project</title>
		<link>http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-2-save-out-all-files-in-a-project/</link>
		<comments>http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-2-save-out-all-files-in-a-project/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 17:08:59 +0000</pubDate>
		<dc:creator>sburke</dc:creator>
				<category><![CDATA[Macro]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[pdm]]></category>
		<category><![CDATA[pdmworks]]></category>
		<category><![CDATA[vb]]></category>

		<guid isPermaLink="false">http://solidworks.burkesys.com/?p=267</guid>
		<description><![CDATA[So the previous post showed how a single file can be saved from Workgroup PDM onto your local computer using a macro. This macro builds upon that. If you are starting out with macros, I suggest you go back and get that working first. The Macro ' Title of Macro: Save all files out from [...]]]></description>
			<content:encoded><![CDATA[<p>So the <a href="http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-save-single-file/">previous post </a>showed how a single file can be saved from Workgroup PDM onto your local computer using a macro. This macro builds upon that. If you are starting out with macros, I suggest you <a href="http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-save-single-file/">go back</a> and get that working first.</p>
<h3>The Macro</h3>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">' Title of Macro: Save all files out from a Project in Workgroup PDM
</span><span style="color: #008000;">' Further info: http://solidworks.burkesys.com/category/macro/
</span><span style="color: #008000;">' Author: Stephen Burke | www.sburke.eu
</span><span style="color: #008000;">' Version: SolidWorks 2010
</span><span style="color: #008000;">' Add in &quot;SolidWorks Workgroup PDM 1.0 Type Library&quot; under: Tools - References
</span><span style="color: #008000;">' Date: 23/09/2010
</span>
<span style="color: #E56717; font-weight: bold;">Option</span> <span style="color: #E56717; font-weight: bold;">Explicit</span>
<span style="color: #151B8D; font-weight: bold;">Dim</span> swApp <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Object</span>
<span style="color: #E56717; font-weight: bold;">Sub</span> main()
    <span style="color: #151B8D; font-weight: bold;">Dim</span> connection <span style="color: #151B8D; font-weight: bold;">As</span> PDMWConnection
    <span style="color: #151B8D; font-weight: bold;">Set</span> connection = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;PDMWorks.PDMWConnection&quot;</span>)
    connection.Login <span style="color: #800000;">&quot;pdmwadmin&quot;</span>, <span style="color: #800000;">&quot;pdmwadmin&quot;</span>, <span style="color: #800000;">&quot;localhost&quot;</span>
    <span style="color: #008000;">'Enter your PDM Login details above, &quot;username&quot;, &quot;password&quot;, &quot;pdmserver&quot;
</span>
    <span style="color: #151B8D; font-weight: bold;">Dim</span> alldocs <span style="color: #151B8D; font-weight: bold;">As</span> PDMWDocuments
    <span style="color: #151B8D; font-weight: bold;">Dim</span> doc <span style="color: #151B8D; font-weight: bold;">As</span> PDMWDocument
    <span style="color: #151B8D; font-weight: bold;">Dim</span> project
    <span style="color: #151B8D; font-weight: bold;">Dim</span> item
    <span style="color: #008000;">'Dim msg
</span>    <span style="color: #008000;">' ^ remove the single quote from above if you want to debug.
</span>
    <span style="color: #151B8D; font-weight: bold;">Set</span> alldocs = connection.Documents
    project = connection.DocumentList(<span style="color: #800000;">&quot;Project1&quot;</span>)
    <span style="color: #008000;">' ^ Type in the name of the Project you wish to save the files out of.
</span>
    <span style="color: #8D38C9; font-weight: bold;">For</span> <span style="color: #8D38C9; font-weight: bold;">Each</span> item <span style="color: #8D38C9; font-weight: bold;">In</span> project
        <span style="color: #008000;">'msg = MsgBox(item, vbCritical)
</span>        <span style="color: #008000;">' ^ remove the single quote from above if you want to debug.
</span>        <span style="color: #151B8D; font-weight: bold;">Set</span> doc = alldocs(item)
        doc.Save <span style="color: #800000;">&quot;C:\Temp\&quot;</span>
    <span style="color: #8D38C9; font-weight: bold;">Next</span> item
&nbsp;
    connection.Logout
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span></pre></div></div>

<h3>Readme</h3>
<p>This macro uses connection.DocumentList(&#8220;Projectname&#8221;) to create an array of files contained in a particular project in the PDM Vault. To debug this macro further, uncomment the lines &#8220;Dim msg&#8221; and &#8220;msg = MsgBox(item, vbCritical)&#8221;, and when you run the macro you will get a pop-up dialog telling you the names of each of the files found in the PDM Project.</p>
<p><strong><em>There is one cavet. If you have links / references in the Project you are saving, those linked files will not be saved.</em></strong> E.g. in the image below, the Car-and-Engine-Drawing and the Slide3 files will not be saved out. I will post a following macro which will be able to save linked files.</p>
<div id="attachment_275" class="wp-caption aligncenter" style="width: 294px"><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/pdm-project-links-references.gif"><img class="size-full wp-image-275" title="pdm-project-links-references" src="http://solidworks.burkesys.com/wp-content/uploads/2010/09/pdm-project-links-references.gif" alt="" width="284" height="110" /></a><p class="wp-caption-text">Linked files will not be saved.</p></div>
<p>I&#8217;m not going to provide a download of this Macro. I recommend that you create a new Macro in SolidWorks, and type (or copy and paste) the above code into the new empty macro. Also, in case you have not read the previous macro, make sure to add in &#8220;SolidWorks Workgroup PDM 1.0 Type Library&#8221; under Tools -&gt; References in Microsoft Visual Basic. That way you can use &#8220;<a href="http://en.wikipedia.org/wiki/IntelliSense" target="_blank">IntelliSense</a>&#8221; (code prompt and completion) to make sure that the pdm parameters are referenced correctly. In the image below, after typing the . (period/full stop), a drop-down list of available parameters should show up. If the drop-down list doesn&#8217;t show up, something is wrong. Check Tools -&gt; References and go from there.</p>
<div id="attachment_279" class="wp-caption aligncenter" style="width: 259px"><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/intellisense-pdm-macro-parameters.gif"><img class="size-full wp-image-279" title="intellisense-pdm-macro-parameters" src="http://solidworks.burkesys.com/wp-content/uploads/2010/09/intellisense-pdm-macro-parameters.gif" alt="" width="249" height="159" /></a><p class="wp-caption-text">IntelliSense Code completion helps make sure you are referencing the PDM API correctly</p></div>
]]></content:encoded>
			<wfw:commentRss>http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-2-save-out-all-files-in-a-project/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Workgroup PDM Macro 1 &#8211; Save out a single file onto your computer</title>
		<link>http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-save-single-file/</link>
		<comments>http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-save-single-file/#comments</comments>
		<pubDate>Thu, 23 Sep 2010 15:02:57 +0000</pubDate>
		<dc:creator>sburke</dc:creator>
				<category><![CDATA[Macro]]></category>
		<category><![CDATA[api]]></category>
		<category><![CDATA[pdmworks]]></category>
		<category><![CDATA[vb]]></category>
		<category><![CDATA[visual basic]]></category>
		<category><![CDATA[workgroup pdm]]></category>

		<guid isPermaLink="false">http://solidworks.burkesys.com/?p=187</guid>
		<description><![CDATA[Skip straight to the Macro &#62; Introduction Macros in SolidWorks are extremely powerful and useful. They can be however difficult to maintain, especially when upgrading to new versions of SW and requires a good knowledge of SW API and VB/C++. There are also many macros available for SolidWorks, (lenny&#8217;s SW Macros, 3D ContentCentral Macros, Loronos SW Macro [...]]]></description>
			<content:encoded><![CDATA[<p><a href="#macro" target="_self">Skip straight to the Macro &gt;</a></p>
<h3>Introduction</h3>
<p><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/solidworks-pdm-macro.gif"><img class="alignright size-full wp-image-192" title="solidworks-pdm-macro" src="http://solidworks.burkesys.com/wp-content/uploads/2010/09/solidworks-pdm-macro.gif" alt="" width="141" height="59" /></a>Macros in SolidWorks are extremely powerful and useful. They can be however difficult to maintain, especially when upgrading to new versions of SW and requires a good knowledge of SW API and VB/C++. There are also many macros available for SolidWorks, (<a href="http://www.lennyworks.com/solidworks/default.asp?ID=20" target="_blank">lenny&#8217;s SW Macros</a>, <a href="http://www.3dcontentcentral.com/macros.aspx">3D ContentCentral Macros</a>, <a href="http://sw.fcsuper.com/index.php?name=UpDownload&amp;req=viewdownload&amp;cid=1">Loronos SW Macro Downloads</a>, <a href="https://forum.solidworks.com/community/solidworks/api" target="_blank">SolidWorks Forums</a> - login required, and <a href="http://www.solidworks.com/sw/support/APIDownloads.html">SolidWorks API Examples</a> - broken, even when logged in) which are particularly helpful to study and use as a foundation to build your own macro. Unfortunately there are very few macros available for Workgroup PDM and some of which seem to get lost, especially links on the SolidWorks website (the sample pdm api project on the main <a href="http://help.solidworks.com/2010/English/api/pdmworksapi/PDMWorks.Interop.pdmworks_WelcomePDMWorksAPI.html" target="_blank">solidworks help website </a>is broken &#8211; FAIL). Also most of the active work regarding managing SW data is going towards SolidWorks Enterprise PDM which sits on a SQL server as opposed to a file based DB with Workgroup PDM.</p>
<p><a href="http://www.solidworks.com/sw/products/7230_ENU_HTML.htm" target="_blank">SolidWorks Workgroup PDM</a> is a product that comes with SolidWorks Professional and SolidWorks Premium. It allows for revision control of SolidWorks files, and allows multiple people to work on the same SolidWorks project. All SolidWorks files (and other files such as DWG, doc, jpg) gets stored in a main Vault on a central server. There is no direct access to files in the PDM Vault. Access must be through either SolidWorks or SolidWorks Explorer with a PDM Add-In. Files in the vault cannot be accessed directly via Windows Network Share/SMB. As a result interaction with data in Workgroup PDM must be done manually. However here is where SolidWorks Macros and the PDM API comes in.</p>
<p>This macro is the first of a few that I am going to write on Workgroup PDM. If your beginning to write macros, I&#8217;d recommend starting with this Macro which is a good foundation.</p>
<h3>The Macro</h3>
<p><a id="macro"></a><br />
<em><strong>This macro allows a user to copy/save a single specified file from the PDM Vault onto their computer.</strong></em><br />
While this is quite a small task, it is an excellent beginning to learn the SolidWorks PDM API.</p>
<p><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/pdm-save-out-single-file.zip">Download Zip file of the Macro &gt;</a></p>

<div class="wp_syntax"><div class="code"><pre class="vb" style="font-family:monospace;"><span style="color: #008000;">' Title of Macro: Save a single file out from the Workgroup PDM Vault
</span><span style="color: #008000;">' Further info: http://solidworks.burkesys.com/category/macro/
</span><span style="color: #008000;">' Author: Stephen Burke | www.sburke.eu
</span><span style="color: #008000;">' Version: SolidWorks 2010
</span><span style="color: #008000;">' Instructions: Replace &quot;123456.SLDDRW&quot;, with the file required.
</span><span style="color: #008000;">' Add in &quot;SolidWorks Workgroup PDM 1.0 Type Library&quot; under: Tools - References
</span><span style="color: #008000;">' Date: 23/09/2010
</span>
<span style="color: #E56717; font-weight: bold;">Option</span> <span style="color: #E56717; font-weight: bold;">Explicit</span>
<span style="color: #151B8D; font-weight: bold;">Dim</span> swApp <span style="color: #151B8D; font-weight: bold;">As</span> <span style="color: #F660AB; font-weight: bold;">Object</span>
<span style="color: #E56717; font-weight: bold;">Sub</span> main()
    <span style="color: #151B8D; font-weight: bold;">Dim</span> connection <span style="color: #151B8D; font-weight: bold;">As</span> PDMWConnection
    <span style="color: #151B8D; font-weight: bold;">Set</span> connection = <span style="color: #E56717; font-weight: bold;">CreateObject</span>(<span style="color: #800000;">&quot;PDMWorks.PDMWConnection&quot;</span>)
    connection.Login <span style="color: #800000;">&quot;pdmwadmin&quot;</span>, <span style="color: #800000;">&quot;pdmwadmin&quot;</span>, <span style="color: #800000;">&quot;localhost&quot;</span>
    <span style="color: #008000;">'Enter your PDM Login details above, &quot;username&quot;, &quot;password&quot;, &quot;pdmserver&quot;
</span>
    <span style="color: #151B8D; font-weight: bold;">Dim</span> alldocs <span style="color: #151B8D; font-weight: bold;">As</span> PDMWDocuments
    <span style="color: #151B8D; font-weight: bold;">Dim</span> doc <span style="color: #151B8D; font-weight: bold;">As</span> PDMWDocument
    <span style="color: #151B8D; font-weight: bold;">Set</span> alldocs = connection.Documents
&nbsp;
    <span style="color: #151B8D; font-weight: bold;">Set</span> doc = alldocs(<span style="color: #800000;">&quot;123456.SLDDRW&quot;</span>)
    <span style="color: #008000;">' ^ Type in the name of the file you wish to save out.
</span>    doc.Save <span style="color: #800000;">&quot;C:\Temp\&quot;</span>
    <span style="color: #008000;">' ^ Type in a folder on your computer to save into.
</span>
    connection.Logout
<span style="color: #8D38C9; font-weight: bold;">End</span> <span style="color: #E56717; font-weight: bold;">Sub</span></pre></div></div>

<h5>Readme / Usage</h5>
<ol>
<li>Open SolidWorks</li>
<li>Tools -&gt; Macro -&gt; Edit (browse to the saved Zip file)</li>
<li>(in Microsoft Visual basic) Tools -&gt; References -&gt; (add-in) &#8220;SolidWorks Workgroup PDM 1.0 Type Library&#8221;</li>
<li>(in Microsoft Visual basic) Click the Save icon and close down the Visual Basic Editor</li>
<li>(in SolidWorks) Tools -&gt; Macro -&gt; Run</li>
<li>Check C:\Temp for the file</li>
</ol>
<h3>Troubleshooting &amp; FAQ&#8217;s</h3>
<p><strong><em>Problem</em></strong>: You receive the following error: &#8220;Compile error: Can&#8217;t find project or library&#8221;<br />
<strong><em>Solution:</em></strong> Go to Tools -&gt; References and add in &#8220;SolidWorks Workgroup PDM 1.0 Type Library&#8221;. If that does not work, then go to SolidWorks, Tools -&gt; Macro -&gt; New. Choose a new name for the macro and where to save it. This will open up a new Macro. Go to Tools -&gt; References and add in &#8220;SolidWorks Workgroup PDM 1.0 Type Library&#8221;. Then copy and paste the code from above.</p>
<p><strong><em>Problem:</em></strong> You receive the following error: &#8220;Method &#8216;Item&#8217; of object &#8216;IPDMWDocuments&#8217; failed&#8221;.<br />
<strong><em>Solution:</em></strong> The file you require was misspelt in the macro, or doesn&#8217;t exist in the Vault. Check the line &#8216;Set doc = alldocs(&#8220;123456.SLDDRW&#8221;)&#8217;</p>
<p><strong><em>Note:</em></strong> It is not required to be logged into Workgroup PDM within SolidWorks, nor is it required to have &#8220;Workgroup PDM&#8221; turned on in Tools -&gt; Add-Ins. It is required to have &#8220;Workgroup PDM&#8221; visible in Tools -&gt; Add-Ins as this indicates that the PDM libraries are installed on your computer.</p>
<p><strong><em>Note:</em></strong> It is possible to run this Macro from within SolidWorks (Tools -&gt; Macro -&gt; Run) and also from the SolidWorks Task Scheduler with a custom task.</p>
<p><strong><em>Note:</em></strong> This is the macro in its simplest form. It would be possible to show an input dialog to allow a user select and choose which file to save out.</p>
<p><strong><em>Note:</em></strong> While this macro was developed with SolidWorks 2010, it is possible to use this macro with all versions of SolidWorks. It would be best to copy and paste the code into a new macro in this case.</p>
<p><strong><em>Note:</em></strong> If you re-run the macro, it will overwrite and replace any existing file.</p>
<h3>SolidWorks Workgroup PDM API Help (pdmworksapi.chm)</h3>
<p>This help file contains all the api references which can be used in Macros. This file is essential if you want to make full use of the workgroup PDM in Macros. Getting this file was a little difficult. SolidWorks&#8217;s help brought me to <a href="http://help.solidworks.com/2010/English/PDMWorks/LegacyHelp/PDMWorks_Workgroup/API.htm" target="_blank">here</a>, which wasn&#8217;t fully correct, but led me to <a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/obtain-sw-pdm-api-help.jpg" target="_blank">this</a>. A google before this led me to a <a href="http://www.personal.psu.edu/jah5420/Misc/SolidWorks/SolidWorks/api/" target="_blank">2008 version </a>of this chm file, which fortunately had much more information and examples than the 2010 version. I&#8217;m going to provide a mirror of the files here, due to the large amount of broken links that occurs. Local Mirror of <a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/pdmworksapi-sw2008.zip">pdmworksapi-sw2008.chm</a> and <a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/pdmworksapi-sw2010.zip">pdmworksapi-sw2010.chm</a>. (You might have to go properties of the chm files after downloading and go &#8220;unblock&#8221;.) In the pdmworksapi-sw2008.chm, fortunately the Example contained therein had most of the macro in this post.</p>
<p style="text-align: center;" lang="vb"><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/09/get-specific-document-pdm-macro.jpg"><img class="aligncenter size-full wp-image-222" title="get-specific-document-pdm-macro" src="http://solidworks.burkesys.com/wp-content/uploads/2010/09/get-specific-document-pdm-macro.jpg" alt="" width="491" height="323" /></a></p>
<p>Stay tuned for more macros based on this simple example.</p>
]]></content:encoded>
			<wfw:commentRss>http://solidworks.burkesys.com/2010/09/workgroup-pdm-macro-save-single-file/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Macro Tip &#8211; How to quickly stop a SolidWorks macro</title>
		<link>http://solidworks.burkesys.com/2010/07/macro-tip-how-to-quickly-stop-a-solidworks-macro/</link>
		<comments>http://solidworks.burkesys.com/2010/07/macro-tip-how-to-quickly-stop-a-solidworks-macro/#comments</comments>
		<pubDate>Sat, 03 Jul 2010 10:22:36 +0000</pubDate>
		<dc:creator>sburke</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Macro]]></category>
		<category><![CDATA[SW2010]]></category>

		<guid isPermaLink="false">http://solidworks.burkesys.com/?p=167</guid>
		<description><![CDATA[CTRL + Pause/Break Especially useful for macros which loop through lots of operations. If you have a looping MsgBox() popup, the above CTRL+break doesn&#8217;t seem to work. In this case: Task Manager -&#62; Processes -&#62; swvbaserver.exe (End Process) Note: SW may have to be restarted to allow a macro to run afterwards. Reference]]></description>
			<content:encoded><![CDATA[<p><a href="http://solidworks.burkesys.com/wp-content/uploads/2010/07/macro-toolbar-sw.jpg"><img class="alignright size-full wp-image-168" title="macro-toolbar-sw" src="http://solidworks.burkesys.com/wp-content/uploads/2010/07/macro-toolbar-sw.jpg" alt="" width="177" height="98" /></a><strong>CTRL + Pause/Break</strong></p>
<p>Especially useful for macros which loop through lots of operations.</p>
<p>If you have a looping MsgBox() popup, the above CTRL+break doesn&#8217;t seem to work. In this case:</p>
<p>Task Manager -&gt; Processes -&gt; swvbaserver.exe (End Process)<br />
Note: SW may have to be restarted to allow a macro to run afterwards.</p>
<p><a href="http://www.mofeel.net/232-comp-cad-solidworks/9978.aspx" target="_blank">Reference</a></p>
]]></content:encoded>
			<wfw:commentRss>http://solidworks.burkesys.com/2010/07/macro-tip-how-to-quickly-stop-a-solidworks-macro/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

