<?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/"
	xmlns:georss="http://www.georss.org/georss" xmlns:geo="http://www.w3.org/2003/01/geo/wgs84_pos#" xmlns:media="http://search.yahoo.com/mrss/"
	>

<channel>
	<title>SolidWorks API</title>
	<atom:link href="http://swapi.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://swapi.wordpress.com</link>
	<description>programming the best 3D CAD</description>
	<lastBuildDate>Thu, 13 Dec 2007 08:16:06 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.com/</generator>
<cloud domain='swapi.wordpress.com' port='80' path='/?rsscloud=notify' registerProcedure='' protocol='http-post' />
<image>
		<url>http://s2.wp.com/i/buttonw-com.png</url>
		<title>SolidWorks API</title>
		<link>http://swapi.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="http://swapi.wordpress.com/osd.xml" title="SolidWorks API" />
	<atom:link rel='hub' href='http://swapi.wordpress.com/?pushpress=hub'/>
		<item>
		<title>Redlight forever !</title>
		<link>http://swapi.wordpress.com/2007/12/13/redlight-forever/</link>
		<comments>http://swapi.wordpress.com/2007/12/13/redlight-forever/#comments</comments>
		<pubDate>Thu, 13 Dec 2007 08:12:31 +0000</pubDate>
		<dc:creator>Dr. Goulu</dc:creator>
				<category><![CDATA[addin]]></category>
		<category><![CDATA[assembly]]></category>
		<category><![CDATA[part]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://swapi.wordpress.com/2007/12/13/redlight-forever/</guid>
		<description><![CDATA[I&#8217;m pleased to see that some people are still looking for the &#8220;RedLight&#8221; tool I developed at DynaBits back in 2003. I therefore decided to make it available again here, especially because it has a button that points to my PayPal account which is still valid, and, just to mention, no one never ever paid [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=19&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m pleased to see that <a href="http://groups.google.com/group/comp.cad.solidworks/browse_thread/thread/b13ccd2555b4ca2d" target="_blank">some people are still looking for </a>the &#8220;RedLight&#8221; tool I developed at DynaBits back in 2003. I therefore decided to make it available again here, especially because it has a button that points to my PayPal account which is still valid, and, just to mention, no one never ever paid a single $, € or CHF for RedLight &#8230;</p>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;">Technically, since this is a blog about API, the trick is to stop a rebuild when it starts by handling the RegenNotify event and exploiting this information from the API help : &#8220;Return  S_FALSE to stop from proceeding with the action that caused the  notification.&#8221;</p>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;">&nbsp;</p>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;">&nbsp;</p>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;">Below is a copy of the (old) page about RedLight on DynaBits&#8217; web site:</p>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;">&nbsp;</p>
<h3><img src="http://swapi.files.wordpress.com/2007/12/redlightlogo.png?w=500" alt="redlightlogo.png" /> &#8220;RedLight&#8221; is      a FREE add-in for SolidWorks to  avoid (automatic)  rebuilds and measure edit/idle time.</h3>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;"><span id="more-19"></span>Copyright 2003, DynaBits sàrl Switzerland www.dynabits.com<br />
You may use this program freely, give it away, but not sell it.<br />
DynaBits makes no guarantee and offers no support for this free tool!</p>
<h3>Installation</h3>
<ul>
<li>Download RedLight.exe [329 Kb] installer (from the download &#8220;Box&#8221; on the right)</li>
<li>Run the installer and check the &#8220;SolidPlus RedLight&#8221; add-in in &#8220;Tools/Add-Ins&#8221;    menu if needed</li>
<li>If you can&#8217;t see these 3 buttons <img src="http://swapi.files.wordpress.com/2007/12/redlight.png?w=500" alt="redlight.png" />, right-click the window frame and check the    &#8220;RedLight&#8221; toolbar.</li>
</ul>
<h3>Usage</h3>
<ol>
<li>The &#8220;red light&#8221; button which remains pushed when you click it.<br />
<strong>As long as    it remains pushed:</strong></p>
<ol>
<li><strong>all rebuilds will be skipped</strong>.</li>
<li><strong>but mates will still be enforced</strong>. Especially, if you create a new      mate it will be satisfied without rebuilding the whole model.</li>
</ol>
<p>Click the red light    button again to set it back to normal position, re-enabling rebuilds.</li>
<li>The two &#8220;green light&#8221; buttons let you rebuild the model manually, even if    the red button is pushed:
<ol>
<li>The &#8220;small&#8221; green light does an &#8220;EditRebuild&#8221;, which is fast but doesn&#8217;t    go in depth : it doesn&#8217;t solve dependencies or propagate to assembly    components.</li>
<li>The &#8220;large&#8221; green light is supposed to do the same as the standard SW &#8220;green light&#8221; button (which doesn&#8217;t work when red light is pushed). However it seems that it rebuilds everything.</li>
</ol>
<p>While the red light button is pushed, we advise to use the &#8220;EditRebuild&#8221;      button, and make a &#8220;ForceRebuild&#8221; only when needed.</li>
</ol>
<p>Select SolidPlus/RedLigh/About&#8230; menu to display the following dialog:</p>
<p style="text-align:center;">     <img src="http://swapi.files.wordpress.com/2007/12/redlightabout.png?w=500" alt="redlightabout.png" /></p>
<p style="text-align:left;">Any period longer than 1min without selection      made or changed is considered as idle time.</p>
<p style="text-align:left;">The &#8220;About&#8221; dialog appears also when exiting      SolidWorks or when unchecking &#8220;RedLight&#8221; from the add-ins list.</p>
<p style="text-align:left;">Tip : if you want to measure time spent on a      project, stop/restart RedLight when starting the project. In a forthcoming      version, time spent on each document will be stored and accumulated in a      custom property.</p>
<h3>Release      Notes</h3>
<ul>
<li>    <!--webbot bot="ScheduledImage" U-src="../../images/new.gif" U-Else-src="index.htm" S-Alt="NEW!" S-Else-Alt D-Start-Date="04 Jul 2003 08:53:46" D-End-Date="03 Aug 2003 08:53:46" startspan -->v. 1.1.1 (2003/07/18) : Added Force rebuild button, menus, idle time monitoring and    installer</li>
<li>    v 1.0.8 (2003/07/11) : Added &#8220;About&#8221; dialog box with statistics. No longer    &#8220;open source&#8221;</li>
<li>     beta        2 (2003/07/03) : By special request of bob.z, RedLight now plays a  sound &#8220;(tada.wav&#8221;) at the end of every rebuild longer than 10 secs.</li>
<li>beta 1 (2003/06/26) : first release, announced on comp.cad.solidworks.</li>
</ul>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;">&nbsp;</p>
<h3>Read what users said about RedLight</h3>
<p style="text-align:left;"><em>This bit of code you&#8217;ve written (redlight) is      already saving me more time than any of the (&#8230;) enhancements SW has come      up with in recent memory.</em></p>
<p align="right">Alex</p>
<p style="text-align:left;"><em>Truly excellent add-in.  You can even map the      functions to ye olde Spacemouse.  What more could you ask for?</em></p>
<p align="right">Jim Elias</p>
<p style="text-align:left;"><em>RedLight Rocks !!! saves me lots of time; very nice</em></p>
<p align="right">Navy Diver</p>
<p style="text-align:left;" align="left"> <em>Often when mating components, normally SW takes (&#8230;) time to rebuild. With      Redlight, it doesn&#8217;t rebuild until you want it to. One nice thing I&#8217;ve      noticed when using Redlight is this. If instead of hitting your rebuild      button after creating mates, you drag one of the components, only those      mates just created resolve, even better, eh.</em></p>
<p><em>Another nice surprise. When creating angle mates the SW way, normally I line      up the components roughly in the way I want them using the rotate component      tool. Then I add the mates with the &#8216;closest&#8217; option. I have found that SW      never gets it right in the preview so I have to go through the other 3      combinations available, each time of course sitting back for the mind      numbing rebuild. Quite often when I then get out of the mate dialogue the      mate flips. So far without fail, using your Redlight, if I go into edit mode      and drag the component as I&#8217;ve described before, the  mates are exactly as      I&#8217;ve intended.</em></p>
<p style="text-align:left;" align="right">Alex</p>
<p style="text-align:left;"> <!--webbot bot="Include" U-Include="../../paypal.htm" TAG="BODY" startspan --></p>
<p><!--webbot bot="Include" endspan i-checksum="64931" --></p>
<h3>Special Disclaimer :</h3>
<p>RedLight can save you a lot of time BUT  it uses a low-level  trick to skip rebuilds which might interfere with normal SW functionning.<br />
RedLight might therefore cause unexpected behaviour of SolidWorks and/or  third-party add-ins.<br />
Therefore, DynaBits takes NO RESPONSABILITY for any malfunction or  problem that might occur due the usage of this program.<br />
USE REDLIGHT AT YOUR OWN RISK!</p>
<p>(However, user feedback suggest it is not that risky&#8230;)</p>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/swapi.wordpress.com/19/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/swapi.wordpress.com/19/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/swapi.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/swapi.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/swapi.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/swapi.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/swapi.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/swapi.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/swapi.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/swapi.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/swapi.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/swapi.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/swapi.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/swapi.wordpress.com/19/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/swapi.wordpress.com/19/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/swapi.wordpress.com/19/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=19&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://swapi.wordpress.com/2007/12/13/redlight-forever/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14222bf1aa4683216508f7ed40f52cdd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dr. Goulu</media:title>
		</media:content>

		<media:content url="http://swapi.files.wordpress.com/2007/12/redlightlogo.png" medium="image">
			<media:title type="html">redlightlogo.png</media:title>
		</media:content>

		<media:content url="http://swapi.files.wordpress.com/2007/12/redlight.png" medium="image">
			<media:title type="html">redlight.png</media:title>
		</media:content>

		<media:content url="http://swapi.files.wordpress.com/2007/12/redlightabout.png" medium="image">
			<media:title type="html">redlightabout.png</media:title>
		</media:content>
	</item>
		<item>
		<title>OBJ+MTL exporter</title>
		<link>http://swapi.wordpress.com/2007/03/25/objmtl-exporter/</link>
		<comments>http://swapi.wordpress.com/2007/03/25/objmtl-exporter/#comments</comments>
		<pubDate>Sun, 25 Mar 2007 15:12:00 +0000</pubDate>
		<dc:creator>Dr. Goulu</dc:creator>
				<category><![CDATA[assembly]]></category>
		<category><![CDATA[export]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[part]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://swapi.wordpress.com/2007/03/25/objmtl-exporter/</guid>
		<description><![CDATA[This macro exports parts and (simple) assemblies to Alias OBJ format, generating a corresponding MTL material file at the same time. This will evolve towards an exporter to Hyperion soon &#8230; 'OBJ+MTL exporter : exports parts and (simple) assemblies to Alias OBJ format, 'generating a corresponding MTL material file at the same time. 'Author : [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=13&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<p> This macro exports parts and (simple) assemblies to Alias OBJ format, generating a corresponding MTL material file at the same time.</p>
<p>This will evolve towards an exporter to <a href="http://www.ozone3d.net/hyperion.php" target="_blank">Hyperion </a>soon &#8230;</p>
<p><span id="more-13"></span></p>
<pre>'OBJ+MTL exporter : exports parts and (simple) assemblies to Alias OBJ format,
'generating a corresponding MTL material file at the same time.
'Author : Ph. Guglielmetti, (www.goulu.net) Switzerland, all rights reserved
'Licence: you may use this macro for free, as long as this header is kept untouched.
'License: no support is provided
'Licence: it is forbidden to sell this code or publish it elsewhere without our permission
'Note : "Microsoft Scripting Runtime" must be added to support "Dictionary" data type
'Revision : PGu 2007/03/25 first step towards a Hyperion exporter (http://www.hypergraphics3d.com/)

Const mm As Double = 0.001
Const scal = 1 / mm ' factor the scale the export

Public swApp As SldWorks.SldWorks

Private materials As New dictionary
Private offset As Long ' to append meshes in same OBJ file

Sub main()
    Set swApp = Application.SldWorks
    Dim doc As SldWorks.ModelDoc2
    Set doc = swApp.ActiveDoc
    Open doc.GetPathName + ".obj" For Output As 1
    Print #1, "# SolidWorks to OBJ exporter by Dr. Goulu"
    Dim mtlfile As String: mtlfile = doc.GetPathName + ".mtl"
    mtlfile = Mid(mtlfile, InStrRev(mtlfile, "\") + 1) ' remove path
    Print #1, "mtllib "; Replace(mtlfile, " ", "")
    offset = 1 'vertices are numbered from 1 in OBJ format
    Select Case doc.GetType
        Case swDocPART:
            Call AddMaterial(doc.MaterialUserName, doc.MaterialPropertyValues)
            Call ExportOBJ(doc.GetBodies2(swSolidBody, True), doc.MaterialUserName)
        Case swDocASSEMBLY:
            Call Traverse(doc.GetActiveConfiguration.GetRootComponent)
    End Select
    Close 1
    Call ExportMTL(mtlfile)
End Sub

Private Sub Traverse(comp As SldWorks.Component2)
    Dim mat As String: mat = comp.GetMaterialUserName
    If Not AddMaterial(mat, comp.GetMaterialPropertyValues2(swThisConfiguration, Nothing)) Then
        On Error Resume Next ' dirty way to skip assemblies
        mat = comp.GetModelDoc.MaterialUserName
        Call AddMaterial(mat, comp.GetModelDoc.MaterialPropertyValues)
        On Error GoTo 0
    End If
    Call ExportOBJ(comp.GetBodies2(swSolidBody), mat, comp.Transform2)
    Dim children As Variant: children = comp.GetChildren
    Dim c As Variant
    For Each c In children
        Dim child As Component2: Set child = c
        Call Traverse(child) 'recurse in parts
    Next c
End Sub

Private Sub ExportOBJ(bodies As Variant, material As String, Optional transform As SldWorks.MathTransform)
    If IsEmpty(bodies) Then Exit Sub
    Dim b As Variant
    For Each b In bodies
        Dim body As SldWorks.Body2: Set body = b

        Print #1, "": Print #1, "#Body "; body.name
        Print #1, "g"
        Dim mat As String: mat = body.GetMaterialUserName2
        If mat &lt;&gt; "" Then
            Call AddMaterial(body.GetMaterialUserName2, body.MaterialPropertyValues2)
        Else
            mat = material 'default material
        End If
        If mat &lt;&gt; "" Then Print #1, "usemtl "; material
        Dim tess As SldWorks.Tessellation
        Dim e As Variant 'empty
        Set tess = body.GetTessellation(e)
        tess.NeedFaceFacetMap = True
        tess.MatchType = swTesselationMatchFacetTopology
        Debug.Assert tess.Tessellate
        Dim n As Long: n = tess.GetVertexCount
        Dim i As Long
        For i = 0 To n - 1
            Dim xyz As Variant
            If Not transform Is Nothing Then
                Dim v As SldWorks.MathPoint
                Set v = swApp.GetMathUtility.CreatePoint(tess.GetVertexPoint(i))
                Set v = v.MultiplyTransform(transform)
                xyz = v.ArrayData
            Else
                xyz = tess.GetVertexPoint(i)
            End If
            Const fmt = "0.000000"
            Print #1, "v "; Format(xyz(0) * scal, fmt); " "; Format(xyz(1) * scal, fmt); " "; Format(xyz(2) * scal, fmt)
        Next i
        Dim f As SldWorks.Face2
        Set f = body.GetFirstFace
        n = 0
        While Not f Is Nothing
            n = n + 1
            Print #1, "g "; body.name; " "; f.GetFeature.name; " face"; n
            Dim facets As Variant: facets = tess.GetFaceFacets(f)
            For i = LBound(facets) To UBound(facets)
                Dim fins As Variant: fins = tess.GetFacetFins(facets(i))
                Debug.Assert (UBound(fins)) = 2 ' make sure we have only triangles
                Dim pts(2) As Long ': ReDim pts(UBound(fins))
                Dim j As Long
                For j = LBound(fins) To UBound(fins)
                    Dim vert As Variant: vert = tess.GetFinVertices(fins(j))
                    pts(j) = vert(0)
                Next j
                Print #1, "f "; pts(0) + offset; pts(1) + offset; pts(2) + offset
            Next i
            Set f = f.GetNextFace
        Wend
        offset = offset + tess.GetVertexCount
    Next b
End Sub

Private Function AddMaterial(name As String, properties As Variant) As Boolean
    If name = "" Then Exit Function
    If Not materials.Exists(name) Then
        Call materials.Add(name, properties)
        AddMaterial = True
    End If
End Function

Private Sub ExportMTL(mtlfile As String)
    Open mtlfile For Output As 1
    Dim mat As Variant
    For Each mat In materials
        Print #1, "newmtl "; mat
        Dim p As Variant: p = materials(mat) '[ R, G, B, Ambient, Diffuse, Specular, Shininess, Transparency, Emission ]
        Dim r As Double: r = p(0)
        Dim g As Double: g = p(1)
        Dim b As Double: b = p(2)
        Print #1, "Ka "; r * p(3); g * p(3); b * p(3) 'Ambient
        Print #1, "Kd "; r * p(4); g * p(4); b * p(4) 'Diffuse
        Print #1, "Ks "; r * p(5); g * p(5); b * p(5) 'Specular
        'shininess ?
        Print #1, "Tf "; r * p(7); g * p(7); b * p(7)
        'emission ?
    Next mat
    Close 1
End Sub</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/swapi.wordpress.com/13/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/swapi.wordpress.com/13/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/swapi.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/swapi.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/swapi.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/swapi.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/swapi.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/swapi.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/swapi.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/swapi.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/swapi.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/swapi.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/swapi.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/swapi.wordpress.com/13/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/swapi.wordpress.com/13/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/swapi.wordpress.com/13/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=13&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://swapi.wordpress.com/2007/03/25/objmtl-exporter/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14222bf1aa4683216508f7ed40f52cdd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dr. Goulu</media:title>
		</media:content>
	</item>
		<item>
		<title>Layers</title>
		<link>http://swapi.wordpress.com/2007/01/30/layers/</link>
		<comments>http://swapi.wordpress.com/2007/01/30/layers/#comments</comments>
		<pubDate>Tue, 30 Jan 2007 21:03:53 +0000</pubDate>
		<dc:creator>Dr. Goulu</dc:creator>
				<category><![CDATA[drawing]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://swapi.wordpress.com/2007/01/30/layers/</guid>
		<description><![CDATA[SolidWorks macro to organise segments from an imported dxf/dwg by color on layers Imagine you get a large dxf or dwg which has been colorized by hand, without using layers. This macro will let you edit the drawing cleanly in SolidWorks, by placing all segments with the same color on specific layers. 'Layerize: SolidWorks macro [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=4&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h4>SolidWorks macro to organise segments from an imported dxf/dwg by color on layers</h4>
<p>Imagine you get a large dxf or dwg which has been colorized by hand, without using layers. This macro will let you edit the drawing cleanly in SolidWorks, by placing all segments with the same color on specific layers.</p>
<p><span id="more-4"></span></p>
<pre>'Layerize: SolidWorks macro to organise segments from an imported dxf/dwg by color on layers
'Author  : Ph. Guglielmetti, (c) 2007, e-Systems Consulting Switzerland, all rights reserved
'Licence : you may use this macro for free, as long as this header is kept untouched.
'License : no support is provided, except for e-Systems customers
'Licence : it is forbidden to sell this code or publish it elsewhere without our permission
'Revision: 2007/01/30 PGu for AMBT
'Notes   :
' 1) Don't forget to check "Microsoft Scripting Runtime" in References, needed for the Dictionary object
' 2) This macro is extremely slow if the drawing doc is visible. Minimize it when the macro runs to go faster

Sub main()
    Dim swApp As SldWorks.SldWorks: Set swApp = Application.SldWorks
    Dim doc As SldWorks.DrawingDoc: Set doc = swApp.ActiveDoc
    Dim view As SldWorks.view: Set view = doc.GetFirstView
    Dim sketch As SldWorks.sketch: Set sketch = view.GetSketch
    Dim segs As Variant: segs = sketch.GetSketchSegments
    Debug.Print UBound(segs)
    Dim layermgr As SldWorks.layermgr: Set layermgr = doc.GetLayerManager
    Dim layers As New dictionary
    Dim s As Variant
    For Each s In segs
        Dim seg As SldWorks.SketchSegment: Set seg = s
        Dim c As Long: c = seg.Color
        If Not layers.Exists(c) Then ' create it
            Dim name As String: name = "color " + Str(c)
            Debug.Assert layermgr.AddLayer(name, "created by Layerize macro", seg.Color, seg.Style, seg.Width)
            Call layers.Add(c, name)
            Debug.Print "layer"; name; "created"
        End If
        seg.Layer = layers(c)
        seg.LayerOverride = False
        DoEvents
    Next s
    Debug.Print "finished"
End Sub</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/swapi.wordpress.com/4/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/swapi.wordpress.com/4/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/swapi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/swapi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/swapi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/swapi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/swapi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/swapi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/swapi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/swapi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/swapi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/swapi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/swapi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/swapi.wordpress.com/4/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/swapi.wordpress.com/4/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/swapi.wordpress.com/4/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=4&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://swapi.wordpress.com/2007/01/30/layers/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14222bf1aa4683216508f7ed40f52cdd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dr. Goulu</media:title>
		</media:content>
	</item>
		<item>
		<title>ViewSize</title>
		<link>http://swapi.wordpress.com/2007/01/12/viewsize/</link>
		<comments>http://swapi.wordpress.com/2007/01/12/viewsize/#comments</comments>
		<pubDate>Fri, 12 Jan 2007 21:15:39 +0000</pubDate>
		<dc:creator>Dr. Goulu</dc:creator>
				<category><![CDATA[assembly]]></category>
		<category><![CDATA[drawing]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[part]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://swapi.wordpress.com/2007/03/08/viewsize/</guid>
		<description><![CDATA[Macro to resize the model view for screen captures Saving your models as pictures for documentation ? Then you know the problem : the images will have 912×534 pixels one day and 1143×712 the day after. If you don&#8217;t want to edit your images in a second step, here is a macro that sets the [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=7&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Macro to resize the model view for screen captures</h3>
<p>Saving your models as pictures for documentation ? Then you know the problem : the images will have 912×534 pixels one day and 1143×712 the day after. If you don&#8217;t want to edit your images in a second step, here is a macro that sets the graphic area to a specified size:</p>
<p><span id="more-7"></span></p>
<pre>'ViewSize : SolidWorks macro to size the view (for screen captures)
'Author : Ph. Guglielmetti, (c) 2004, DynaBits sàrl Switzerland, all rights reserved
'Licence: you may use this macro for free, as long as this header is kept untouched.
'License: no support is provided, except for e-Systems customers
'Licence: it is forbidden to sell this code or publish it elsewhere without our permission
'Revision : 2004-01-12 PhG v 1.0 Tricky! : uses a WinAPI call to read the Frame's DIBSECTION size values</pre>
<pre>Option Explicit</pre>
<pre>Private Const fh As Long = 800 ' horizontal size in pixels
Private Const fv As Long = 600 ' vertical size in pixels</pre>
<pre>Private Declare Sub RtlMoveMemory Lib "kernel32" _
  (ByVal pDest As Long, ByVal pSource As Long, ByVal cbCopy As Long) ' see function Peek below

Sub ViewSize() ' main
    Dim swApp As SldWorks.SldWorks
    Set swApp = Application.SldWorks
    Dim doc As SldWorks.ModelDoc2
    Set doc = swApp.ActiveDoc
    Dim view As SldWorks.ModelView
    Set view = doc.ActiveView
    Call SetFrameSize(view, fh, fv)
End Sub</pre>
<pre>' works from SW2004. Before, ModelView::FrameHeight was only a Get property
Sub SetFrameSize(view As SldWorks.ModelView, fh As Long, fv As Long)
    view.FrameState = swWindowNormal
    Dim dib As Long
    dib = view.GetViewDIB
    Dim h As Long, v As Long
    h = Peek(dib + 4, vbLong)
    v = Peek(dib + 8, vbLong)
    view.FrameWidth = fh + view.FrameWidth - h
    view.FrameHeight = fv + view.FrameHeight - v
End Sub</pre>
<pre>Function Peek(Adresse As Long, VType As Long)
  Dim cbCopy As Long
  Select Case VType
    Case vbByte
      cbCopy = 1
    Case vbInteger, vbBoolean
      cbCopy = 2
    Case vbLong, vbSingle
      cbCopy = 4
    Case vbDouble
      cbCopy = 8
    Case Else
      Err.Raise 13
  End Select
  RtlMoveMemory VarPtr(Peek), VarPtr(VType), 4
  RtlMoveMemory VarPtr(Peek) + 8, Adresse, cbCopy
End Function</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/swapi.wordpress.com/7/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/swapi.wordpress.com/7/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/swapi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/swapi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/swapi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/swapi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/swapi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/swapi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/swapi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/swapi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/swapi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/swapi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/swapi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/swapi.wordpress.com/7/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/swapi.wordpress.com/7/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/swapi.wordpress.com/7/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=7&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://swapi.wordpress.com/2007/01/12/viewsize/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14222bf1aa4683216508f7ed40f52cdd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dr. Goulu</media:title>
		</media:content>
	</item>
		<item>
		<title>AddWeldMass</title>
		<link>http://swapi.wordpress.com/2007/01/12/addweldmass/</link>
		<comments>http://swapi.wordpress.com/2007/01/12/addweldmass/#comments</comments>
		<pubDate>Fri, 12 Jan 2007 17:08:32 +0000</pubDate>
		<dc:creator>Dr. Goulu</dc:creator>
				<category><![CDATA[macro]]></category>
		<category><![CDATA[part]]></category>
		<category><![CDATA[properties]]></category>
		<category><![CDATA[VBA]]></category>
		<category><![CDATA[weldment]]></category>

		<guid isPermaLink="false">http://swapi.wordpress.com/2007/01/12/addweldmass/</guid>
		<description><![CDATA[Solidworks macro to add mass/weight custom properties for cut lists If you want to list weights of welded parts in a cut list, you&#8217;ll have to add properties to weldments by hand, one by one … Here is a macro that does it automatically. 'AddWeldMass Solidworks macro to add a mass/weight custom property to each [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=11&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>Solidworks macro to add mass/weight custom properties for cut lists</h3>
<p>If you want to list weights of welded parts in a cut list, you&#8217;ll have to add properties to weldments by hand, one by one …</p>
<p>Here is a macro that does it automatically.</p>
<p><span id="more-11"></span></p>
<pre>'AddWeldMass Solidworks macro to add a mass/weight custom property to each weldment
'so that it can be displayed in a cut list
'Author : Ph. Guglielmetti, e-Systems Switzerland, all rights reserved
'Licence: you may use this macro for free, as long as this header is kept untouched.
'License: no support is provided, except for e-Systems customers
'Licence: it is forbidden to sell this code or publish it elsewhere without our permission
'Revision : PGu 2007/01/11 because I was tired to do this by hand …</pre>
<pre>Option Explicit</pre>
<pre>Private Const propname As String = "POIDS" ' change to "MASS" or whatever you prefer
Private Const proptype As String = "Texte" ' in english you must change to "Text". See comment in code…</pre>
<pre>Sub AddMassProps() ' main
    Dim swApp As SldWorks.SldWorks
    Set swApp = Application.SldWorks
    Dim doc As SldWorks.ModelDoc2
    Set doc = swApp.ActiveDoc
    'Traverse all features
    Dim f As Feature: Set f = doc.FirstFeature
    Do While Not f Is Nothing
        If f.GetTypeName = "CutListFolder" Then ' not "SubWeldFolder" as captured by macro recorder ?
            'the following API call is a typical example of mindless localization :
            'the "proptype" string constant depends on the user language, which
	    'prevents the macro from running everywhere without adaptation !
            'this was corrected in the Add2 call available from SW2007…
        	If f.CustomPropertyManager.Add(propname, proptype, Chr(34) + _
			"SW-Mass@@@" + f.Name + "@" + doc.GetTitle + ".SLDPRT" + Chr(34)) Then
                	Debug.Print "Property "; propname; " added to feature "; f.Name
            End If
        End If
        Set f = f.GetNextFeature
    Loop
End Sub</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/swapi.wordpress.com/11/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/swapi.wordpress.com/11/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/swapi.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/swapi.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/swapi.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/swapi.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/swapi.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/swapi.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/swapi.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/swapi.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/swapi.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/swapi.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/swapi.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/swapi.wordpress.com/11/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/swapi.wordpress.com/11/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/swapi.wordpress.com/11/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=11&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://swapi.wordpress.com/2007/01/12/addweldmass/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14222bf1aa4683216508f7ed40f52cdd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dr. Goulu</media:title>
		</media:content>
	</item>
		<item>
		<title>Scale Texture</title>
		<link>http://swapi.wordpress.com/2007/01/11/scale-texture/</link>
		<comments>http://swapi.wordpress.com/2007/01/11/scale-texture/#comments</comments>
		<pubDate>Thu, 11 Jan 2007 21:26:17 +0000</pubDate>
		<dc:creator>Dr. Goulu</dc:creator>
				<category><![CDATA[configurations]]></category>
		<category><![CDATA[macro]]></category>
		<category><![CDATA[part]]></category>
		<category><![CDATA[VBA]]></category>

		<guid isPermaLink="false">http://swapi.wordpress.com/2007/01/11/scale-texture/</guid>
		<description><![CDATA[SolidWorks Macro to adjust texture scale to configurations sizes If you need to adjust the material texture to many different sizes (configurations) of a part, here is a macro for you: 'ScaleTexture : Solidworks macro to scale material texture on each config of current part 'so that it looks the same for different sizes of [...]<img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=8&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></description>
			<content:encoded><![CDATA[<h3>SolidWorks Macro to adjust texture scale to configurations sizes</h3>
<p>If you need to adjust the material texture to many different sizes (configurations) of a part, here is a macro for you:</p>
<pre><span id="more-8"></span></pre>
<pre>'ScaleTexture : Solidworks macro to scale material texture on each config of current part
'so that it looks the same for different sizes of the part
'Author : Ph. Guglielmetti, e-Systems Switzerland, all rights reserved
'Licence: you may use this macro for free, as long as this header is kept untouched.
'License: no support is provided, except for e-Systems customers
'Licence: it is forbidden to sell this code or publish it elsewhere without our permission
'Revision : PGu 2007/01/11 Written for my colleague Arnaud who needed it for gem stones</pre>
<pre>Option Explicit
Dim swApp As SldWorks.SldWorks
Dim part As SldWorks.PartDoc</pre>
<pre>Sub ScaleTexture ()
    Set swApp = Application.SldWorks
    Set part = swApp.ActiveDoc
    ' find texture scale factor for current config
    Dim texture As SldWorks.texture
    Set texture = part.Extension.GetTexture(part.GetActiveConfiguration.Name)
    Dim s As Double: s = texture.ScaleFactor * boxsize
    ' apply it to all configs
    Dim confnames As Variant
    confnames = part.GetConfigurationNames
    Dim conf As Variant
    For Each conf In confnames
        Call part.ShowConfiguration(conf)
        Set texture = part.Extension.GetTexture(conf)
        If Not texture Is Nothing Then
            Dim d As Double: d = boxsize
            texture.ScaleFactor = s / d
        End If
        Debug.Assert part.Extension.SetTexture(conf, texture)
        part.ViewZoomtofit2
        DoEvents
continue:
    Next conf
End Sub</pre>
<pre>' returns the part's size (diagonal of the bounding box) in current configuration
Function boxsize(Optional body_index As Integer = 0) As Double
    Dim bodies As Variant
    bodies = part.GetBodies(swSolidBody)
    If IsEmpty(bodies) Then Exit Function ' no solid body …
    Dim box As Variant
    box = bodies(body_index).GetBodyBox
    boxsize = Sqr((box(3) - box(0)) * (box(3) - box(0)) + _
                  (box(4) - box(1))* (box(4) - box(1)) + _
                  (box(5) - box(2)) * (box(5) - box(2)))
End Function</pre>
<br /><img alt="" border="0" src="http://feeds.wordpress.com/1.0/categories/swapi.wordpress.com/8/" /> <img alt="" border="0" src="http://feeds.wordpress.com/1.0/tags/swapi.wordpress.com/8/" /> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gocomments/swapi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/comments/swapi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godelicious/swapi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/delicious/swapi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gofacebook/swapi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/facebook/swapi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gotwitter/swapi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/twitter/swapi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/gostumble/swapi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/stumble/swapi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/godigg/swapi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/digg/swapi.wordpress.com/8/" /></a> <a rel="nofollow" href="http://feeds.wordpress.com/1.0/goreddit/swapi.wordpress.com/8/"><img alt="" border="0" src="http://feeds.wordpress.com/1.0/reddit/swapi.wordpress.com/8/" /></a> <img alt="" border="0" src="http://stats.wordpress.com/b.gif?host=swapi.wordpress.com&amp;blog=846723&amp;post=8&amp;subd=swapi&amp;ref=&amp;feed=1" width="1" height="1" />]]></content:encoded>
			<wfw:commentRss>http://swapi.wordpress.com/2007/01/11/scale-texture/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
	
		<media:content url="http://1.gravatar.com/avatar/14222bf1aa4683216508f7ed40f52cdd?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dr. Goulu</media:title>
		</media:content>
	</item>
	</channel>
</rss>
