<?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: Export Face As DXF in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269724#M18402</link>
    <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;It requires you to have a face selected before running. You could select this face programmatically or manually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()

Dim oCtrlDef As ButtonDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")

Dim oDXFFullFileName As String
oDXFFullFileName = "C:\Temp\Face.dxf"

ThisApplication.CommandManager.PostPrivateEvent( PrivateEventTypeEnum.kFileNameEvent, oDXFFullFileName)

oCtrlDef.Execute

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Borrowed from here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/api-quot-export-face-as-dxf-quot-in-previous-version/m-p/9060984#M101769" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/api-quot-export-face-as-dxf-quot-in-previous-version/m-p/9060984#M101769&lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 27 Sep 2023 10:53:07 GMT</pubDate>
    <dc:creator>gerrardhickson</dc:creator>
    <dc:date>2023-09-27T10:53:07Z</dc:date>
    <item>
      <title>Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269275#M18401</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to export a face from a solid using iLogic. I have made the face a named entity and have been trying to export the face using the&amp;nbsp;GeomToDXFCommand API, but have had no luck in being able to pass the face to the API. I can't export the flat pattern as I only want the face in its folded form. Is there a way to get the functionality of 'Right Click' &amp;gt; 'Export Face As' using iLogic?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 07:40:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269275#M18401</guid>
      <dc:creator>mitchELAHB</dc:creator>
      <dc:date>2023-09-27T07:40:39Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269724#M18402</link>
      <description>&lt;P&gt;Try this:&lt;/P&gt;&lt;P&gt;It requires you to have a face selected before running. You could select this face programmatically or manually.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub Main()

Dim oCtrlDef As ButtonDefinition
oCtrlDef = ThisApplication.CommandManager.ControlDefinitions.Item("GeomToDXFCommand")

Dim oDXFFullFileName As String
oDXFFullFileName = "C:\Temp\Face.dxf"

ThisApplication.CommandManager.PostPrivateEvent( PrivateEventTypeEnum.kFileNameEvent, oDXFFullFileName)

oCtrlDef.Execute

End Sub&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Borrowed from here:&lt;/P&gt;&lt;P&gt;&lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/api-quot-export-face-as-dxf-quot-in-previous-version/m-p/9060984#M101769" target="_blank" rel="noopener"&gt;https://forums.autodesk.com/t5/inventor-ilogic-and-vb-net-forum/api-quot-export-face-as-dxf-quot-in-previous-version/m-p/9060984#M101769&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 10:53:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269724#M18402</guid>
      <dc:creator>gerrardhickson</dc:creator>
      <dc:date>2023-09-27T10:53:07Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269837#M18403</link>
      <description>&lt;P&gt;Thanks, I've implemented something similar with a try/catch statement when setting the face name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Function SaveFace(FaceName As String, SavePath As String)	

	'finding entity called 'FaceName', providing error if can't find
	Dim oNamedEntities = iLogicVb.Automation.GetNamedEntities(ThisDoc.Document)
	Try
		oFace = oNamedEntities.FindEntity(FaceName)
	Catch
		MessageBox.Show("Cannot find face called '" &amp;amp; FaceName &amp;amp; "'! DXF not saved.", "Error saving file")
		Exit Function
	End Try
	
	'selecting entity called 'FaceName'
	ThisDoc.Document.SelectSet.Select(oFace)
	
	'Export selected face to 'SavePath'	
	Dim oCmdMgr As CommandManager = ThisApplication.CommandManager
	Dim oCtrlDef As ButtonDefinition = oCmdMgr.ControlDefinitions.Item("GeomToDXFCommand")
	oCmdMgr.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, SavePath)
	oCtrlDef.Execute

End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works well for my needs, but I did wonder if there was a more elegant solution than selecting the face programmatically.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 11:45:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269837#M18403</guid>
      <dc:creator>mitchELAHB</dc:creator>
      <dc:date>2023-09-27T11:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269907#M18404</link>
      <description>&lt;P&gt;Do you mean you would like to export the face directly? E.g. oFace.exporttodxf?&amp;nbsp;&lt;/P&gt;&lt;P&gt;If that's what you were hoping for, then it seems that you're out of luck. I think the exit face as DXF was introduced to inventor relatively recently, so it hasn't been included in the API yet.&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 12:01:45 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269907#M18404</guid>
      <dc:creator>gerrardhickson</dc:creator>
      <dc:date>2023-09-27T12:01:45Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269921#M18405</link>
      <description>&lt;P&gt;Thanks for that. Yeah, I was hoping to be able to do some a bit more eloquently, but what I have works.&lt;/P&gt;&lt;P&gt;Cheers&lt;/P&gt;</description>
      <pubDate>Wed, 27 Sep 2023 12:07:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12269921#M18405</guid>
      <dc:creator>mitchELAHB</dc:creator>
      <dc:date>2023-09-27T12:07:37Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12324210#M18406</link>
      <description>Thanks for sharing this code.&lt;BR /&gt;Very helpful for me.&lt;BR /&gt;&lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;</description>
      <pubDate>Mon, 23 Oct 2023 12:15:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12324210#M18406</guid>
      <dc:creator>MSt-Louis</dc:creator>
      <dc:date>2023-10-23T12:15:53Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12329634#M18407</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4760353"&gt;@mitchELAHB&lt;/a&gt;&amp;nbsp;, it works great.&lt;/P&gt;&lt;P&gt;Instead of exporting a face from "ThisDoc",&amp;nbsp;&lt;SPAN&gt;I would like to export a face from a known file, because I want to run this rule in a DWG file to export faces from multiple .ipt files that are there.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Eg.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;'selecting entity called 'FaceName'
