<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Extruding sketch in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/6776920#M68992</link>
    <description>&lt;P&gt;hello rcolon9E4ZX,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is a bit code from the API inventor help, look for extrude, and look at the examples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Public Sub DrawBlockWithPocket()
    &lt;SPAN style="color: blue;"&gt;' Create a new part document, using the default part template.&lt;/SPAN&gt;
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
                ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
                    
    &lt;SPAN style="color: blue;"&gt;' Set a reference to the component definition.&lt;/SPAN&gt;
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition
    
    &lt;SPAN style="color: blue;"&gt;' Create a new sketch on the X-Y work plane.  Since it's being created on&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' one of the base workplanes we know the orientation it will be created in&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' and don't need to worry about controlling it.  Because of this we also&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' know the origin of the sketch plane will be at (0,0,0) in model space.&lt;/SPAN&gt;
    Dim oSketch As PlanarSketch
    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
    
    &lt;SPAN style="color: blue;"&gt;' Set a reference to the transient geometry object.&lt;/SPAN&gt;
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
    
    &lt;SPAN style="color: blue;"&gt;' Draw a 4cm x 3cm rectangle with the corner at (0,0)&lt;/SPAN&gt;
    Dim oRectangleLines As SketchEntitiesEnumerator
    Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _
                                oTransGeom.CreatePoint2d(0, 0), _
                                oTransGeom.CreatePoint2d(4, 3))

    &lt;SPAN style="color: blue;"&gt;' Create a profile.&lt;/SPAN&gt;
    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid
    
    &lt;SPAN style="color: blue;"&gt;' Create a base extrusion 1cm thick.&lt;/SPAN&gt;
    Dim oExtrudeDef As ExtrudeDefinition
    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
    Call oExtrudeDef.SetDistanceExtent(1, kNegativeExtentDirection)
    Dim oExtrude As ExtrudeFeature
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
                        
    &lt;SPAN style="color: blue;"&gt;' Get the top face of the extrusion to use for creating the new sketch.&lt;/SPAN&gt;
    Dim oFrontFace As Face
    Set oFrontFace = oExtrude.StartFaces.Item(1)
    
    &lt;SPAN style="color: blue;"&gt;' Create a new sketch on this face, but use the method that allows you to&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' control the orientation and orgin of the new sketch.&lt;/SPAN&gt;
    Set oSketch = oCompDef.Sketches.AddWithOrientation(oFrontFace, _
                    oCompDef.WorkAxes.Item(1), True, True, oCompDef.WorkPoints(1))
                    
    &lt;SPAN style="color: blue;"&gt;' Determine where in sketch space the point (0.5,0.5,0) is.&lt;/SPAN&gt;
    Dim oCorner As Point2d
    Set oCorner = oSketch.ModelToSketchSpace(oTransGeom.CreatePoint(0.5, 0.5, 0))
   
    &lt;SPAN style="color: blue;"&gt;' Create the interior 3cm x 2cm rectangle for the pocket.&lt;/SPAN&gt;
    Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _
                oCorner, oTransGeom.CreatePoint2d(oCorner.X + 3, oCorner.Y + 2))
                
    &lt;SPAN style="color: blue;"&gt;' Create a profile.&lt;/SPAN&gt;
    Set oProfile = oSketch.Profiles.AddForSolid
    
    &lt;SPAN style="color: blue;"&gt;' Create a pocket .25 cm deep.&lt;/SPAN&gt;
    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kCutOperation)
    Call oExtrudeDef.SetDistanceExtent(0.25, kNegativeExtentDirection)
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
End Sub&lt;/PRE&gt;</description>
    <pubDate>Sat, 31 Dec 2016 12:37:18 GMT</pubDate>
    <dc:creator>HermJan.Otterman</dc:creator>
    <dc:date>2016-12-31T12:37:18Z</dc:date>
    <item>
      <title>Extruding sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/6776482#M68990</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on generating .ipt's from VBA. I am looking for a chunk of code to extrude a sketch. Also, how do I distinguish which region I want to extrude (ex. a donut-ring or middle).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Fri, 30 Dec 2016 20:55:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/6776482#M68990</guid>
      <dc:creator>rcolon9E4ZX</dc:creator>
      <dc:date>2016-12-30T20:55:13Z</dc:date>
    </item>
    <item>
      <title>Re: Extruding sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/6776920#M68992</link>
      <description>&lt;P&gt;hello rcolon9E4ZX,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;here is a bit code from the API inventor help, look for extrude, and look at the examples:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Public Sub DrawBlockWithPocket()
    &lt;SPAN style="color: blue;"&gt;' Create a new part document, using the default part template.&lt;/SPAN&gt;
    Dim oPartDoc As PartDocument
    Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
                ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
                    
    &lt;SPAN style="color: blue;"&gt;' Set a reference to the component definition.&lt;/SPAN&gt;
    Dim oCompDef As PartComponentDefinition
    Set oCompDef = oPartDoc.ComponentDefinition
    
    &lt;SPAN style="color: blue;"&gt;' Create a new sketch on the X-Y work plane.  Since it's being created on&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' one of the base workplanes we know the orientation it will be created in&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' and don't need to worry about controlling it.  Because of this we also&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' know the origin of the sketch plane will be at (0,0,0) in model space.&lt;/SPAN&gt;
    Dim oSketch As PlanarSketch
    Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes(3))
    
    &lt;SPAN style="color: blue;"&gt;' Set a reference to the transient geometry object.&lt;/SPAN&gt;
    Dim oTransGeom As TransientGeometry
    Set oTransGeom = ThisApplication.TransientGeometry
    
    &lt;SPAN style="color: blue;"&gt;' Draw a 4cm x 3cm rectangle with the corner at (0,0)&lt;/SPAN&gt;
    Dim oRectangleLines As SketchEntitiesEnumerator
    Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _
                                oTransGeom.CreatePoint2d(0, 0), _
                                oTransGeom.CreatePoint2d(4, 3))

    &lt;SPAN style="color: blue;"&gt;' Create a profile.&lt;/SPAN&gt;
    Dim oProfile As Profile
    Set oProfile = oSketch.Profiles.AddForSolid
    
    &lt;SPAN style="color: blue;"&gt;' Create a base extrusion 1cm thick.&lt;/SPAN&gt;
    Dim oExtrudeDef As ExtrudeDefinition
    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
    Call oExtrudeDef.SetDistanceExtent(1, kNegativeExtentDirection)
    Dim oExtrude As ExtrudeFeature
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
                        
    &lt;SPAN style="color: blue;"&gt;' Get the top face of the extrusion to use for creating the new sketch.&lt;/SPAN&gt;
    Dim oFrontFace As Face
    Set oFrontFace = oExtrude.StartFaces.Item(1)
    
    &lt;SPAN style="color: blue;"&gt;' Create a new sketch on this face, but use the method that allows you to&lt;/SPAN&gt;
    &lt;SPAN style="color: blue;"&gt;' control the orientation and orgin of the new sketch.&lt;/SPAN&gt;
    Set oSketch = oCompDef.Sketches.AddWithOrientation(oFrontFace, _
                    oCompDef.WorkAxes.Item(1), True, True, oCompDef.WorkPoints(1))
                    
    &lt;SPAN style="color: blue;"&gt;' Determine where in sketch space the point (0.5,0.5,0) is.&lt;/SPAN&gt;
    Dim oCorner As Point2d
    Set oCorner = oSketch.ModelToSketchSpace(oTransGeom.CreatePoint(0.5, 0.5, 0))
   
    &lt;SPAN style="color: blue;"&gt;' Create the interior 3cm x 2cm rectangle for the pocket.&lt;/SPAN&gt;
    Set oRectangleLines = oSketch.SketchLines.AddAsTwoPointRectangle( _
                oCorner, oTransGeom.CreatePoint2d(oCorner.X + 3, oCorner.Y + 2))
                
    &lt;SPAN style="color: blue;"&gt;' Create a profile.&lt;/SPAN&gt;
    Set oProfile = oSketch.Profiles.AddForSolid
    
    &lt;SPAN style="color: blue;"&gt;' Create a pocket .25 cm deep.&lt;/SPAN&gt;
    Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kCutOperation)
    Call oExtrudeDef.SetDistanceExtent(0.25, kNegativeExtentDirection)
    Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
