<?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="https://swapi.wordpress.com/feed/" rel="self" type="application/rss+xml" />
	<link>https://swapi.wordpress.com</link>
	<description>programming the best 3D CAD</description>
	<lastBuildDate>Tue, 23 Sep 2014 19:23:08 +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>https://s0.wp.com/i/buttonw-com.png</url>
		<title>SolidWorks API</title>
		<link>https://swapi.wordpress.com</link>
	</image>
	<atom:link rel="search" type="application/opensearchdescription+xml" href="https://swapi.wordpress.com/osd.xml" title="SolidWorks API" />
	<atom:link rel='hub' href='https://swapi.wordpress.com/?pushpress=hub'/>
	<item>
		<title>What does it take to learn the SolidWorks API?</title>
		<link>https://swapi.wordpress.com/2013/03/27/what-does-it-take-to-learn-the-solidworks-api/</link>
					<comments>https://swapi.wordpress.com/2013/03/27/what-does-it-take-to-learn-the-solidworks-api/#respond</comments>
		
		<dc:creator><![CDATA[CADSharp]]></dc:creator>
		<pubDate>Wed, 27 Mar 2013 14:05:14 +0000</pubDate>
				<category><![CDATA[training]]></category>
		<guid isPermaLink="false">http://swapi.wordpress.com/?p=53</guid>

					<description><![CDATA[The SolidWorks API allows users to automate tasks in SolidWorks, thereby increasing productivity. Nevertheless, the learning the SolidWorks API can be a challenge if you don&#8217;t know where to start. In this post I want to answer the question, &#8220;What does it take to learn the SolidWorks API?&#8221; Those interested in the SolidWorks API typically [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>The SolidWorks API allows users to automate tasks in SolidWorks, thereby increasing productivity. Nevertheless, the learning the SolidWorks API can be a challenge if you don&#8217;t know where to start. In this post I want to answer the question, &#8220;What does it take to learn the SolidWorks API?&#8221;</p>
<p>Those interested in the SolidWorks API typically fall into one of two categories:</p>
<ol>
<li>Those wanting to hire someone who knows the SolidWorks API to write custom macros and addins.</li>
<li>Those wanting to learn the SolidWorks API on their own, in order to write custom macros and addins.</li>
</ol>
<p>As with any other discipline, there is always a tradeoff between time and money. If you have money but not time, you need a consultant. If you have time but not money, you may consider learning the discipline yourself.</p>
<p>Most engineers interested in the API fall into the second category. Then again, what engineer really has gobs of time to spend learning a new discipline? Not many of us do. Nevertheless, I can help you develop a general idea of how long it will take you to learn the API&#8212;assuming you use the best resources available.</p>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;"><span id="more-53"></span></p>
<h4>Three Essential Skills to SolidWorks API Programming</h4>
<p>First, let&#8217;s consider the skills that an API programming novice will need to learn in order to use the SolidWorks API:</p>
<ol>
<li>Programming using either Visual Basic for Applications, VB.NET, C#, or C++</li>
<li>Navigating and using the SolidWorks API Help file</li>
<li>Understanding the SolidWorks API object hierarchy</li>
</ol>
<h4>Why Are These Skills Important?</h4>
<ol>
<li>API stands for &#8220;Application Programming Interface&#8221;. Without learning programming, you&#8217;re stuck using the macro recorder or copying other people&#8217;s code. Trust me, this gets old fast. If you&#8217;re new to programming, you should definitely learn the SolidWorks API using Visual Basic for Applications (VBA). It is by far the simplest language to learn and use with the API. Also, since most examples are in VBA, it is also much easier to study other people&#8217;s code. The main drawback is that you cannot write addins and stand-alones, only macros. This isn&#8217;t an issue for most automation projects, however.</li>
<li>Whereas many help files are notorious for being useless, the SolidWorks API help file is exactly the opposite. It is essential to seriously using the SolidWorks API. Without it, researching what code to write is either tedious or impossible. That being said, it is written for programmers. Learning how to use the API Help best occurs in the context of learning basic programming.</li>
<li>When you program with the SolidWorks API, you are constantly interacting with &#8220;objects&#8221;. These objects can refer to nearly anything you can think of within SolidWorks&#8212;a part, a feature, a face, a drawing view, a dimension, a mate, etc. These objects all have a specific relationship to one another within the SolidWorks API. Without grasping the relationships of these objects to one another, it is very difficult to quickly write API code. These relationships, formally called the SolidWorks API Object Model, are explained in summary <a href="http://help.solidworks.com/2013/English/api/sldworksapiprogguide/GettingStarted/SolidWorks_API_Object_Model_Overview.htm">here</a>.</li>
</ol>
<h4>Fastest Way to Learn These Skills?</h4>
<p>As with learning any discipline, you&#8217;re more than welcome to dive right in without any professional instruction or guidance. You can play around with the macro recorder, look at code samples you find online, try cutting and pasting your own macros together, etc. Needless to say, if you have no prior programming experience, you&#8217;ll end up with 1) sloppy code that doesn&#8217;t do a whole lot, 2) a lot of frustration because you don&#8217;t really understand how the code works (and therefore how to modify it to your needs).</p>
<p>Alternatively, what if you could have a professional SolidWorks API programmer sit beside you and walk you through all of the basics, and well beyond? This exact experience may not be possible, but you can get pretty close using SolidWorks API video tutorials like those found <a href="http://www.cadsharp.com">here</a>. In particular, I recommend using dual monitors&#8212;have the video on one screen and your code editor on the other screen. Do you know of any faster ways to learn the SolidWorks API?</p>
<h4>So what&#8217;s it really going to cost me?</h4>
<p>The truth is, learning the SolidWorks API isn&#8217;t like learning any other SolidWorks feature. It requires skills that may be completely new to you. This means you&#8217;ll have to put in the time to practice and get better. Of course, the end result is more than worth it. Who doesn&#8217;t want to automate some or all of their workflow? Who doesn&#8217;t want to increase their company&#8217;s bottom line? Who doesn&#8217;t want to learn skills that separate them from their peers?</p>
<p>Do you want these things and enjoy learning? The API is for you. If you&#8217;re considering taking your first plunge into the SolidWorks API, feel free to <a href="http://www.cadsharp.com/contact">email me</a> if you want more advice.</p>
]]></content:encoded>
					
					<wfw:commentRss>https://swapi.wordpress.com/2013/03/27/what-does-it-take-to-learn-the-solidworks-api/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://2.gravatar.com/avatar/844f7a313a275f4f8f1033dc3a1c73228b682308d045e8ccc52bc623098c96f8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cadsharp</media:title>
		</media:content>
	</item>
		<item>
		<title>Redlight forever!</title>
		<link>https://swapi.wordpress.com/2007/12/13/redlight-forever/</link>
					<comments>https://swapi.wordpress.com/2007/12/13/redlight-forever/#respond</comments>
		
		<dc:creator><![CDATA[Dr. Goulu]]></dc:creator>
		<pubDate>Thu, 13 Dec 2007 08:12:31 +0000</pubDate>
				<category><![CDATA[addin]]></category>
		<category><![CDATA[solidworks api]]></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 [&#8230;]]]></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;">
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;">
<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;">
<h3><img alt="redlightlogo.png" src="https://swapi.wordpress.com/wp-content/uploads/2007/12/redlightlogo.png?w=500" /> &#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 <a href="http://www.dynabits.com" rel="nofollow">http://www.dynabits.com</a><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>Download</h3>
<p>As of 2013, RedLight.exe is hosted by <a href="http://www.cadsharp.com">CADSharp.com</a>. Please download it <a href="http://www.cadsharp.com/docs/RedLight.exe">here</a>. Note that it does not appear to work on 2011, 2012, or 2013.</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 alt="redlight.png" src="https://swapi.wordpress.com/wp-content/uploads/2007/12/redlight.png?w=500" />, 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 alt="redlightabout.png" src="https://swapi.wordpress.com/wp-content/uploads/2007/12/redlightabout.png?w=500" /></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;">
<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>
]]></content:encoded>
					
					<wfw:commentRss>https://swapi.wordpress.com/2007/12/13/redlight-forever/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/32a7bf56f7bc0ce665dd9ffc672186c547c5345f5532735f91d7a2a13968e043?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dr. Goulu</media:title>
		</media:content>

		<media:content url="https://swapi.wordpress.com/wp-content/uploads/2007/12/redlightlogo.png" medium="image">
			<media:title type="html">redlightlogo.png</media:title>
		</media:content>

		<media:content url="https://swapi.wordpress.com/wp-content/uploads/2007/12/redlight.png" medium="image">
			<media:title type="html">redlight.png</media:title>
		</media:content>

		<media:content url="https://swapi.wordpress.com/wp-content/uploads/2007/12/redlightabout.png" medium="image">
			<media:title type="html">redlightabout.png</media:title>
		</media:content>
	</item>
		<item>
		<title>OBJ+MTL exporter</title>
		<link>https://swapi.wordpress.com/2007/03/25/objmtl-exporter/</link>
					<comments>https://swapi.wordpress.com/2007/03/25/objmtl-exporter/#respond</comments>
		
		<dc:creator><![CDATA[Dr. Goulu]]></dc:creator>
		<pubDate>Sun, 25 Mar 2007 15:12:00 +0000</pubDate>
				<category><![CDATA[macro]]></category>
		<category><![CDATA[solidworks api]]></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 : [&#8230;]]]></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>
]]></content:encoded>
					
					<wfw:commentRss>https://swapi.wordpress.com/2007/03/25/objmtl-exporter/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/32a7bf56f7bc0ce665dd9ffc672186c547c5345f5532735f91d7a2a13968e043?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>https://swapi.wordpress.com/2007/01/30/layers/</link>
					<comments>https://swapi.wordpress.com/2007/01/30/layers/#comments</comments>
		
		<dc:creator><![CDATA[Dr. Goulu]]></dc:creator>
		<pubDate>Tue, 30 Jan 2007 21:03:53 +0000</pubDate>
				<category><![CDATA[macro]]></category>
		<category><![CDATA[solidworks api]]></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 [&#8230;]]]></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>
]]></content:encoded>
					
					<wfw:commentRss>https://swapi.wordpress.com/2007/01/30/layers/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/32a7bf56f7bc0ce665dd9ffc672186c547c5345f5532735f91d7a2a13968e043?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>https://swapi.wordpress.com/2007/01/12/viewsize/</link>
					<comments>https://swapi.wordpress.com/2007/01/12/viewsize/#comments</comments>
		
		<dc:creator><![CDATA[Dr. Goulu]]></dc:creator>
		<pubDate>Fri, 12 Jan 2007 21:15:39 +0000</pubDate>
				<category><![CDATA[macro]]></category>
		<category><![CDATA[solidworks api]]></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 [&#8230;]]]></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>
]]></content:encoded>
					
					<wfw:commentRss>https://swapi.wordpress.com/2007/01/12/viewsize/feed/</wfw:commentRss>
			<slash:comments>2</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/32a7bf56f7bc0ce665dd9ffc672186c547c5345f5532735f91d7a2a13968e043?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>https://swapi.wordpress.com/2007/01/12/addweldmass/</link>
					<comments>https://swapi.wordpress.com/2007/01/12/addweldmass/#comments</comments>
		
		<dc:creator><![CDATA[Dr. Goulu]]></dc:creator>
		<pubDate>Fri, 12 Jan 2007 17:08:32 +0000</pubDate>
				<category><![CDATA[macro]]></category>
		<category><![CDATA[solidworks api]]></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 [&#8230;]]]></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>
]]></content:encoded>
					
					<wfw:commentRss>https://swapi.wordpress.com/2007/01/12/addweldmass/feed/</wfw:commentRss>
			<slash:comments>1</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/32a7bf56f7bc0ce665dd9ffc672186c547c5345f5532735f91d7a2a13968e043?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>https://swapi.wordpress.com/2007/01/11/scale-texture/</link>
					<comments>https://swapi.wordpress.com/2007/01/11/scale-texture/#respond</comments>
		
		<dc:creator><![CDATA[Dr. Goulu]]></dc:creator>
		<pubDate>Thu, 11 Jan 2007 21:26:17 +0000</pubDate>
				<category><![CDATA[macro]]></category>
		<category><![CDATA[solidworks api]]></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 [&#8230;]]]></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>
]]></content:encoded>
					
					<wfw:commentRss>https://swapi.wordpress.com/2007/01/11/scale-texture/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://0.gravatar.com/avatar/32a7bf56f7bc0ce665dd9ffc672186c547c5345f5532735f91d7a2a13968e043?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">Dr. Goulu</media:title>
		</media:content>
	</item>
		<item>
		<title>About DynaBits</title>
		<link>https://swapi.wordpress.com/2007/01/01/about-dynabits/</link>
					<comments>https://swapi.wordpress.com/2007/01/01/about-dynabits/#respond</comments>
		
		<dc:creator><![CDATA[CADSharp]]></dc:creator>
		<pubDate>Mon, 01 Jan 2007 11:00:01 +0000</pubDate>
				<category><![CDATA[solidworks api]]></category>
		<guid isPermaLink="false">http://swapi.wordpress.com/?p=30</guid>

					<description><![CDATA[DynaBits is now out of business. Read its story, achievements and my personal (bitter) thoughts about this defunct startup. History 1999/2 Ph. Guglielmetti starts his own business as a consultant for technical software (LabView, Matlab, &#8230;) 1999/6 reseller of MSC Working Model (Visual Nastran) 1999/10 first contact with SolidWorks through e-Systems 1999/12 purchase of source [&#8230;]]]></description>
										<content:encoded><![CDATA[<p>DynaBits is now out of business. Read its story, achievements and my personal (bitter) thoughts about this defunct startup.</p>
<p class="apiRemarksText" style="margin-top:0;font-weight:normal;margin-bottom:0;font-style:normal;"><span id="more-30"></span></p>
<h4>History</h4>
<ul>
<li>1999/2 Ph. Guglielmetti starts his own business as a consultant for technical software (LabView, Matlab, &#8230;)</li>
<li>1999/6 reseller of MSC Working Model (Visual Nastran)</li>
<li>1999/10 first contact with <a href="http://www.goulu.net/wordpress/wp-admin/SolidWorks">SolidWorks</a> through <a href="http://www.e-systems.ch">e-Systems</a></li>
<li>1999/12 purchase of source code of the &#8220;ToolSuite&#8221; from ShapeSolve ltd.</li>
<li>2000/3 becomes SolidWorks &#8220;Solution Partner&#8221;</li>
<li>2000/6 start of development of GeniusWorks.</li>
<li>2000/11 SolidWorks purchases CimLogic and its Toolbox, killing all other partner library products</li>
<li>2001/1 US provisional patent granted on GeniusWorks technology</li>
<li>2001/2 GeniusWorks demonstrated at SolidWorks World in Orlando, FL</li>
<li>2002/2 SolidWorks World Las Vegas, NV</li>
<li>2002/3 DynaBits sàrl incorported. partners : Ph. Guglielmetti, e-Systems and F. Georgeon</li>
<li>2002/10 4 people working full time.</li>
<li>2003/1 SolidWorks now offers ToolBox in their &#8220;Office&#8221; bundle almost for free.</li>
<li>2003/6 GeniusWorks doesn’t sell. Running out of money, back to the single man-company&#8230;</li>
<li>2003/9 SolidSketch released</li>
<li>2004/3 <a href="http://www.goulu.net/wordpress/wp-admin/cadML">cadML</a> and cadDoc released</li>
<li>2004/3 consulting and development for famous swiss watchmakers</li>
<li>2004/9/1 Business taken over by <a href="http://www.e-systems.ch">e-Systems</a></li>
</ul>
<h4>the Bottom line</h4>
<p>Developing CAD add-ins is fun, but definitely doesn’t pay back because:</p>
<ul>
<li>reliability standard is high, so are development and support costs.</li>
<li>resellers are not interested in selling add-ins, unless they are required to win a market against a competitor.</li>
<li>users don’t purchase, and even don’t search add-ins direct on the internet. If they do, they use your shareware without paying.</li>
<li>CAD editors integrate your good ideas (or your competitor’s) in their core product. &#8220;Partnerships&#8221; are really asymmetric. See some proos below:</li>
</ul>
<h4>Ex-products</h4>
<ul>
<li>SolidPlus (2004) (called SolidSketch in 2003) add-ins for SolidWorks : wraps a sketch on a surface (very limited in SW 2004), Multiple sweeps, 3D curve-driven patterns (very limited in SW 2006)</li>
<li>Many various Macros for SolidWorks developed over time, often as responses to requests on the comp.cad.solidworks newsgroup.</li>
<li>TableWizard Hole Table (1999) 4 years before SolidWorks implemented the same functionality in SW 2004. Is now specialized for watchmakers needs.</li>
<li>MathSurf and SketchFile macros to create mathematically defined curves and surfaces</li>
<li>Contact macro to keep 2 parts in contact while moving and create a relative position table that can be used for CAM.</li>
<li>UltraLight (2001) speeds up work with large assemblies by creating configurations with small features and parts suppressed, and sub-assemblies replaced by &#8220;shrink-wrapped&#8221; sufaces. SW2003 introduced the &#8220;save assembly as surfaces&#8221;&#8230;</li>
<li>GeniusWorX (2001), an intelligent library of standard fasteners with automatic insertion capability based on a much more advanced technology than Toolbox. SW 2006 introduces Smart Components, which can adapt their size to the geometry they&#8217;re dragged onto, 4 years after GeniusWorks &#8230;</li>
<li>GeniusExplorer (2003) a library browser that embeds the feature palette functionality in the feature/property manager. SolidWorks 2005 now offers exactly the same functionality.</li>
<li>RedLight (2003), add-in to block rebuilds and account time spent in editing and rebuilding each model. SolidWorks 2005 introduced a way to block assembly rebuilds&#8230;</li>
<li>Spliner (2003), a SolidWorks to display length of selected segments, curves and edges in the status bar. SolidWorks 2005 has an improved &#8220;measurement tool&#8221; that offers exactly the same functionality, except that it doesn’t update the length of a spline while being edited, as Spliner does.</li>
<li>and much more&#8230;</li>
</ul>
]]></content:encoded>
					
					<wfw:commentRss>https://swapi.wordpress.com/2007/01/01/about-dynabits/feed/</wfw:commentRss>
			<slash:comments>0</slash:comments>
		
		
		
		<media:content url="https://2.gravatar.com/avatar/844f7a313a275f4f8f1033dc3a1c73228b682308d045e8ccc52bc623098c96f8?s=96&#38;d=identicon&#38;r=G" medium="image">
			<media:title type="html">cadsharp</media:title>
		</media:content>
	</item>
	</channel>
</rss>