ThisDoc.Document.SelectSet.Select(oFace)&lt;/PRE&gt;&lt;P&gt;How can I change this line to select oFace from a specific known file?&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Wed, 25 Oct 2023 11:23:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12329634#M18407</guid>
      <dc:creator>MSt-Louis</dc:creator>
      <dc:date>2023-10-25T11:23:46Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12355584#M18408</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Would something like this do?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="visual-basic"&gt;Sub main()
	
	Dim sFilePath As String = "C:\TEST\Test.ipt"
	Dim oDoc As Document = ThisApplication.Documents.Open(sFilePath, True) 	'False = open invisible, True = open visible. invisible is much faster.
	Dim oFaceName As String = "Test" 
	Dim oSavePath As String = "C:\TEST\Test.dxf"
	SaveFace(oDoc, oFaceName, oSavePath)
	oDoc.Close
	
End Sub

Function SaveFace(oDoc As Document, FaceName As String, SavePath As String)	

	'finding entity called 'FaceName', providing error if can't find
	Dim oNamedEntities = iLogicVb.Automation.GetNamedEntities(oDoc)
	Try
		oFace = oNamedEntities.FindEntity(FaceName)
	Catch
		MessageBox.Show("Cannot find face called '" &amp;amp; FaceName &amp;amp; "'! DXF not saved.", "Error saving file")
		Exit Function
	End Try
	
	Dim oFolder As String = System.IO.Path.GetDirectoryName(SavePath)
	
	'creating folder if not exist
	If Not System.IO.Directory.Exists(oFolder) Then
	    System.IO.Directory.CreateDirectory(oFolder)
	End If
	
	'selecting entity called 'FaceName'
	oDoc.SelectSet.Select(oFace)
	
	'Export selected face to 'SavePath'	
	Dim oCmdMgr As CommandManager = ThisApplication.CommandManager
	Dim oCtrlDef As ButtonDefinition = oCmdMgr.ControlDefinitions.Item("GeomToDXFCommand")
	oCmdMgr.PostPrivateEvent(PrivateEventTypeEnum.kFileNameEvent, SavePath)
	oCtrlDef.Execute

	'deselecting entity called 'FaceName'
	oDoc.SelectSet.Clear

End Function&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Unfourtnately I think you'll need to open the files visibly to get the GeomToDXFCommand to work, which slows things down a little. I haven't tested this code much so you might need to add a few tweeks.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 05:13:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12355584#M18408</guid>
      <dc:creator>mitchELAHB</dc:creator>
      <dc:date>2023-11-09T05:13:25Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12357051#M18409</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;Thank you for the code. Yes it works !&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;The only issue is here:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Document&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;Documents&lt;/SPAN&gt;.&lt;SPAN&gt;Open&lt;/SPAN&gt;(&lt;SPAN&gt;sFilePath&lt;/SPAN&gt;, &lt;SPAN&gt;True&lt;/SPAN&gt;) 	&lt;SPAN&gt;'False = open invisible, True = open visible. invisible is much faster.&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;If I set the boolean to False (wich I think is a good idea to open invisible), the export does not take place. But I think you already knew this.&lt;/P&gt;&lt;P&gt;If I have no choice, I'll add oDoc.Close at the end of your code.&lt;/P&gt;</description>
      <pubDate>Mon, 06 Nov 2023 14:33:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12357051#M18409</guid>
      <dc:creator>MSt-Louis</dc:creator>
      <dc:date>2023-11-06T14:33:26Z</dc:date>
    </item>
    <item>
      <title>Re: Export Face As DXF</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12364715#M18410</link>
      <description>&lt;P&gt;Yes, as far as I know the document will need to be opened. Good point on closing the file, that slipped my mind, I'll update my code for any future searches that find this topic.&lt;/P&gt;</description>
      <pubDate>Thu, 09 Nov 2023 05:11:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/export-face-as-dxf/m-p/12364715#M18410</guid>
      <dc:creator>mitchELAHB</dc:creator>
      <dc:date>2023-11-09T05:11:26Z</dc:date>
    </item>
  </channel>
</rss>

