<?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: Create a sketch on a certain face in a part with iLogic in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9376307#M67217</link>
    <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5011186"&gt;@JelteDeJong&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I cant test this for you but you could try the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;oAssDoc = ThisApplication.ActiveDocument
oAssDef = oAssDoc.ComponentDefinition
Dim oFace As Face
&lt;FONT color="#0000FF"&gt;if (iLogicVb.Automation.NameExists("face0"))
	iLogicVb.Automation.FindEntity("face0")&lt;/FONT&gt;
else
	oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face ")
end if

'make sure it is a planar face
If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then

oPlanarSurface = oFace.Geometry

'add a sketch
oSketch = oAssDef.Sketches.Add(oFace)

'trying to choose an appropriate point
'assume this planar face has one edge loop only
oEdgeLoop = oFace.EdgeLoops(1)

oMinPt = oEdgeLoop.RangeBox.MinPoint
oMaxPt = oEdgeLoop.RangeBox.MaxPoint

CenterPt = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)

Else

End If&lt;/PRE&gt;&lt;P&gt;(i got the idea from &lt;A href="https://forums.autodesk.com/t5/inventor-customization/where-is-new-feature-face-name-in-inventor-2019-api-located/m-p/8771402/highlight/true#M97154" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-customization/where-is-new-feature-face-name-in-inventor-2019-api-located/m-p/8771402/highlight/true#M97154&lt;/A&gt; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;this might be dumb question but I am trying to use this as iLogic rule and it gives errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error on Line 4 : 'NameExists' is not a member of 'Autodesk.iLogic.Interfaces.IiLogicAutomation'.&lt;BR /&gt;Error on Line 5 : 'FindEntity' is not a member of 'Autodesk.iLogic.Interfaces.IiLogicAutomation'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please explain why is this error coming up? is the rule meant to be used only in VBA or VB.NET?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;</description>
    <pubDate>Fri, 13 Mar 2020 12:05:18 GMT</pubDate>
    <dc:creator>sam</dc:creator>
    <dc:date>2020-03-13T12:05:18Z</dc:date>
    <item>
      <title>Create a sketch on a certain face in a part with iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9284673#M67212</link>
      <description>&lt;P&gt;Hello guys,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to make a code that "detects" a named face and create a sketch on that face.&lt;/P&gt;&lt;P&gt;I have a code, but i have to click the face to create a sketch.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The code:&lt;/P&gt;&lt;PRE&gt;oAssDoc = ThisApplication.ActiveDocument
oAssDef = oAssDoc.ComponentDefinition
Dim oFace As Face
oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face ")
'make sure it is a planar face
If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then

oPlanarSurface = oFace.Geometry

'add a sketch
oSketch = oAssDef.Sketches.Add(oFace)

'trying to choose an appropriate point
'assume this planar face has one edge loop only
oEdgeLoop = oFace.EdgeLoops(1)

oMinPt = oEdgeLoop.RangeBox.MinPoint
oMaxPt = oEdgeLoop.RangeBox.MaxPoint

CenterPt = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)

Else

End If&lt;/PRE&gt;&lt;P&gt;Is it possible to detect the ‘face0’ in the named geometry(without extra clicking) and create a sketch on that face?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Face0.jpg" style="width: 400px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/723544iD18B5C2A2B7A25CE/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Face0.jpg" alt="Face0.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Help is much appreciated &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 07:31:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9284673#M67212</guid>
      <dc:creator>RajivAngoelal</dc:creator>
      <dc:date>2020-01-30T07:31:30Z</dc:date>
    </item>
    <item>
      <title>Re: Create a sketch on a certain face in a part with iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9284832#M67213</link>
      <description>&lt;P&gt;did you see this post about getting a named face?&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-customization/where-is-new-feature-face-name-in-inventor-2019-api-located/m-p/8380509/highlight/true#M91013" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-customization/where-is-new-feature-face-name-in-inventor-2019-api-located/m-p/8380509/highlight/true#M91013&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 08:59:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9284832#M67213</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2020-01-30T08:59:06Z</dc:date>
    </item>
    <item>
      <title>Re: Create a sketch on a certain face in a part with iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9284884#M67214</link>
      <description>&lt;P&gt;Dear JelteDeJong,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes i have seen the post, but the post had nothing to do with my&amp;nbsp;&lt;FONT&gt;preferred&lt;/FONT&gt; request.&lt;/P&gt;&lt;P&gt;i would like to create a sketch on a particular face. The name of the face does not matter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 09:19:56 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9284884#M67214</guid>
      <dc:creator>RajivAngoelal</dc:creator>
      <dc:date>2020-01-30T09:19:56Z</dc:date>
    </item>
    <item>
      <title>Re: Create a sketch on a certain face in a part with iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9285314#M67215</link>
      <description>&lt;P&gt;I cant test this for you but you could try the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;oAssDoc = ThisApplication.ActiveDocument
oAssDef = oAssDoc.ComponentDefinition
Dim oFace As Face
&lt;FONT color="#0000FF"&gt;if (iLogicVb.Automation.NameExists("face0"))
	iLogicVb.Automation.FindEntity("face0")&lt;/FONT&gt;
else
	oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face ")
end if

'make sure it is a planar face
If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then

oPlanarSurface = oFace.Geometry

'add a sketch
oSketch = oAssDef.Sketches.Add(oFace)

'trying to choose an appropriate point
'assume this planar face has one edge loop only
oEdgeLoop = oFace.EdgeLoops(1)

