<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0">
    <title>Mod the Machine</title>
    
    
    <link rel="alternate" type="text/html" href="http://modthemachine.typepad.com/my_weblog/" />
    <id>tag:typepad.com,2003:weblog-1713640</id>
    <updated>2012-05-31T11:02:27-07:00</updated>
    <subtitle>Discussing Autodesk Inventor's Application Programming Interface (API)</subtitle>
    <generator uri="http://www.typepad.com/">TypePad</generator>
    <atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/modthemachine" /><feedburner:info uri="modthemachine" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://hubbub.api.typepad.com/" /><entry>
        <title>Get strokes for 2d and 3d transient wireframe geometry</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/CI4JPf_WqoM/get-strokes-for-2d-and-3d-transient-wireframe-geometry.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/get-strokes-for-2d-and-3d-transient-wireframe-geometry.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc68834016766f667a1970b</id>
        <published>2012-05-31T11:02:27-07:00</published>
        <updated>2012-05-31T11:06:44-07:00</updated>
        <summary>An enhancement in the Inventor 2013 API allows you to get strokes for 2d and 3d transient geometry. One reason why you may want to do this is to approximate sketch geometry. The new method is GetStrokes of the CurveEvaluator...</summary>
        <author>
            <name>Wayne Brill</name>
        </author>
        <category scheme="http://www.sixapart.com/ns/types#category" term="Parts" />
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>An enhancement in the Inventor 2013 API allows you to get strokes for 2d and 3d transient geometry. One reason why you may want to do this is to approximate sketch geometry. The new method is GetStrokes of the CurveEvaluator and Curve2dEvaluator objects. To get the transient geometry (CurveEvaluator) from the sketch entity, use the Geometry.Evaluator property.</p>
<p><strong>New 2013 method used to get strokes</strong></p>
<ul>
<li>CurveEvaluator.GetStrokes </li>
<li>Curve2dEvaluator.GetStrokes </li>
</ul>
<p><strong>VBA Example: </strong></p>
<p>Please keep in mind that we only recommend using VBA for prototyping and learning the API but do not recommend using VBA in production.</p>
<p>To try out this example create a 3D Sketch. I used a helical curve as you can see in the screenshot. When you run the Approximate3DSketchGeometry procedure it prompts you to select a 3d entity and then displays an InputBox asking for the chord height tolerance. This value will be used as the maximum of deviation. (How far off can these line segments be to the curve). I used .25. This will be centimeters in database units.</p>
<p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016766f66780970b-pi"><img alt="image" border="0" height="356" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016766f6678b970b-pi" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" width="456" /></a></p>
<p>A MsgBox is used to ask if you want to use existing client graphics, create new client graphics or just cancel. The lines that you see that approximate the curve, are drawn using client graphics. Here is the result after running the procedure:</p>
<p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ebf7e6a4970c-pi"><img alt="image" border="0" height="277" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163060297ab970d-pi" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" width="466" /></a></p>
<p><strong>VBA Code:</strong></p>
<p><span style="background-color: #ffffff;">'<span style="color: #0000ff;"> Draws client graphics that is an approximation <br />' of the selected curve. <br />' To use this have a part open that contains <br />' a 3D skech that contains curves. <br /></span></span>Public Sub Approximate3DSketchGeometry() <br />    Dim partDoc As PartDocument <br />    Set partDoc = _ <br />              ThisApplication.ActiveDocument <br />    <br />   <span style="color: #0000ff;">' Have the user select a sketch entity. <br /></span>    Dim selectObj As SketchEntity3D <br />    Set selectObj = ThisApplication. _ <br />                    CommandManager.Pick _ <br />                    (kSketch3DCurveFilter, _ <br />                    "Select 3D sketch entity") <br />    If selectObj Is Nothing Then <br />        On Error Resume Next <br />        Call partDoc.ComponentDefinition _ <br />        .ClientGraphicsCollection.Item _ <br />                                ("Test").Delete <br />        Call partDoc.GraphicsDataSetsCollection _ <br />                             .Item("Test").Delete <br />        ThisApplication.ActiveView.Update <br />        Exit Sub <br />    End If <br />    <br />   <span style="color: #0000ff;">' Get the tolerance to approximate with. <br /></span>    Dim tolerance As Double <br />    tolerance = Val(InputBox _ <br />     ("Enter the chord height tolerance:", _ <br />                       "Tolerance", "0.25")) <br />    <br />   <span style="color: #0000ff;">' Get the evaluator from the curve. <br /></span>    Dim eval As CurveEvaluator <br />    Set eval = selectObj.Geometry.Evaluator <br />    <br />   <span style="color: #0000ff;">' Get the parameter extents. <br /></span>    Dim startParam As Double <br />    Dim endParam As Double <br />    Call eval.GetParamExtents _ <br />                        (startParam, endParam) <br />    <br />    Dim vertexCount As Long <br />    Dim vertexCoords() As Double <br />    Call eval.GetStrokes(startParam, endParam, _ <br />            tolerance, vertexCount, vertexCoords) <br />    <br />    ' <span style="color: #0000ff;">Create a client graphics object. <br />    ' If one already exists, give the user <br />    ' the option of re-using it, or creating <br />    ' a new one. <br /></span>    Dim graphics As ClientGraphics <br />    Dim graphicsData As GraphicsDataSets <br />    On Error Resume Next <br />    Set graphics = partDoc.ComponentDefinition. _ <br />            ClientGraphicsCollection.Item("Test") <br />    On Error GoTo 0 <br />    If graphics Is Nothing Then <br />        Set graphics = partDoc. _ <br />      ComponentDefinition.ClientGraphicsCollection _ <br />                                      .Add("Test") <br />        Set graphicsData = partDoc. _ <br />           GraphicsDataSetsCollection.Add("Test") <br />    Else <br />        Dim answer As VbMsgBoxResult <br />        answer = MsgBox _ <br />        ("Yes = existing. No = new Cancel. = quit.", _ <br />                         vbYesNoCancel + vbQuestion) <br />        If answer = vbNo Then <br />            On Error Resume Next <br />            graphics.Delete <br />            partDoc.GraphicsDataSetsCollection _ <br />                              .Item("Test").Delete <br />            On Error GoTo 0 <br />            <br />            Set graphics = partDoc.ComponentDefinition _ <br />                  .ClientGraphicsCollection.Add("Test") <br />            Set graphicsData = partDoc. _ <br />                  GraphicsDataSetsCollection.Add("Test") <br />        ElseIf answer = vbYes Then <br />            Set graphicsData = partDoc. _ <br />                GraphicsDataSetsCollection.Item("Test") <br />        ElseIf answer = vbCancel Then <br />            If Not graphics Is Nothing Then <br />                graphics.Delete <br />                partDoc.GraphicsDataSetsCollection _ <br />                                .Item("Test").Delete <br />                ThisApplication.ActiveView.Update <br />                Exit Sub <br />            End If <br />        End If <br />    End If <br />    <br />    Dim coordSet As GraphicsCoordinateSet <br />    Set coordSet = graphicsData.CreateCoordinateSet(1) <br />    Call coordSet.PutCoordinates(vertexCoords)</p>
<p>   <span style="color: #0000ff;">' Create a graphics node. <br /></span>    Dim node As GraphicsNode <br />    Set node = graphics.AddNode(1) <br />    <br />    <span style="color: #0000ff;">' Create a line strip using the calculated coordinates.</span> <br />    Dim lineStrip As LineStripGraphics <br />    Set lineStrip = node.AddLineStripGraphics <br />    lineStrip.CoordinateSet = coordSet <br />    <br />    ThisApplication.ActiveView.Update <br />End Sub</p>
<p>-Wayne</p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/get-strokes-for-2d-and-3d-transient-wireframe-geometry.html</feedburner:origLink></entry>
    <entry>
        <title>Transient wire body  Create ruled surface</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/ojXfWxArp8s/transient-wire-body-create-ruled-surface.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/transient-wire-body-create-ruled-surface.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc68834016305c60ba3970d</id>
        <published>2012-05-23T14:24:22-07:00</published>
        <updated>2012-05-23T14:51:50-07:00</updated>
        <summary>Transient B-Rep allows you to define B-Rep data from scratch and one of the enhancements to the Inventor 2013 API allows you to define a new wire body. In the previous release you could only build surfaces and solids. One...</summary>
        <author>
            <name>Wayne Brill</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>Transient B-Rep allows you to define B-Rep data from scratch and one of the enhancements to the Inventor 2013 API allows you to define a new wire body. In the previous release you could only build surfaces and solids. One reason to create a wire body is for input to other modeling operations.</p>
