<?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: Inventor 2025 API - How to use AddBySilhouette() to add a Face to a Planar Sketch if they are not on the same plane in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2025-api-how-to-use-addbysilhouette-to-add-a-face-to-a/m-p/13289525#M2690</link>
    <description>&lt;P&gt;I believe you can't directly project a face, and you must cycle through each edge of that face and project them separately. I don't code in C# but maybe you can get the idea from this iLogic code:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim oDoc As PartDocument = ThisDoc.Document

Dim oSketch As Sketch = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select Sketch")
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Face")

For Each oEdge As Edge In oFace.Edges
	
	oSketch.AddByProjectingEntity(oEdge)
	
Next&lt;/LI-CODE&gt;</description>
    <pubDate>Wed, 29 Jan 2025 23:37:07 GMT</pubDate>
    <dc:creator>C_Haines_ENG</dc:creator>
    <dc:date>2025-01-29T23:37:07Z</dc:date>
    <item>
      <title>Inventor 2025 API - How to use AddBySilhouette() to add a Face to a Planar Sketch if they are not on the same plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2025-api-how-to-use-addbysilhouette-to-add-a-face-to-a/m-p/13280790#M2689</link>
      <description>&lt;P&gt;I have some code where I am trying to add a Face (or Edge) to a Sketch. I keep getting errors and I believe the issue is that they are not on the same plane and I think I need to do some sort of projection to make this occur.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, I hope you will forgive me because my code is in C#&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;public void ProjectHoleFaceToSketch(PlanarSketch sketch, Face face)
        {
            if (sketch == null || face == null)
                throw new ArgumentNullException("Sketch or face is null.");

            try
            {
                var failed = false;
                try
                {
                    // this does not work.
                    var faceVertices = face.Vertices;
                    var proximityPoint = faceVertices[1].Point; // Use any vertex as a starting point
                    sketch.AddBySilhouette(face, proximityPoint);

                }
                catch (Exception ex)
                {
                    failed = true;
                    _logger.LogError(ex, "Failed to project face onto sketch.");
                }

                if (failed == true)
                {
                    try
                    {
                        //this also does not work
                        var plane = sketch.PlanarEntity as Plane;
                        double[] rootPoint = new double[3];
                        double[] normal = new double[3];
                        plane.GetPlaneData(ref rootPoint, ref normal);

                        var proximityPoint = _application.TransientGeometry.CreatePoint(rootPoint[0], rootPoint[1], rootPoint[2]);
                    }
                    catch (Exception ex)
                    {
                        _logger.LogError(ex, "Failed to project face onto sketch.");
                    }
                }
                
            }
            catch (Exception ex)
            {
                _logger.LogError(ex, "[SketchService][ProjectHoleFaceToSketch] Failed to project edges onto sketch.");
            }

        }&lt;/LI-CODE&gt;&lt;P&gt;This results in the following error:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;The parameter is incorrect. (0x80070057 (E_INVALIDARG))
System.ArgumentException: The parameter is incorrect. (0x80070057 (E_INVALIDARG))
   at System.RuntimeType.InvokeMember(String name, BindingFlags bindingFlags, Binder binder, Object target, Object[] providedArgs, ParameterModifier[] modifiers, CultureInfo culture, String[] namedParams)
   at System.RuntimeType.ForwardCallToInvokeMember(String memberName, BindingFlags flags, Object target, Object[] aArgs, Boolean[] aArgsIsByRef, Int32[] aArgsWrapperTypes, Type[] aArgsTypes, Type retType)
   at Inventor.PlanarSketch.AddBySilhouette(Face Face, Point ProximityPoint)
   at TeakIsleInventor.AddIn.Services.Inventor.SketchService.ProjectHoleFaceToSketch(PlanarSketch sketch, Face face) in c:\...\\Inventor\SketchService.cs:line 692&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 24 Jan 2025 19:44:41 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2025-api-how-to-use-addbysilhouette-to-add-a-face-to-a/m-p/13280790#M2689</guid>
      <dc:creator>rwemmerLHAEW</dc:creator>
      <dc:date>2025-01-24T19:44:41Z</dc:date>
    </item>
    <item>
      <title>Re: Inventor 2025 API - How to use AddBySilhouette() to add a Face to a Planar Sketch if they are not on the same plane</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2025-api-how-to-use-addbysilhouette-to-add-a-face-to-a/m-p/13289525#M2690</link>
      <description>&lt;P&gt;I believe you can't directly project a face, and you must cycle through each edge of that face and project them separately. I don't code in C# but maybe you can get the idea from this iLogic code:&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Dim oDoc As PartDocument = ThisDoc.Document

Dim oSketch As Sketch = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kSketchObjectFilter, "Select Sketch")
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Face")

For Each oEdge As Edge In oFace.Edges
	
	oSketch.AddByProjectingEntity(oEdge)
	
Next&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 29 Jan 2025 23:37:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/inventor-2025-api-how-to-use-addbysilhouette-to-add-a-face-to-a/m-p/13289525#M2690</guid>
      <dc:creator>C_Haines_ENG</dc:creator>
      <dc:date>2025-01-29T23:37:07Z</dc:date>
    </item>
  </channel>
</rss>

