<?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 Create Sketch Fom Selected Face (Replicate &amp;quot;Start 2D Sketch&amp;quot; tool) in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-sketch-fom-selected-face-replicate-quot-start-2d-sketch/m-p/14029570#M179549</link>
    <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a sketch onto a face within a part, which I will then add/modify features from, however I am unable to create a 2D sketch onto any desired face as I am given an error upon running Sketches.Add().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This part is currently an immediate child of the active assembly, but I have also attempted in modifying a part within an assembly, which itself is within the active assembly (a part within a sub-assembly).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To simplify my debugging process, I decided to replicate the "Start 2D Sketch" tool and select a specific face I want to create a sketch onto. Code snippets for this are below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;iLogic Sample:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim face As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select a face")

' Only attempt to add a sketch if the selected face belongs to a part
If (face.Parent.ComponentDefinition.Type = ObjectTypeEnum.kPartComponentDefinitionObject) Then
	Dim def = face.Parent.ComponentDefinition
    Dim sketch As PlanarSketch = def.Sketches.Add(selection)
End If&lt;/LI-CODE&gt;&lt;P&gt;C# Sample:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Face selection = (Face)Globals.InventorApp.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a face");

// Only attempt to add a sketch if the selected face belongs to a part
if (((Face)selection).Parent.ComponentDefinition is PartComponentDefinition def)
{
    PlanarSketch profile = def.Sketches.Add(selection);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both of these snippets fail upon adding the sketch the part's component definition.&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To my understanding, you can only create a sketch profile on a planar face that resides within its part. But the code above is accessing the component definition of the face as it's parent, ensuring that I am getting the correct component definition for the face.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are faces not suitable for sketches? In Inventor's built-in "Start 2D Sketch" tool you can select a face on some geometry to create a sketch onto.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance into understanding why I cannot add a sketch to a face of a part would be greatly appreciated.&lt;/P&gt;</description>
    <pubDate>Tue, 24 Feb 2026 03:24:39 GMT</pubDate>
    <dc:creator>kristian_oa</dc:creator>
    <dc:date>2026-02-24T03:24:39Z</dc:date>
    <item>
      <title>Create Sketch Fom Selected Face (Replicate "Start 2D Sketch" tool)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-sketch-fom-selected-face-replicate-quot-start-2d-sketch/m-p/14029570#M179549</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to create a sketch onto a face within a part, which I will then add/modify features from, however I am unable to create a 2D sketch onto any desired face as I am given an error upon running Sketches.Add().&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This part is currently an immediate child of the active assembly, but I have also attempted in modifying a part within an assembly, which itself is within the active assembly (a part within a sub-assembly).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To simplify my debugging process, I decided to replicate the "Start 2D Sketch" tool and select a specific face I want to create a sketch onto. Code snippets for this are below:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;iLogic Sample:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim face As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select a face")

' Only attempt to add a sketch if the selected face belongs to a part
If (face.Parent.ComponentDefinition.Type = ObjectTypeEnum.kPartComponentDefinitionObject) Then
	Dim def = face.Parent.ComponentDefinition
    Dim sketch As PlanarSketch = def.Sketches.Add(selection)
End If&lt;/LI-CODE&gt;&lt;P&gt;C# Sample:&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Face selection = (Face)Globals.InventorApp.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a face");

// Only attempt to add a sketch if the selected face belongs to a part
if (((Face)selection).Parent.ComponentDefinition is PartComponentDefinition def)
{
    PlanarSketch profile = def.Sketches.Add(selection);
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Both of these snippets fail upon adding the sketch the part's component definition.&lt;/P&gt;&lt;P&gt;What am I doing wrong?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To my understanding, you can only create a sketch profile on a planar face that resides within its part. But the code above is accessing the component definition of the face as it's parent, ensuring that I am getting the correct component definition for the face.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are faces not suitable for sketches? In Inventor's built-in "Start 2D Sketch" tool you can select a face on some geometry to create a sketch onto.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any guidance into understanding why I cannot add a sketch to a face of a part would be greatly appreciated.&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2026 03:24:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-sketch-fom-selected-face-replicate-quot-start-2d-sketch/m-p/14029570#M179549</guid>
      <dc:creator>kristian_oa</dc:creator>
      <dc:date>2026-02-24T03:24:39Z</dc:date>
    </item>
    <item>
      <title>Re: Create Sketch Fom Selected Face (Replicate "Start 2D Sketch" tool)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-sketch-fom-selected-face-replicate-quot-start-2d-sketch/m-p/14030102#M179557</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/17872265"&gt;@kristian_oa&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Quick fix:&lt;/P&gt;
&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;face&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;FaceProxy&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;CommandManager&lt;/SPAN&gt;.&lt;SPAN&gt;Pick&lt;/SPAN&gt;(&lt;SPAN&gt;SelectionFilterEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kPartFacePlanarFilter&lt;/SPAN&gt;, &lt;SPAN&gt;"Select a face"&lt;/SPAN&gt;)

&lt;SPAN&gt;' Only attempt to add a sketch if the selected face belongs to a part&lt;/SPAN&gt;
&lt;SPAN&gt;If&lt;/SPAN&gt; (&lt;SPAN&gt;face&lt;/SPAN&gt;.&lt;SPAN&gt;Parent&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN&gt;Type&lt;/SPAN&gt; = &lt;SPAN&gt;ObjectTypeEnum&lt;/SPAN&gt;.&lt;SPAN&gt;kPartComponentDefinitionObject&lt;/SPAN&gt;) &lt;SPAN&gt;Then&lt;/SPAN&gt;
	&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;def&lt;/SPAN&gt; = &lt;SPAN&gt;face&lt;/SPAN&gt;.&lt;SPAN&gt;Parent&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
    &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;sketch&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PlanarSketch&lt;/SPAN&gt; = &lt;SPAN&gt;def&lt;/SPAN&gt;.&lt;SPAN&gt;Sketches&lt;/SPAN&gt;.&lt;SPAN&gt;Add&lt;/SPAN&gt;(&lt;SPAN&gt;face&lt;/SPAN&gt;.&lt;SPAN&gt;NativeObject&lt;/SPAN&gt;)
&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;If&lt;/SPAN&gt;&lt;/PRE&gt;
&lt;P&gt;When you pick a face in assembly environment it's actually not a face but a faceproxy (the face represented in context of the assembly). Therefore, use face.NativeObject to get the face in the parts context &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2026 11:01:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-sketch-fom-selected-face-replicate-quot-start-2d-sketch/m-p/14030102#M179557</guid>
      <dc:creator>JhoelForshav</dc:creator>
      <dc:date>2026-02-24T11:01:34Z</dc:date>
    </item>
    <item>
      <title>Re: Create Sketch Fom Selected Face (Replicate "Start 2D Sketch" tool)</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-sketch-fom-selected-face-replicate-quot-start-2d-sketch/m-p/14030963#M179577</link>
      <description>&lt;P&gt;Thank you so much for this!&lt;/P&gt;&lt;P&gt;I completely forgot proxies exist and are to be used in these scenarios. You're a legend!&lt;/P&gt;</description>
      <pubDate>Tue, 24 Feb 2026 20:47:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-sketch-fom-selected-face-replicate-quot-start-2d-sketch/m-p/14030963#M179577</guid>
      <dc:creator>kristian_oa</dc:creator>
      <dc:date>2026-02-24T20:47:46Z</dc:date>
    </item>
  </channel>
</rss>