End Sub&lt;/PRE&gt;</description>
      <pubDate>Sat, 31 Dec 2016 12:37:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/6776920#M68992</guid>
      <dc:creator>HermJan.Otterman</dc:creator>
      <dc:date>2016-12-31T12:37:18Z</dc:date>
    </item>
    <item>
      <title>Ynt: Extruding sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/13259650#M175525</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/562667"&gt;@HermJan.Otterman&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Can we draw two rectangles to same sketch and create profile by selecting just outer rectangle and leaving inner rectangle ?&amp;nbsp; I mean, instead of creating two sketch, can we work with just one sketch ?&lt;/P&gt;</description>
      <pubDate>Tue, 14 Jan 2025 10:54:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/13259650#M175525</guid>
      <dc:creator>Mehmet_Fatih_Turker</dc:creator>
      <dc:date>2025-01-14T10:54:56Z</dc:date>
    </item>
    <item>
      <title>Ynt: Extruding sketch</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/13263966#M175619</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/13221187"&gt;@Mehmet_Fatih_Turker&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;yes you can. it is basically all in the help of Inventor.&lt;/P&gt;&lt;P&gt;so if you use the addforsolid, you can specify some optional input.&lt;/P&gt;&lt;P&gt;If you want the whole sketch to be extruded then you don't put in anything, but in your case you can.&lt;/P&gt;&lt;P&gt;so create the two rectangles, (oRectangleLines3, and oRectangleLines4)... (names in the code)&lt;/P&gt;&lt;P&gt;then in the addforsolid you can only pass an objectcollection, so create the object collecction and add only the largest rectangle to it.&lt;/P&gt;&lt;P&gt;then if you create te profile, pass in the object colletion.&lt;/P&gt;&lt;P&gt;try you self to change the first option from false tot true (should be false)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;the code:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Public&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt; &lt;SPAN&gt;Main&lt;/SPAN&gt;()
    &lt;SPAN&gt;' Check to make sure a sketch is open.&lt;/SPAN&gt;
    &lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;Not&lt;/SPAN&gt; &lt;SPAN&gt;TypeOf&lt;/SPAN&gt; &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveEditObject&lt;/SPAN&gt; &lt;SPAN&gt;Is&lt;/SPAN&gt; &lt;SPAN&gt;PlanarSketch&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
      &lt;SPAN&gt;MsgBox&lt;/SPAN&gt; (&lt;SPAN&gt;"A sketch must be active."&lt;/SPAN&gt;)
      &lt;SPAN&gt;Exit&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;
    &lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;

    &lt;SPAN&gt;' Set a reference to the active sketch.&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oSketch&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PlanarSketch&lt;/SPAN&gt;
     &lt;SPAN&gt;oSketch&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveEditObject&lt;/SPAN&gt;

    &lt;SPAN&gt;' Set a reference to the transient geometry collection.&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oTransGeom&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;
     &lt;SPAN&gt;oTransGeom&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientGeometry&lt;/SPAN&gt;
	
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oRectangleLines3&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;SketchEntitiesEnumerator&lt;/SPAN&gt;
     &lt;SPAN&gt;oRectangleLines3&lt;/SPAN&gt; = &lt;SPAN&gt;oSketch&lt;/SPAN&gt;.&lt;SPAN&gt;SketchLines&lt;/SPAN&gt;.&lt;SPAN&gt;AddAsTwoPointCenteredRectangle&lt;/SPAN&gt;( _
    &lt;SPAN&gt;oTransGeom&lt;/SPAN&gt;.&lt;SPAN&gt;CreatePoint2d&lt;/SPAN&gt;(0, 0), _
    &lt;SPAN&gt;oTransGeom&lt;/SPAN&gt;.&lt;SPAN&gt;CreatePoint2d&lt;/SPAN&gt;(5, 5))
			
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oRectangleLines4&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;SketchEntitiesEnumerator&lt;/SPAN&gt;
     &lt;SPAN&gt;oRectangleLines4&lt;/SPAN&gt; = &lt;SPAN&gt;oSketch&lt;/SPAN&gt;.&lt;SPAN&gt;SketchLines&lt;/SPAN&gt;.&lt;SPAN&gt;AddAsTwoPointCenteredRectangle&lt;/SPAN&gt;( _
    &lt;SPAN&gt;oTransGeom&lt;/SPAN&gt;.&lt;SPAN&gt;CreatePoint2d&lt;/SPAN&gt;(0, 0), _
    &lt;SPAN&gt;oTransGeom&lt;/SPAN&gt;.&lt;SPAN&gt;CreatePoint2d&lt;/SPAN&gt;(6, 6))
	
	
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;partDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt; = &lt;SPAN&gt;ThisDoc&lt;/SPAN&gt;.&lt;SPAN&gt;Document&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oCompDef&lt;/SPAN&gt; = &lt;SPAN&gt;partDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
		
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;objcol&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;TransientObjects&lt;/SPAN&gt;.&lt;SPAN&gt;CreateObjectCollection&lt;/SPAN&gt;(&lt;SPAN&gt;oRectangleLines4&lt;/SPAN&gt;)
		
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oProfile&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Profile&lt;/SPAN&gt;
     &lt;SPAN&gt;oProfile&lt;/SPAN&gt; = &lt;SPAN&gt;oSketch&lt;/SPAN&gt;.&lt;SPAN&gt;Profiles&lt;/SPAN&gt;.&lt;SPAN&gt;AddForSolid&lt;/SPAN&gt;(&lt;SPAN&gt;False&lt;/SPAN&gt;, &lt;SPAN&gt;objcol&lt;/SPAN&gt;)
	
	&lt;SPAN&gt;' Create a base extrusion 1cm thick.&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oExtrudeDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ExtrudeDefinition&lt;/SPAN&gt;
     &lt;SPAN&gt;oExtrudeDef&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;ExtrudeFeatures&lt;/SPAN&gt;.&lt;SPAN&gt;CreateExtrudeDefinition&lt;/SPAN&gt;(&lt;SPAN&gt;oProfile&lt;/SPAN&gt;, &lt;SPAN&gt;kJoinOperation&lt;/SPAN&gt;)
     &lt;SPAN&gt;oExtrudeDef&lt;/SPAN&gt;.&lt;SPAN&gt;SetDistanceExtent&lt;/SPAN&gt;(1, &lt;SPAN&gt;kNegativeExtentDirection&lt;/SPAN&gt;)
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oExtrude&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ExtrudeFeature&lt;/SPAN&gt;
     &lt;SPAN&gt;oExtrude&lt;/SPAN&gt; = &lt;SPAN&gt;oCompDef&lt;/SPAN&gt;.&lt;SPAN&gt;Features&lt;/SPAN&gt;.&lt;SPAN&gt;ExtrudeFeatures&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;oExtrudeDef&lt;/SPAN&gt;)

&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Sub&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;succes&lt;/P&gt;</description>
      <pubDate>Thu, 16 Jan 2025 08:10:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/extruding-sketch/m-p/13263966#M175619</guid>
      <dc:creator>HermJan.Otterman</dc:creator>
      <dc:date>2025-01-16T08:10:30Z</dc:date>
    </item>
  </channel>
</rss>