<p><span style="color: #232323;"><strong>New 2013 object, properties and method used to create a wire body ruled surface:</strong></span></p>
<ul>
<li>WireDefinition Object </li>
<li>FaceShellDefinition.WireDefinitions Property </li>
<li>WireDefinition.WireEdgeDefinitions Property </li>
<li>TransientBRep.CreateRuledSurface Method </li>
</ul>
<p><strong>VBA Example: </strong></p>
<p>Please keep in mind that we only recommend using VBA for prototyping and learning the API but do not recommend using VBA in production).</p>
<p>This example shows how to use this new functionality to create a ruled surface. After running this procedure a NonParametricBaseFeature will be added to the part file.</p>
<p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016766ba11ef970b-pi"><img alt="image" border="0" height="298" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016305c60b91970d-pi" style="background-image: none; padding-left: 0px; padding-right: 0px; display: inline; padding-top: 0px; border-width: 0px;" title="image" width="578" /></a></p>
<p><strong>VBA Code:</strong></p>
<p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 9pt;"><span style="color: #0000ff;">' Demonstrate creating a transient ruled surface.      <br />' This sample uses all straight line segments       <br />' for each of the sections.       <br />' A part document must be open.       <br /></span>Public Sub RuledSurf()     <br /> <span style="color: #0000ff;">' Get the transient B-Rep and Geometry objects.</span> <br /> Dim tBRep As TransientBRep     <br /> Set tBRep = ThisApplication.TransientBRep     <br /> <br /> Dim tg As TransientGeometry     <br /> Set tg = ThisApplication.TransientGeometry     <br /> <br /> <span style="color: #0000ff;">' Create a new surface body definition.</span> <br /> Dim bodyDef As SurfaceBodyDefinition     <br /> Set bodyDef = tBRep.CreateSurfaceBodyDefinition     <br /> <br /> '<span style="color: #0000ff;"> Add a lump, shell, and wire.</span> <br /> Dim lumpDef As LumpDefinition     <br /> Set lumpDef = bodyDef.LumpDefinitions.Add     <br /> <br /> Dim shellDef As FaceShellDefinition     <br /> Set shellDef = lumpDef.FaceShellDefinitions.Add     <br /> <br /> Dim wireDef As WireDefinition     <br /> Set wireDef = shellDef.WireDefinitions.Add     <br /> <br /> <span style="color: #0000ff;">' Create coordinate points and use those      <br /> ' to create vertex definitions.       <br /></span> Dim pnts(2) As Point     <br /> Set pnts(0) = tg.CreatePoint(0, 0, 0)     <br /> Set pnts(1) = tg.CreatePoint(10, 3, 0)     <br /> Set pnts(2) = tg.CreatePoint(20, 0, 0)     <br /> Dim vertexDefs(2) As VertexDefinition     <br /> Set vertexDefs(0) = _     <br /> bodyDef.VertexDefinitions.Add(pnts(0))     <br /> Set vertexDefs(1) = _     <br /> bodyDef.VertexDefinitions.Add(pnts(1))     <br /> Set vertexDefs(2) = _     <br /> bodyDef.VertexDefinitions.Add(pnts(2))     <br /> <br /> <span style="color: #0000ff;">' Create two wire edges, passing through the      <br /> ' three vertices.       <br /></span> Call wireDef.WireEdgeDefinitions.Add _     <br /> (vertexDefs(0), vertexDefs(1), _     <br /> tg.CreateLineSegment(pnts(0), pnts(1)))     <br /> Call wireDef.WireEdgeDefinitions.Add _     <br /> (vertexDefs(1), vertexDefs(2), _     <br /> tg.CreateLineSegment(pnts(1), pnts(2)))     <br /> <br /> <span style="color: #0000ff;">' Create a second wire definition.      <br /></span> Dim wireDef2 As WireDefinition     <br /> Set wireDef2 = shellDef.WireDefinitions.Add     <br /> <br /> <span style="color: #0000ff;">' Create coordinate points and use those to      <br /> ' create vertex definitions.       <br /></span> Set pnts(0) = tg.CreatePoint(-5, 0, 10)     <br /> Set pnts(1) = tg.CreatePoint(10, 6, 10)     <br /> Set pnts(2) = tg.CreatePoint(25, 0, 10)     <br /> <br /> Set vertexDefs(0) = _     <br /> bodyDef.VertexDefinitions.Add(pnts(0))     <br /> Set vertexDefs(1) = _     <br /> bodyDef.VertexDefinitions.Add(pnts(1))     <br /> Set vertexDefs(2) = _     <br /> bodyDef.VertexDefinitions.Add(pnts(2))     <br /> <br /> <span style="color: #0000ff;">' Create two edges, passing through the      <br /> ' three vertices.       <br /></span> Call wireDef2.WireEdgeDefinitions.Add _     <br /> (vertexDefs(0), vertexDefs(1), _     <br /> tg.CreateLineSegment(pnts(0), pnts(1)))     <br /> Call wireDef2.WireEdgeDefinitions.Add _     <br /> (vertexDefs(1), vertexDefs(2), _     <br /> tg.CreateLineSegment(pnts(1), pnts(2)))     <br /> <br /> <span style="color: #0000ff;">' Create a body using the defined wires.      <br /></span> Dim errors As NameValueMap     <br /> Set errors = ThisApplication.TransientObjects. _     <br /> CreateNameValueMap     <br /> Dim body1 As SurfaceBody     <br /> Set body1 = bodyDef. _     <br /> CreateTransientSurfaceBody(errors)     <br /> <br /> <span style="color: #0000ff;">' Create a ruled surface between the two      <br /> ' wire bodies.</span> <br /> Dim ruled As SurfaceBody     <br /> Set ruled = tBRep.CreateRuledSurface _     <br /> (body1.Wires.Item(1), body1.Wires.Item(2))     <br /> <br /> <span style="color: #0000ff;">' Get the part component definition of the      <br /> ' active document.       <br /></span> Dim partDoc As PartDocument     <br /> Set partDoc = ThisApplication.ActiveDocument     <br /> Dim partDef As PartComponentDefinition     <br /> Set partDef = partDoc.ComponentDefinition     <br /> <br /> <span style="color: #0000ff;">' Create a base body feature of the      <br /> ' transient body.</span> <br /> Dim baseBody As NonParametricBaseFeature     <br /> Set baseBody = _     <br /> partDef.Features. _     <br /> NonParametricBaseFeatures.Add(ruled)     <br /> <br /> <span style="color: #0000ff;">' Change the result work surface so      <br /> ' it's not translucent.       <br /></span> baseBody.SurfaceBodies.Item(1). _     <br /> Parent.Translucent = False     <br /> <br /> ThisApplication.ActiveView.Fit     <br />End Sub</p>
<p>-Wayne</p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/transient-wire-body-create-ruled-surface.html</feedburner:origLink></entry>
    <entry>
        <title>Autodesk Manufacturing DevCamp and DevLab</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/cn8oZisN8W4/autodesk-manufacturing-devcamp-and-devlab.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/autodesk-manufacturing-devcamp-and-devlab.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc68834016305b39804970d</id>
        <published>2012-05-21T12:17:47-07:00</published>
        <updated>2012-05-21T12:17:47-07:00</updated>
        <summary>There’s less than a month to go till the Autodesk Manufacturing DevCamp being held in Portland June 13-14. A highlight for me is the DevLab on the 15th. This is an opportunity for you to bring your code and get...</summary>
        <author>
            <name>Brian Ekins</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>There’s less than a month to go till the Autodesk Manufacturing DevCamp being held in Portland June 13-14.  A highlight for me is the DevLab on the 15th.  This is an opportunity for you to bring your code and get one-on-one help.  I hope to see you at DevCamp, DevLab, or both.  Here’s the official blurb:</p>  <blockquote>   <p>Whether you are a beginner interested in getting started extending <b>Inventor, Inventor ETO, PLM 360 or Vault</b> through their APIs, or an expert developer looking to gain insights directly from Autodesk Engineers and Product Managers, the Manufacturing DevCamp will get you there.  There are classes for getting started developing Cloud and Mobile apps too!  Check out the class offering at <b><a href="http://tinyurl.com/7zdp77p">http://tinyurl.com/7zdp77p</a></b></p> </blockquote>  <p>-Brian</p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/autodesk-manufacturing-devcamp-and-devlab.html</feedburner:origLink></entry>
    <entry>
        <title>ADN Manufacturing DevBlog</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/9SYLPP1iez4/adn-manufacturing-devblog.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/adn-manufacturing-devblog.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc6883401676695b9c3970b</id>
        <published>2012-05-18T08:15:13-07:00</published>
        <updated>2012-05-18T08:15:35-07:00</updated>
        <summary>Autodesk has a program to help developers working with Autodesk technology called the Autodesk Developer Network (ADN). Members of ADN receive access to software, individual support with their problems, and access to exclusive events each year discussing the new features...</summary>
        <author>
            <name>Brian Ekins</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p><a href="http://adndevblog.typepad.com/manufacturing/"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="DevBlog" border="0" alt="DevBlog" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc6883401676695b9b4970b-pi" width="494" height="96" /></a></p>  <p>Autodesk has a program to help developers working with Autodesk technology called the Autodesk Developer Network (ADN).  Members of ADN receive access to software, individual support with their problems, and access to exclusive events each year discussing the new features in the upcoming releases.  You can read more about ADN <a href="http://www.autodesk.com/developers">here</a>.  In addition to those benefits, members of ADN have access to a large pool of answers to previous common questions.  </p>  <p>Good news for everyone else is that they’ve decided to make these answers open to everyone and have begun transferring them over into a blog format.  Answers to new questions will also be posted into the blog.  You can access this blog at: <a href="http://adndevblog.typepad.com/manufacturing/">http://adndevblog.typepad.com/manufacturing/</a>.  You can quickly access the initial welcome page <a href="http://adndevblog.typepad.com/manufacturing/2012/03/welcome.html">here</a>.</p>  <p>-Brian</p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/adn-manufacturing-devblog.html</feedburner:origLink></entry>
    <entry>
        <title>Inventor 2013 SDK and API Help Update</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/cy01jJCt_u8/inventor-2013-sdk-and-api-help-update.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/inventor-2013-sdk-and-api-help-update.html" thr:count="8" thr:updated="2012-05-24T23:19:03-07:00" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc688340163059d6069970d</id>
        <published>2012-05-17T11:04:45-07:00</published>
        <updated>2012-05-17T11:05:00-07:00</updated>
        <summary>The SDK and API Help that went out with Inventor 2013 were found to have a few issues that we want to correct. SDK The initial SDK that was delivered with Inventor 2013 tried to remain compatible with Visual Studio...</summary>
        <author>
            <name>Brian Ekins</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>The SDK and API Help that went out with Inventor 2013 were found to have a few issues that we want to correct.  </p>  <p><strong><font size="3">SDK</font></strong>     <br />The initial SDK that was delivered with Inventor 2013 tried to remain compatible with Visual Studio 2008.  However, to best develop for Inventor 2013 you need to be using Visual Studio 2010.  The Add-In wizards provided as part of the SDK have been updated so they now use Visual Studio 2010.  The primary reason for needing Visual Studio 2010 is that Inventor 2013 is now based on .Net Framework 4.  The interop library for Inventor is built with .Net Framework 4 and to use it your project needs to target .Net Framework 4.</p>  <p>As part of this work to update the wizards we also cleaned up their installation.  In previous releases of Inventor you needed to perform two steps to install the wizards.  First you had to install DeveloperTools.msi to install the various samples and programming tools.  Then you needed to install InventorWizards.msi to install the add-in wizards.  This second step is no longer needed as the wizards are now installed as part of the Developer Tools installation.</p>  <p>To use this update you’ll need to download the new DeveloperTools.msi from <a href="http://www.autodesk.com/developinventor">www.autodesk.com/developinventor</a>.  It’s about two-thirds of the way down the page, as shown below.  To use the update, follow the directions as outlined in the picture below.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168eb92f974970c-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="DeveloperToolsUpdate" border="0" alt="DeveloperToolsUpdate" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163059d604c970d-pi" width="490" height="532" /></a></p>  <p><strong><font size="3">API Help       <br /></font></strong>Besides updating the SDK, there have also been some fixes made to the API help.  No big enhancements from what was delivered with Inventor 2013 but a lot of smaller fixes and enhancements, including the “What’s New” section.  You can download the update from the same location as the SDK, <a href="http://www.autodesk.com/developinventor">www.autodesk.com/developinventor</a>.  It’s near the top of the page, along with instructions of where to put the file on your system to replace the original help, as shown below.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163059d6058970d-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="HelpUpdate" border="0" alt="HelpUpdate" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016766913a81970b-pi" width="490" height="251" /></a>  </p>      <p>-Brian</p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/inventor-2013-sdk-and-api-help-update.html</feedburner:origLink></entry>
    <entry>
        <title>New Inventor API Help</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/qAlhKrHgXts/new-inventor-api-help.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/new-inventor-api-help.html" thr:count="1" thr:updated="2012-05-19T08:14:50-07:00" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc688340167668b38ef970b</id>
        <published>2012-05-16T12:44:32-07:00</published>
        <updated>2012-05-16T12:44:53-07:00</updated>
        <summary>You may have noticed that the Inventor API help has had some issues over the past several releases. We were using a commercial product for creating the help that didn’t work very well with the type of API that Inventor...</summary>
        <author>
            <name>Brian Ekins</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>You may have noticed that the Inventor API help has had some issues over the past several releases.  We were using a commercial product for creating the help that didn’t work very well with the type of API that Inventor has.  It forced us to do things in certain ways that weren’t really what we wanted and made it difficult to add some of the features that we wanted.</p>  <p>Inventor 2013 introduces an entirely new help system.  Both the system that generates the help and the result is quite different from what we had before.  I hope you see it as an improvement but would like very much to hear your suggestions on what will make it better.  We are using a new help generation system and no longer have the same limitations.  The new help is shown below.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168eb8cfe65970c-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="HelpIntro" border="0" alt="HelpIntro" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340167668b38d1970b-pi" width="479" height="312" /></a></p>  <p>The transition from the old to the new help doesn’t come without some hiccups.  The old help system used a proprietary database and the translator that converted it into the new help wasn’t 100% accurate.  We’ve identified and fixed many of the issues but I’m sure there are still a lot more out there.  With over 21,500 help topics it’s difficult to check every one.  At the bottom of every topic you’ll see the link shown below and as you notice any problems or have any suggestions on improving the help please feel free to use it.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016305976753970d-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="HelpComment" border="0" alt="HelpComment" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016305976762970d-pi" width="240" height="104" /></a></p>  <p>One feature that was in the previous help and is missing in the new help is the index.  It’s missing because we ran out of time before the release was due.  Plan on seeing the index return in the future.  Even though the index is missing, the search capability does work and will find things the index won’t.  There were a few other things that we ran out of time on too, so there are plans for future improvements but I would like to hear your ideas too.</p>  <p>I think one big improvement over the previous help is how the code samples are presented.  Any topic that’s demonstrated in any of the samples now has a <strong>Samples</strong> section in the topic that lists the samples along with links to each one.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc6883401630597676e970d-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="HelpLink" border="0" alt="HelpLink" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168eb8cfe86970c-pi" width="479" height="361" /></a></p>  <p> </p>  <p>The samples are no longer included in the contents of the various object, method, or property topics but are topics by themselves.  This allows them to be categorized and supports the linking as shown above.  I think the current categorization needs some work so please let me know if you have any suggestions.  The new help system also now supports samples in multiple languages and it’s easy for us to find out which topics don’t have samples so we can concentrate on adding samples to demonstrate more functionality.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016305976779970d-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="HelpSamples" border="0" alt="HelpSamples" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016305976780970d-pi" width="479" height="309" /></a></p>  <p>-Brian</p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/new-inventor-api-help.html</feedburner:origLink></entry>
    <entry>
        <title>Creating Geometric Constraints in a Sketch</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/QCnv301Zlf8/creating-geometric-constraints-in-a-sketch.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/creating-geometric-constraints-in-a-sketch.html" thr:count="0" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc688340163057bb06a970d</id>
        <published>2012-05-11T16:22:21-07:00</published>
        <updated>2012-05-11T16:23:01-07:00</updated>
        <summary>In the previous post in this series I discussed creating sketch geometry. The last post ended by showing how to create lines and arcs that define the shape of a slot. It also illustrated that the lines and arcs didn’t...</summary>
        <author>
            <name>Brian Ekins</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>In the <a href="http://modthemachine.typepad.com/my_weblog/2012/04/drawing-in-a-sketch.html">previous post</a> in this series I discussed creating sketch geometry.  The last post ended by showing how to create lines and arcs that define the shape of a slot.  It also illustrated that the lines and arcs didn’t behave quite like expected because of missing constraints.  </p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340167666f844e970b-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="ModifiedSlotResult" border="0" alt="ModifiedSlotResult" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340167666f8451970b-pi" width="346" height="167" /></a></p>  <p>In this post we’ll look at how to create geometric sketch constraints using the API. There are two types of sketch constraints; geometric and dimension.  I’ll focus on geometric constraints for this post.</p>  <p>Geometric sketch constraints are used extensively within Inventor, probably in more ways than you would initially think.  Below is a portion of the sketch ribbon, where I’ve highlighted the commands you typically think of as the geometric constraint commands.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163057bb029970d-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="SketchConstraintCommands" border="0" alt="SketchConstraintCommands" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168eb716519970c-pi" width="479" height="94" /></a></p>  <p> </p>  <p>These constraints define the behavior of sketch geometry.  There are two types of geometric constraints; those that act on a single geometric entity and those that define some type of relationship between two geometric entities.  For example, the Fix (Ground), Horizontal, and Vertical constraints act on a single entity, whereas all of the others control two entities.</p>  <p>All of these are quite easy to use through the API.  The diagram below shows the object model for 2d sketch geometric constraints.  You’ve already learned from the previous posts how to access a sketch through the API.  The SketchLines and SketchArcs collections on the Sketch were used to drawing the slot geometry.  Now you’ll use the GeometricConstraints collection to add the needed geometric constraints.  Unlike the sketch geometry where there was a unique collection for each type of geometry, for geometric constraints there is a single collection for all of the constraint types.  The GeometricConstraints collections supports many Add methods to allow the creation of each of the types of constraints.  It’s also through this collection where you can access existing constraints.  </p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163057bb032970d-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="GeomConstraintsObjectModel" border="0" alt="GeomConstraintsObjectModel" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163057bb03e970d-pi" width="475" height="323" /></a></p>  <p>Below is the program from the last post that creates the slot shape.  The new portion of code at the bottom, highlighted in yellow, creates the constraints.  You can see that it uses the variables that reference geometry created earlier in the program.</p>  <p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 8pt"><strong><font color="#0000ff">' Get a reference to the SketchPoints collection.</font></strong>     <br />Dim points As Inventor.SketchPoints = sketch.SketchPoints     <br />    <br /><font color="#0000ff"><strong>' Get a reference to the SketchLines collection.        <br /></strong></font>Dim lines As Inventor.SketchLines = sketch.SketchLines     <br />    <br /><font color="#0000ff"><strong>' Get a reference to the SketchArcs collection.</strong></font>     <br />Dim arcs As Inventor.SketchArcs = sketch.SketchArcs     <br />    <br /><font color="#0000ff"><strong>' Create the sketch points.</strong></font>     <br />Dim pointArray(5) As Inventor.SketchPoint     <br />pointArray(0) = points.Add(tg.CreatePoint2d(0, 1), False)     <br />pointArray(1) = points.Add(tg.CreatePoint2d(0, 0), False)     <br />pointArray(2) = points.Add(tg.CreatePoint2d(0, -1), False)     <br />pointArray(3) = points.Add(tg.CreatePoint2d(4, -1), False)     <br />pointArray(4) = points.Add(tg.CreatePoint2d(4, 0), False)     <br />pointArray(5) = points.Add(tg.CreatePoint2d(4, 1), False)     <br />    <br /><font color="#0000ff"><strong>' Draw the geometry.</strong></font>     <br />Dim arc1 As Inventor.SketchArc     <br />arc1 = arcs.AddByCenterStartEndPoint(pointArray(1), pointArray(0), _     <br />                                     pointArray(2))     <br />    <br />Dim line1 As Inventor.SketchLine     <br />line1 = lines.AddByTwoPoints(pointArray(2), pointArray(3))     <br />    <br />Dim arc2 As Inventor.SketchArc     <br />arc2 = arcs.AddByCenterStartEndPoint(pointArray(4), pointArray(3), _     <br />                                     pointArray(5))     <br />    <br />Dim line2 As Inventor.SketchLine     <br />line2 = lines.AddByTwoPoints(pointArray(5), pointArray(0))    <br /><span style="background: #eeee00">     <br /><font color="#0000ff"><strong>' Get a reference to the GeometricConstraints collection.         <br /></strong></font>Dim geomConstraints As Inventor.GeometricConstraints       <br />geomConstraints = sketch.GeometricConstraints       <br />      <br /><font color="#0000ff"><strong>' Create the four tangent constraints.</strong></font>       <br />geomConstraints.AddTangent(arc1, line1)       <br />geomConstraints.AddTangent(line1, arc2)       <br />geomConstraints.AddTangent(arc2, line2)       <br />geomConstraints.AddTangent(line2, arc1)       <br />      <br /><font color="#0000ff"><strong>' Create a parallel constraint.</strong></font>       <br />geomConstraints.AddParallel(line1, line2)       <br />      <br /><font color="#0000ff"><strong>' Create a horizontal constraint.</strong></font>       <br />geomConstraints.AddHorizontal(line1)       <br /></span></p>  <p>Creating any of the other types of constraints is similar to the above with the difference being the add method that’s used. The API help is a great resource to help in understanding the various add methods of the GeometricConstraints object.</p>  <p>I mentioned earlier that geometric constraints are used by Inventor in more ways than most people think.  In addition to the typical geometric constraints as discussed above, there are several other geometry creation commands that result in the creation of geometric constraints.  For example, when you create an offset, new geometry is created and Inventor creates constraints between the original geometry and the new geometry so the new geometry behaves as an offset.  You can delete the constraint to remove the offset behavior.  The picture below shows a simple sketch.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163057bb048970d-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="GeomConstraints1" border="0" alt="GeomConstraints1" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168eb716538970c-pi" width="475" height="293" /></a></p>  <p>Below is the same sketch after offsetting the outside profile and creating a rectangular pattern of the circle.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163057bb054970d-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="GeomConstraints2" border="0" alt="GeomConstraints2" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340167666f8466970b-pi" width="475" height="294" /></a></p>  <p>Finally, the picture below shows the constraint symbols turned on so you can see all of the constraints that were created automatically as a result of the previous operations.  The API provides query access to all of these constraints through the GeometricConstraints collection.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168eb716546970c-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="GeomConstraints3" border="0" alt="GeomConstraints3" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340163057bb065970d-pi" width="475" height="300" /></a></p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/creating-geometric-constraints-in-a-sketch.html</feedburner:origLink></entry>
    <entry>
        <title>Sheet Metal Extents Add-In Update</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/lHCdrMfXcbY/sheet-metal-extents-add-in-update.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/sheet-metal-extents-add-in-update.html" thr:count="5" thr:updated="2012-05-17T16:18:30-07:00" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc6883401630569bcd0970d</id>
        <published>2012-05-09T15:33:36-07:00</published>
        <updated>2012-05-09T15:34:14-07:00</updated>
        <summary>Several years ago I wrote an add-in that creates parameters and iProperties whose values are the length and width of the sheet metal flat pattern. If the model is updated, the values are also automatically updated to reflect the change....</summary>
        <author>
            <name>Brian Ekins</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>Several years ago I wrote an add-in that creates parameters and iProperties whose values are the length and width of the sheet metal flat pattern.  If the model is updated, the values are also automatically updated to reflect the change.  I haven’t touched the add-in for a few years but a problem was recently reported that was the result of a change in the API to handle the new Text and Yes/No types of parameters.  Since the source code was delivered with the add-in, several of you had already found the problem and fixed it.  I’ve made the change now to fix this and have also updated it to take advantage of some new add-in functionality.</p>  <p><u>This version of the add-in is specific to Inventor 2013 and later</u> because I’m taking advantage of a feature that was introduced with Inventor 2013.  I’ve also upgraded the project to Visual Studio 2010 and .Net 4, which is what is recommended for Inventor 2013.  One of the biggest changes was to change this from a registered add-in to registry-free.  This makes it simpler to deploy and is the recommended way of deploying an add-in since Inventor 2012.  </p>  <p>Below are three different zips.  The first two contain the runtime for the add-in but provide two different ways of deploying it.  You can pick whichever will work the best in your situation.  The third zip is the source code for the add-in.</p>  <p><strong /></p>  <p><strong>Installer</strong> – This zip file contains an installer that when run will install the add-in.  You can uninstall the add-in using the Windows Control Panel.  Installation of the add-in no longer requires Administrator rights.</p>  <blockquote>   <p><a href="http://modthemachine.typepad.com/SheetMetalExtentsInstall.zip"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="zip[9]" border="0" alt="zip[9]" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168eb5fa693970c-pi" width="16" height="16" /></a> <a href="http://modthemachine.typepad.com/SheetMetalExtentsInstall.zip">SheetMetalExtentsInstall.zip</a> (433 Kb)</p> </blockquote>  <p><strong /></p>  <p><strong /></p>  <p><strong>Drag &amp; Drop Deployment</strong> – This zip file contains a directory containing the add-in dll, a .addin file and the readme file.  Because the add-in is now registry-free, you can install the add-in by simply copying these files into the correct location on your computer (Drag &amp; Drop Deployment).  Uninstall is just a matter of deleting the directory.  To “install” the add-in using these files copy the “SheetMetalExtents” directory from the zip file into:</p>  <p>   <font face="Courier New">%APPDATA%\Autodesk\ApplicationPlugins</font></p>  <p>The “%APPDATA%” portion of the path uses an environment variable that will resolve to your Roaming directory.  On my machine it ends up using the path of:</p>  <p>   <font face="Courier New">C:\Users\ekinsb\AppData\Roaming\Autodesk\ApplicationPlugins</font></p>  <blockquote>   <p><a href="http://modthemachine.typepad.com/SheetMetalExtents.zip"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="zip[10]" border="0" alt="zip[10]" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc6883401630569bc57970d-pi" width="16" height="16" /></a> <a href="http://modthemachine.typepad.com/SheetMetalExtents.zip">SheetMetalExtents.zip</a> (8 Kb)</p> </blockquote>  <p><strong /></p>  <p><strong /></p>  <p><strong>Source Code</strong> – This zip file contains the source code for the add-in.</p>  <blockquote><a href="http://modthemachine.typepad.com/SheetMetalExtentsSource.zip"><img style="background-image: none; border-bottom: 0px; border-left: 0px; margin: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top: 0px; border-right: 0px; padding-top: 0px" title="zip[11]" border="0" alt="zip[11]" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc6883401630569bc9a970d-pi" width="16" height="16" /></a> <a href="http://modthemachine.typepad.com/SheetMetalExtentsSource.zip">SheetMetalExtentsSource.zip</a> (9 Kb)</blockquote>  <p> </p>  <p>Please let me know if you find any issues with the program or have suggestions to improve it.</p>  <p>-Brian</p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/sheet-metal-extents-add-in-update.html</feedburner:origLink></entry>
    <entry>
        <title>Thumbnail Viewer Component on a 64-Bit System</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/NOL6kRHYnu8/thumbnail-viewer-component-on-a-64-bit-system.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/05/thumbnail-viewer-component-on-a-64-bit-system.html" thr:count="2" thr:updated="2012-05-10T00:24:54-07:00" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc6883401630521c038970d</id>
        <published>2012-05-03T14:12:11-07:00</published>
        <updated>2012-05-03T14:13:52-07:00</updated>
        <summary>In a previous post I discussed several way to access the thumbnail image that’s associated with each document. One of these ways is to use the ThumbnailView component. I received a question recently regarding the ThumbnailView component not working as...</summary>
        <author>
            <name>Brian Ekins</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>In a <a href="http://modthemachine.typepad.com/my_weblog/2010/06/accessing-thumbnail-images.html">previous post</a> I discussed several way to access the thumbnail image that’s associated with each document.  One of these ways is to use the ThumbnailView component.  I received a question recently regarding the ThumbnailView component not working as expected.  After quite a bit of digging and some testing I believe I know what the problem is and how to fix it.</p>  <p><strong><font color="#0000ff">I believe this an issue only if you’re using .Net (VB or C#) and are using 64-bit Windows.</font></strong>  I don’t think there are problems with any other configurations but if there are, please let me know.</p>  <p><strong><font size="3">COM and .Net on a 64-Bit OS Overview</font></strong>     <br />Before I describe the solution, I think it might be worth taking a minute to describe what’s happening when you use a COM component (the thumbnail view component in this case) from .Net program on a 64-bit system.  The picture below attempts to show all of the various pieces that need to play together to get this work.  First, is the COM component itself.  The thumbnail viewer was created using C++ and the resulting dll is compiled for either 32 or 64-bit.  On a 32-bit system you can only use 32-bit components.  On a 64-bit system you can use either 32 or 64-bit components because 64-bit windows supports an emulator that is able to run 32-bit applications.  COM dll components run within the process of the program using it and a 32-bit component can only run within a 32-bit process and a 64-bit component can only run within a 64-bit process. </p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016766153837970b-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="64BitCOMComponent" border="0" alt="64BitCOMComponent" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc6883401676615383e970b-pi" width="403" height="314" /></a></p>  <p>The registry is used because COM components can be located anywhere on a computer but other programs need to be able to know they’re available and where they’re located.  The components make themselves known by adding information to the registry.  There are separate areas in the registry where 32-bit and 64-bit components register themselves.</p>  <p>Another piece that makes the 32-bit vs. 64-bit issue described above even more confusing is that when writing a .Net program you can specify that the runtime will be compatible with 32-bit (x86), 64-bit (x64), or “Any CPU” (both 32 and 64-bit).  The “Any CPU” option is the interesting, and confusing, option.  It’s the option I almost always use.  The reason that .Net can support the “Any CPU” option is that when you compile your program, .Net compiles your program into MSIL (Microsoft Intermediate Language) which is a CPU independent set of instructions.  When your program is run, it is converted by the JIT (Just-In-Time) compiler into native code. This means that even if your program was compiled for “Any CPU”, when it runs it will actually be running as a native 32-bit or 64-bit application.</p>  <p>Because the COM component runs in-process to your application it must match the bitness of the running application.  For example, if you compile your application for “Any CPU” and run your program on a 64-bit machine, the .Net Framework will run it as a true 64-bit application and the 64-bit version of the thumbnail viewer will be required.  If you compile your application for 32-bit and run it on a 64-bit machine, it will run as a 32-bit app and will require the 32-bit version of the thumbnail viewer.  If the correct version of the COM component isn’t available, it will fail to run.</p>  <p>In addition to your program and the COM component, there is one other piece needed when using a COM component with .Net; an <em>Interop</em> assembly.  Your .Net program can’t directly call a COM component.  To provide support for COM, .Net uses the concept of Interop assemblies which are .Net components that provide a .Net interface to a COM component.  When you use the COM component, your program is actually calling functions in the interop assembly, which translates those calls and makes the equivalent call in the COM component.  The Interop serves as a wrapper for the COM component making it compatible with .Net.  These interop assemblies are dll’s and can also be created for 64-bit, 32-bit, or <em>agnostic</em> (equivalent to “Any CPU”).  But like the component, it must also match the bitness of the program it will be running within.</p>  <p>In summary, there are three runtime pieces; the COM component, the .Net Interop, and your program.  If you’re running on a 32-bit system, all of them must be 32-bit.  If you’re running on a 64-bit system you can run either 32-bit or 64-bit but all of the pieces must be 32-bit or 64-bit.  You can’t mix and match the bitness.</p>  <p><strong><font size="3">The Problem        <br /></font></strong>When programming with .Net and using a COM component, it’s somewhat transparent that there is an interop assembly involved.  When you reference the COM component into your project, Visual Studio automatically creates the interop behind the scenes.  The problem is that it’s creating a 32-bit compatible interop.  If you’re creating a 32-bit application, then everything is fine, but for a 64-bit application it’s not going to work.</p>  <p>I found the problem by doing some research on the web and discovering <a href="http://connect.microsoft.com/VisualStudio/feedback/details/711406/tlbimp-error-since-vs2010-a-single-valid-machine-type-compatible-with-the-input-type-library-must-be-specified">this article</a> on a Microsoft support site that gave me the clue I needed.  It also indicates that this is fixed in VS 11.</p>  <p><font size="3"><strong>The Fix        <br /></strong></font>Here’s the fix that I’m using to get this to work.  You need to manually create the interop for the thumbnail viewer component.  By manually creating it, you can specify the machine type that it’s compatible with.  In this case either “x64” or “Agnostic” will work because at runtime on an x64 machine they will both result in true X64 machine code.</p>  <p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 8pt">TlbImp.exe InventorThumbnailView.dll    <br />           /machine:Agnostic  <br />           /namespace:InventorThumbnailViewLib     <br />           /out:Interop.InventorThumbnailView.dll</p>  <p>Here’s a <a href="http://modthemachine.typepad.com/CreateInteropCommandLine.txt">link to a text file</a> that has the complete command line, with the full paths, so you can just copy and past this into a DOS command window.  You will need to edit the path for the output interop dll to where your project is.</p>  <p>Once you’ve created the interop, Use the References command in Visual Studio to reference it into your project.  Use the Browse tab on the References dialog so you can browse and select the interop dll.  You’ll reference this instead of the InventorThumbNailView.dll file.  Now it should all work.  </p>  <p>Below is some code from a very simple Windows Forms project that I created.  After creating the new project, I added a picture box control (with the SizeMode property set to “StretchImage”) and a button to the dialog.  I also added an open file dialog.  Finally, I added a reference to the .Net component “stdole”.  Below is the code that’s contained within the Click event of the button.  It uses the file dialog to get the filename of an Inventor file, uses the thumbnail view component to get the thumbnail from the Inventor file and then displays it.  The component returns the image as an IPictureDisp object.  Next, it converts this object to a .Net Image object, which it finally assigns to the picture box.  See below for some more discussion about this conversion process.</p>  <p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 8pt"><strong><font color="#0000ff">' Code in the button Click event.</font></strong>     <br />With OpenFileDialog1     <br />    .Filter = "Inventor Files (*.ipt;*.iam;*.idw)|*.ipt;*.iam;*.idw"     <br />    If .ShowDialog() = System.Windows.Forms.DialogResult.OK Then     <br /><font color="#0000ff"><strong>        ' Create an instance of the thumbnail viewer component.        <br /></strong></font>        Dim thumbviewer As New _     <br />                           InventorThumbnailViewLib.ThumbnailProvider     <br />    <br /><font color="#0000ff"><strong>        ' Use the component to get the thumbnail.        <br /></strong></font>        Dim pic As stdole.IPictureDisp = Nothing     <br />        Dim handle As Long = 0     <br />    <br /><font color="#0000ff"><strong>        ' Use workaround to make sure handle is a positive number.        <br />        ' Otherwise the call to PictureDispToImage will fail.         <br /></strong></font>        Do     <br />            pic = thumbviewer.GetThumbnail(.FileName)     <br />            handle = pic.Handle     <br />        Loop While handle &lt; 0     <br />    <br /><font color="#0000ff"><strong>        ' Convert the IPictureDisp into an Image to  <br />        ' display it in the picture box.         <br /></strong></font>        Dim img As Image = AxHostConverter.PictureDispToImage(pic)     <br />        PictureBox1.Image = img     <br />    End If     <br />End With     <br /></p>  <p>The object that represents a bitmap image in COM is an IPictureDisp object, (which is defined in the stdole library).  .Net represents a bitmap image using the Image object.  This means there needs to be a conversion from an IPictureDisp objet to an Image object to be able to use the returned bitmap in .Net.  There is a Visual Basic compatibility library that contains routines to do this.  Unfortunately, if you use them with .Net 4, you’ll get a warning message that these functions are obsolete and are only supported on 32-bit.  You can read more here: <a title="http://go.microsoft.com/fwlink/?linkid=160862" href="http://go.microsoft.com/fwlink/?linkid=160862">http://go.microsoft.com/fwlink/?linkid=160862</a>.</p>  <p>To avoid these warnings and possible problems in the future you’ll need to use something else.  Unfortunately, Microsoft hasn’t provided a simple alternative.  Below is a class that exposes some functions to do this conversion from one type to the other.  I wraps some internal functionality on another Microsoft class to it can be used in a general way.  To use it in your project, just copy the class below into your project.  The PictureDispToImage function defined in this AxHostConverter class is used in the code above.</p>  <p>There’s also some funny code in the example above that’s a workaround to a problem I found while testing.  When testing, it would periodically fail to do the conversion.  The failure seemed random with a “A generic error occurred in GDI+” failure.  I accidentally discovered that the failure was occurring whenever the Windows handle being provided by the IPictureDisp object was negative.  The workaround I put in the code above keeps getting an new IPictureDisp until the handle is a positive number.  I stress tested this through several thousand iterations and the most it ever looped to get a positive number was 10, so I think the chance of this being an endless loop is too small to worry about.  About 85% the first return is positive, another 10% took two calls, and the remaining 5% is 3 or more calls.  I believe the cause of this problem is that the number is actually an unsigned int, but it’s being treated as a regular int which results in a negative number for large numbers.  Anyway, this seems to work around the problem.</p>  <p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 8pt"><strong><font color="#0000ff">' Utility class that provides support for converting between       <br /><strong><font color="#0000ff">' IPictureDisp and Image objects.</font></strong></font></strong>    <br />Friend Class AxHostConverter     <br />    Inherits AxHost     <br />    <br />    Private Sub New()     <br />        MyBase.New("")     <br />    End Sub     <br />    <br />    Public Shared Function ImageToPictureDisp( _     <br />                    ByVal objImage As Image) As stdole.IPictureDisp     <br />        Return DirectCast(GetIPictureDispFromPicture(objImage), _     <br />                          stdole.IPictureDisp)     <br />    End Function     <br />    <br />    Public Shared Function PictureDispToImage( _     <br />                  ByVal pictureDisp As stdole.IPictureDisp) As Image     <br />        Dim objPicture As System.Drawing.Image     <br />        objPicture = CType(GetPictureFromIPicture(pictureDisp), _     <br />                           System.Drawing.Image)     <br />    <br />        Return objPicture     <br />    End Function     <br />End Class</p> One final thing to remember is that you’ll need to deliver the interop with your program.  Your program has two dependencies which you’ll need to deliver in addition to your exe; the thumbnail view component, (which also needs to be registered), and the interop dll.</div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/05/thumbnail-viewer-component-on-a-64-bit-system.html</feedburner:origLink></entry>
    <entry>
        <title>Drawing in a Sketch</title>
        <link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/modthemachine/~3/4GAKvQ-qtsQ/drawing-in-a-sketch.html" />
        <link rel="replies" type="text/html" href="http://modthemachine.typepad.com/my_weblog/2012/04/drawing-in-a-sketch.html" thr:count="1" thr:updated="2012-05-15T23:48:20-07:00" />
        <id>tag:typepad.com,2003:post-6a00e553fcbfc68834016304db2975970d</id>
        <published>2012-04-27T12:57:08-07:00</published>
        <updated>2012-04-27T12:57:47-07:00</updated>
        <summary>This is a continuation of the getting started tutorial that’s discussing the creation of a new command to draw a slot. In this installment I discuss drawing geometry in a sketch. When creating sketch geometry using the API, there are...</summary>
        <author>
            <name>Brian Ekins</name>
        </author>
        
        
<content type="xhtml" xml:lang="en-US" xml:base="http://modthemachine.typepad.com/my_weblog/">
<div xmlns="http://www.w3.org/1999/xhtml"><p>This is a continuation of the <a href="http://modthemachine.typepad.com/my_weblog/getting-started-tutorial/">getting started tutorial</a> that’s discussing the creation of a new command to draw a slot.  In this installment I discuss drawing geometry in a sketch.</p>  <p>When creating sketch geometry using the API, there are a couple of concepts that are important to understand that aren’t very obvious when you create sketches interactively.  Let’s look at what you really have when you draw two lines in a sketch.  You can see from the picture below it just looks like two lines and nothing else.</p>  <p> <a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b8e7970c-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="Lines" border="0" alt="Lines" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b8ee970c-pi" width="339" height="248" /></a></p>  <p>If you know what to look for, you’ll also notice something else.  If you move the mouse over the end of the lines, a point is displayed, as shown below.  At first you might think this is just a handle being displayed to indicate that you can drag the end of the line.  It’s not a handle, it’s a real sketch point that’s being displayed.  </p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016304db28eb970d-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="LinesWithPoint" border="0" alt="LinesWithPoint" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b8fc970c-pi" width="347" height="272" /></a></p>  <p>In fact, to better see these are real points you can select a point and using the context menu, change the display style of the point to a center point.  With this display style it remains visible all the time and not just when the cursor is over it.  The picture below shows all three of the points being displayed with a center point style.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016765ce49e8970b-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="LineWithCenterPoint" border="0" alt="LineWithCenterPoint" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016304db28fc970d-pi" width="346" height="273" /></a></p>  <p>The thing to learn from this is that all sketch geometry is <u>always</u> associated to  sketch points.  Sketch geometry doesn’t exist on its own.  The position of sketch geometry is controlled by the position of the points.  It’s like the geometry is fastened to the points and if the points move the geometry attached to them also moves.  </p>  <p>Another very important concept is that the two lines are connected by the fact that they share the same point.  Both lines are attached to the same point.  That’s how Inventor determines connected curves in a profile.  We’ll see an example of this later in this post.</p>  <p>Below is a picture of the two lines after placing a fillet.  The geometry consists of two lines and an arc.  The position of each of the lines is still defined by two sketch points and the arc shares the sketch points where it connects to the lines.  In addition, the arc has an additional sketch point that defines its center.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b90b970c-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; border-top-width: 0px; border-bottom-width: 0px; margin-left: auto; border-left-width: 0px; margin-right: auto; padding-top: 0px" title="LinesWithFillet" border="0" alt="LinesWithFillet" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b913970c-pi" width="324" height="230" /></a></p>  <p>When you interactively draw a sketch, Inventor automatically creates these points behind the scenes.  It also automatically deletes them when the associated geometry is deleted.  When using the API it’s possible to have it automatically create these points too, but without understanding these concepts of how geometry is connected to points and each other by sharing points it’s easy to get results you weren’t expecting.  When interactively drawing a sketch, it’s natural to get the correct result because Inventor infers connections based on where you click the mouse.  When using the API, none of this inference can take place because you’re not moving the mouse over the geometry.</p>  <p>The code below creates a sketch line on an existing sketch.  You can paste this into the bottom of the sub from the previous post in this series.  </p>  <p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 8pt"><font color="#0000ff"><strong><font color="#0000ff">' Get a reference to the TransientGeometry object</font></strong>. </font>    <br />Dim tg As Inventor.TransientGeometry = invApp.TransientGeometry     <br />    <br /><strong><font color="#0000ff">' Get a reference to the SketchLines collection.        <br /></font></strong>Dim lines As Inventor.SketchLines = sketch.SketchLines     <br />    <br /><font color="#0000ff"><strong>' Draw a line between (0,0) and (4,0).</strong></font>     <br />Dim line1 As Inventor.SketchLine     <br />line1 = lines.AddByTwoPoints(tg.CreatePoint2d(0, 0), _     <br />                             tg.CreatePoint2d(4, 0))</p>  <p>The first thing this does is get a reference to the <em>TransientGeometry</em> object. This is a utility object in the API that lets you create various types of geometry.  However, the geometry created is not ever displayed or saved by Inventor, which is why they are called <em>transient</em>.  These objects are simply the mathematical definition of the geometry and are not visible entities.  I’m using it in this case to create two coordinate points to define the end points of the line.  The CreatePoint2d method creates a transient 2d point.  The Point2d object is a simple API object that wraps the x-y coordinates of a point in 2d space.  In Inventor’s API, instead of passing two values to define x-y coordinates a Point2d object is used instead.  There’s also a Point object which wraps x-y-z coordinates for a 3d point.  When working with a sketch you want to make sure you’re using the CreatePoint<u>2d</u> method and not the CreatePoint method.  It’s a common mistake.</p>  <p>The next thing the program above does is get the SketchLines collection.  In a <a href="http://modthemachine.typepad.com/my_weblog/2012/04/objects-in-the-api.html">previous post</a> I briefly discussed collection objects.  The SketchLines object lets you access all of the lines on the sketch and it supports add methods to let you create new lines.  This examples uses the AddByTwoPoints method to create a new sketch line.</p>  <p>The final section of the code above creates the new line.  A variable is declared with the type of SketchLine and the newly created line is assigned to the variable.  The AddByTwoPoints method takes to points as input.  These can either be coordinate points (defined by a Point2d object as in the example above) or they can be existing SketchPoint objects, which you’ll see demonstrated below.</p>  <p>Another thing that’s important to understand are the units that Inventor uses. Internally, Inventor is consistent in the units it uses.  Lengths are <u>always</u> defined in centimeters and angles are <u>always</u> defined in radians.  It doesn’t matter what units the user has specified as their document units.  The API is consistent with the Inventor internal units.  When you create or query geometry, any length or coordinate values will always be in centimeters and any angles will always be in radians.  The example above creates a 4 centimeter long line starting from the origin and going in the sketch X direction.  We’ll see in a later post how to deal with user defined units.</p>  <p>Below is some code that creates a second and third line to create a triangle.</p>  <p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 8pt"><font color="#0000ff"><strong>' Draw a line between (4,0) and (4,3).</strong></font>     <br />Dim line2 As Inventor.SketchLine     <br />line2 = lines.AddByTwoPoints(tg.CreatePoint2d(4, 0), _     <br />                             tg.CreatePoint2d(4, 3))     <br />    <br /><font color="#0000ff"><strong>' Draw a line between (4,3) and (0,0).</strong></font>     <br />Dim line3 As Inventor.SketchLine     <br />line3 = lines.AddByTwoPoints(tg.CreatePoint2d(4, 3), _     <br />                             tg.CreatePoint2d(0, 0)) </p>  <p>The resulting geometry is shown below on the left.  If I try to create an extrusion using this sketch I can’t select the triangle, but only the individual lines.  That’s because each line has it’s own unique pair of sketch points for its end points, instead of sharing a single point between two lines.  This becomes obvious if I drag any of the end points, the triangle pulls apart, as shown in the picture on the right.</p>  <p align="left"><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b919970c-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; float: left; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="LinesTriangle" border="0" alt="LinesTriangle" align="left" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016765ce49f5970b-pi" width="231" height="182" /></a></p>  <p align="left"><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016304db290c970d-pi"><img style="background-image: none; border-right-width: 0px; padding-left: 0px; padding-right: 0px; display: inline; border-top-width: 0px; border-bottom-width: 0px; border-left-width: 0px; padding-top: 0px" title="LinesBrokenTriangle" border="0" alt="LinesBrokenTriangle" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b92f970c-pi" width="240" height="204" /></a></p>  <p>The code below is a variation of the previous code but creates a set of connected lines.  The difference is that instead of defining new coordinates for the end of each line it uses the EndSketchPoint and StartSketchPoint properties of the SketchLine object to get the sketch points from the existing lines.</p>  <p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 8pt"><font color="#0000ff"><strong>' Draw a line between (0,0) and (4,0).</strong></font>     <br />Dim line1 As Inventor.SketchLine     <br />line1 = lines.AddByTwoPoints(tg.CreatePoint2d(0, 0), _     <br />                             tg.CreatePoint2d(4, 0))     <br />    <br /><font color="#0000ff"><strong>' Draw a second line from the end of the previous line to (4,3).</strong></font>     <br />Dim line2 As Inventor.SketchLine     <br />line2 = lines.AddByTwoPoints(line1.EndSketchPoint, _     <br />                             tg.CreatePoint2d(4, 3))     <br />    <br /><font color="#0000ff"><strong>' Draw a line connecting the last point to the first point.        <br /></strong></font>Dim line3 As Inventor.SketchLine     <br />line3 = lines.AddByTwoPoints(line2.EndSketchPoint, _     <br />                             line1.StartSketchPoint)</p>  <p> </p>  <p>The approach to creating sketch geometry that I’ve had the best personal success with is to create the sketch points first and then use those as input when creating the various sketch entities.  It’s easier for me to visualize the points I need if I map it out before hand and having the map helps to eliminate mistakes in my code.  For example, below is an example of what I sketched up to help me visualize the points that will be needed to create the slot.  Remember that arcs and circles require a sketch point at their center.  I’ve numbered the points starting with zero.  Those numbers will correspond to indices in an array in my program.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b93c970c-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="SlotSketch" border="0" alt="SlotSketch" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016304db2924970d-pi" width="347" height="200" /></a></p>  <p>Below is the code that demonstrates this approach.  It begins by creating the sketch points and then it uses those points to create the sketch geometry.  It becomes a dot-to-dot exercise to draw the geometry.  This examples illustrates lines and arcs, but all of sketch geometry uses the same concepts.  You’ll just be using different collection objects and different add methods within those collections.</p>  <p style="line-height: 140%; font-family: courier new; background: #eeeeee; color: black; font-size: 8pt"><strong><font color="#0000ff">' Get a reference to the SketchPoints collection.</font></strong>     <br />Dim points As Inventor.SketchPoints = sketch.SketchPoints     <br />    <br /><font color="#0000ff"><strong>' Get a reference to the SketchLines collection.        <br /></strong></font>Dim lines As Inventor.SketchLines = sketch.SketchLines     <br />    <br /><font color="#0000ff"><strong>' Get a reference to the SketchArcs collection.</strong></font>     <br />Dim arcs As Inventor.SketchArcs = sketch.SketchArcs     <br />    <br /><font color="#0000ff"><strong>' Create the sketch points.</strong></font>     <br />Dim pointArray(5) As Inventor.SketchPoint     <br />pointArray(0) = points.Add(tg.CreatePoint2d(0, 1), False)     <br />pointArray(1) = points.Add(tg.CreatePoint2d(0, 0), False)     <br />pointArray(2) = points.Add(tg.CreatePoint2d(0, -1), False)     <br />pointArray(3) = points.Add(tg.CreatePoint2d(4, -1), False)     <br />pointArray(4) = points.Add(tg.CreatePoint2d(4, 0), False)     <br />pointArray(5) = points.Add(tg.CreatePoint2d(4, 1), False)     <br />    <br /><font color="#0000ff"><strong>' Draw the geometry.</strong></font>     <br />Dim arc1 As Inventor.SketchArc     <br />arc1 = arcs.AddByCenterStartEndPoint(pointArray(1), pointArray(0), _     <br />                                     pointArray(2))     <br />    <br />Dim line1 As Inventor.SketchLine     <br />line1 = lines.AddByTwoPoints(pointArray(2), pointArray(3))     <br />    <br />Dim arc2 As Inventor.SketchArc     <br />arc2 = arcs.AddByCenterStartEndPoint(pointArray(4), pointArray(3), _     <br />                                     pointArray(5))     <br />    <br />Dim line2 As Inventor.SketchLine     <br />line2 = lines.AddByTwoPoints(pointArray(5), pointArray(0))     <br /></p>  <p>The result after running the program is shown below, which is what’s expected.  Because the entities share sketch points at the connections, Inventor sees this as being closed so it can be used as input to create an extrusion.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b94b970c-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="SlotResult" border="0" alt="SlotResult" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc688340168ead0b959970c-pi" width="274" height="117" /></a></p>  <p>However, if you try and edit the sketch by dragging the points it may not behave as you expect, as shown in the picture below.  This is because there aren’t any constraints to define the behavior.  Interactively, constraints are inferred during the sketching process by how you move your mouse, which can’t happen when using the API.  I’ll discuss adding constraints in an upcoming post.</p>  <p><a href="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016765ce4a2b970b-pi"><img style="background-image: none; border-bottom: 0px; border-left: 0px; padding-left: 0px; padding-right: 0px; display: block; float: none; margin-left: auto; border-top: 0px; margin-right: auto; border-right: 0px; padding-top: 0px" title="ModifiedSlotResult" border="0" alt="ModifiedSlotResult" src="http://modthemachine.typepad.com/.a/6a00e553fcbfc68834016304db2966970d-pi" width="273" height="132" /></a></p>  <p><strong>Note</strong>: One issue that I just discovered while writing this post is that the AddByCenterStartEndPoint method is not associating the input center sketch point with the new arc, but is instead creating a new point at that position.  This is not expected behavior and I’ll discuss how you can work around this issue in a later post.  Just know that when you see the extra center points that you didn’t do anything wrong.</p>  <p>-Brian</p></div>
</content>



    <feedburner:origLink>http://modthemachine.typepad.com/my_weblog/2012/04/drawing-in-a-sketch.html</feedburner:origLink></entry>
 
</feed><!-- ph=1 -->