oMinPt = oEdgeLoop.RangeBox.MinPoint
oMaxPt = oEdgeLoop.RangeBox.MaxPoint

CenterPt = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)

Else

End If&lt;/PRE&gt;&lt;P&gt;(i got the idea from &lt;A href="https://forums.autodesk.com/t5/inventor-customization/where-is-new-feature-face-name-in-inventor-2019-api-located/m-p/8771402/highlight/true#M97154" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-customization/where-is-new-feature-face-name-in-inventor-2019-api-located/m-p/8771402/highlight/true#M97154&lt;/A&gt; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 12:51:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9285314#M67215</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2020-01-30T12:51:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create a sketch on a certain face in a part with iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9285450#M67216</link>
      <description>&lt;P&gt;Thank you very much. it works :).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i made the code a little bit smaller&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On Error Resume Next&lt;/P&gt;&lt;P&gt;oDoc = ThisApplication.ActiveDocument&lt;BR /&gt;oDef = oDoc.ComponentDefinition&lt;/P&gt;&lt;P&gt;Dim partDoc As PartDocument = ThisDoc.Document&lt;BR /&gt;Dim namedEntities = iLogicVb.Automation.GetNamedEntities(partDoc)&lt;/P&gt;&lt;P&gt;Dim oFace As Face&lt;BR /&gt;oFace = namedEntities.FindEntity("Face0")&lt;BR /&gt;oSketch = oDef.Sketches.Add(oFace)&lt;BR /&gt;oSketch.name = "Face0"&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 13:38:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9285450#M67216</guid>
      <dc:creator>RajivAngoelal</dc:creator>
      <dc:date>2020-01-30T13:38:08Z</dc:date>
    </item>
    <item>
      <title>Re: Create a sketch on a certain face in a part with iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9376307#M67217</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5011186"&gt;@JelteDeJong&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;I cant test this for you but you could try the following.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;oAssDoc = ThisApplication.ActiveDocument
oAssDef = oAssDoc.ComponentDefinition
Dim oFace As Face
&lt;FONT color="#0000FF"&gt;if (iLogicVb.Automation.NameExists("face0"))
	iLogicVb.Automation.FindEntity("face0")&lt;/FONT&gt;
else
	oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select a Face ")
end if

'make sure it is a planar face
If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then

oPlanarSurface = oFace.Geometry

'add a sketch
oSketch = oAssDef.Sketches.Add(oFace)

'trying to choose an appropriate point
'assume this planar face has one edge loop only
oEdgeLoop = oFace.EdgeLoops(1)

oMinPt = oEdgeLoop.RangeBox.MinPoint
oMaxPt = oEdgeLoop.RangeBox.MaxPoint

CenterPt = ThisApplication.TransientGeometry.CreatePoint((oMaxPt.X + oMinPt.X) / 2#, (oMaxPt.Y + oMinPt.Y) / 2#, (oMaxPt.Z + oMinPt.Z) / 2#)

Else

End If&lt;/PRE&gt;&lt;P&gt;(i got the idea from &lt;A href="https://forums.autodesk.com/t5/inventor-customization/where-is-new-feature-face-name-in-inventor-2019-api-located/m-p/8771402/highlight/true#M97154" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-customization/where-is-new-feature-face-name-in-inventor-2019-api-located/m-p/8771402/highlight/true#M97154&lt;/A&gt; )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;this might be dumb question but I am trying to use this as iLogic rule and it gives errors:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Error on Line 4 : 'NameExists' is not a member of 'Autodesk.iLogic.Interfaces.IiLogicAutomation'.&lt;BR /&gt;Error on Line 5 : 'FindEntity' is not a member of 'Autodesk.iLogic.Interfaces.IiLogicAutomation'.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you please explain why is this error coming up? is the rule meant to be used only in VBA or VB.NET?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best regards,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sam&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 12:05:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9376307#M67217</guid>
      <dc:creator>sam</dc:creator>
      <dc:date>2020-03-13T12:05:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a sketch on a certain face in a part with iLogic</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9376363#M67218</link>
      <description>&lt;BLOCKQUOTE&gt;&lt;HR /&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/1856297"&gt;@RajivAngoelal&lt;/a&gt;&amp;nbsp;wrote:&lt;BR /&gt;&lt;P&gt;Thank you very much. it works :).&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;i made the code a little bit smaller&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;On Error Resume Next&lt;/P&gt;&lt;P&gt;oDoc = ThisApplication.ActiveDocument&lt;BR /&gt;oDef = oDoc.ComponentDefinition&lt;/P&gt;&lt;P&gt;Dim partDoc As PartDocument = ThisDoc.Document&lt;BR /&gt;Dim namedEntities = iLogicVb.Automation.GetNamedEntities(partDoc)&lt;/P&gt;&lt;P&gt;Dim oFace As Face&lt;BR /&gt;oFace = namedEntities.FindEntity("Face0")&lt;BR /&gt;oSketch = oDef.Sketches.Add(oFace)&lt;BR /&gt;oSketch.name = "Face0"&lt;/P&gt;&lt;HR /&gt;&lt;/BLOCKQUOTE&gt;&lt;P&gt;This is working brilliantly as I thought. Thank you so much.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Mar 2020 12:32:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/create-a-sketch-on-a-certain-face-in-a-part-with-ilogic/m-p/9376363#M67218</guid>
      <dc:creator>sam</dc:creator>
      <dc:date>2020-03-13T12:32:27Z</dc:date>
    </item>
  </channel>
</rss>

