<?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: Deleting Everything from Part - Workplane Problem! in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522909#M14224</link>
    <description>Wow, that is a much much faster way to delete everything, tank you!</description>
    <pubDate>Fri, 26 Jan 2024 22:40:50 GMT</pubDate>
    <dc:creator>1211212212112122</dc:creator>
    <dc:date>2024-01-26T22:40:50Z</dc:date>
    <item>
      <title>Deleting Everything from Part - Workplane Problem!</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12521837#M14218</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I often need to delete the entire content of a part which mostly holds Extrusion, Lofting Features, 3d Sketches, 2d Sketches and Workplanes.&lt;/P&gt;&lt;P&gt;I got a working code for deleting everything except for Workplanes:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;' iLogic code to delete all features and sketches in an Inventor part document

Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

If oPartDoc Is Nothing Then
    MessageBox.Show("No active part document found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
    ' Deactivate the document's automatic update to improve performance
    oPartDoc.Update2(False)

    ' Delete all features
    For Each oFeature In oPartDoc.ComponentDefinition.Features
        oFeature.Delete()
    Next

    ' Delete all sketches
    For Each oSketch In oPartDoc.ComponentDefinition.Sketches
        oSketch.Delete()
    Next
	
	' Loop through all 3D sketches
    For Each oSketch In oPartDoc.ComponentDefinition.Sketches3D
        oSketch.Delete()
    Next
	
	' Loop through all WorkPoints
    For Each oWorkPoint In oPartDoc.ComponentDefinition.WorkPoints
        oWorkPoint.Delete()
    Next
	
	' Loop through all WorkAxes
    For Each oWorkAxe In oPartDoc.ComponentDefinition.WorkAxes
        oWorkAxe.Delete()
    Next
	
	' Loop through all Planes !!! This Part Does not work!!!
'    For Each WorkPlane In oPartDoc.ComponentDefinition.WorkPlanes
'        WorkPlane.Delete()
'    Next
	
    ' Reactivate the document's automatic update
    oPartDoc.Update2(True)

    MessageBox.Show("All features and sketches have been deleted.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As far as I am understanding the Error which I am getting is telling me that it is simply not possible to delete workplanes from a part? (Sorry it is in German)&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Regelkompilierungsfehler in Features_löschen, in B_3D_011.ipt

Fehler in Zeile 39 : "Delete" ist kein Member von "Autodesk.iLogic.Interfaces.ICadWorkPlane".&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any workaround?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 12:04:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12521837#M14218</guid>
      <dc:creator>1211212212112122</dc:creator>
      <dc:date>2024-01-26T12:04:26Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Everything from Part - Workplane Problem!</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12521906#M14219</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my opinion, you are trying to delete planes and axes that are initial elements and cannot be removed. You can only delete elements that you have created.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Although I'm not sure. Please check and let me know if you succeeded&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartDocument&lt;/SPAN&gt;
&lt;SPAN&gt;oPartDoc&lt;/SPAN&gt; = &lt;SPAN&gt;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;

&lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oWorkPlane&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;WorkPlane&lt;/SPAN&gt;

&lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;Each&lt;/SPAN&gt; &lt;SPAN&gt;oWorkPlane&lt;/SPAN&gt; &lt;SPAN&gt;In&lt;/SPAN&gt; &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;.&lt;SPAN&gt;WorkPlanes&lt;/SPAN&gt;
	&lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;oWorkPlane&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN&gt;"Płaszczyzna YZ"&lt;/SPAN&gt; &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;oWorkPlane&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN&gt;"Płaszczyzna XZ"&lt;/SPAN&gt; &lt;SPAN&gt;And&lt;/SPAN&gt; &lt;SPAN&gt;oWorkPlane&lt;/SPAN&gt;.&lt;SPAN&gt;Name&lt;/SPAN&gt; &amp;lt;&amp;gt; &lt;SPAN&gt;"Płaszczyzna XY"&lt;/SPAN&gt;
		&lt;SPAN&gt;oWorkPlane&lt;/SPAN&gt;.&lt;SPAN&gt;Delete&lt;/SPAN&gt;()
	&lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;if&lt;/SPAN&gt;
&lt;SPAN&gt;Next&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="m_baczewski_0-1706274187883.png" style="width: 823px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/1318587iD063C6BB4B3934D3/image-dimensions/823x218?v=v2" width="823" height="218" role="button" title="m_baczewski_0-1706274187883.png" alt="m_baczewski_0-1706274187883.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 13:02:05 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12521906#M14219</guid>
      <dc:creator>m_baczewski</dc:creator>
      <dc:date>2024-01-26T13:02:05Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Everything from Part - Workplane Problem!</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12521953#M14220</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5993596"&gt;@1211212212112122&lt;/a&gt;.&amp;nbsp; Although&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14139840"&gt;@m_baczewski&lt;/a&gt;&amp;nbsp;is correct that you will not be able to delete the original 3 WorkPlanes, due to them being part of the document origin structure, I see something different there, which is likely causing problems.&amp;nbsp; You are using the same exact spelling and capitalization for your variable in that loop as the object's Type, which is not allowed, and can cause problems.&amp;nbsp; Maybe just add a lowercase letter "o" to that variable (for example "oWorkPlanes"), like you did with all the other variables.&lt;/P&gt;
&lt;P&gt;Edit:&amp;nbsp; Also, just as additional insight into what you are seeing within that error message, there is both an Inventor API &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=GUID-WorkPlane" target="_blank" rel="noopener"&gt;WorkPlane&lt;/A&gt; type object, and an iLogic variable named &lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=4c0fcba1-6986-ca53-d3f0-3547c3356506" target="_blank" rel="noopener"&gt;WorkPlane&lt;/A&gt;, and that iLogic variable represents the Autodesk.iLogic.Interfaces.ICadWorkPlane Interface.&amp;nbsp; Below is a link to the documentation about that iLogic variable.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=4c0fcba1-6986-ca53-d3f0-3547c3356506" target="_blank" rel="noopener"&gt;https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=4c0fcba1-6986-ca53-d3f0-3547c3356506&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 13:27:39 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12521953#M14220</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-01-26T13:27:39Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Everything from Part - Workplane Problem!</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522333#M14221</link>
      <description>&lt;P&gt;Thank you very much for the quick replies. The same as&amp;nbsp;&lt;A href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/14139840" target="_self"&gt;&lt;SPAN class=""&gt;m_baczewski&lt;/SPAN&gt;&lt;/A&gt;&amp;nbsp;stated also applies for deleting workAxes and workPoint. The following code is working now: (For anyone who wants to use this code: Update the names of Planes, points, and centerpoint to your language!)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;' iLogic code to delete all features and sketches in an Inventor part document
Dim oPartDoc As PartDocument
oPartDoc = ThisApplication.ActiveDocument

If oPartDoc Is Nothing Then
    MessageBox.Show("No active part document found.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error)
Else
    ' Deactivate the document's automatic update to improve performance
    oPartDoc.Update2(False)

    ' Delete all features
    For Each oFeature In oPartDoc.ComponentDefinition.Features
        oFeature.Delete()
    Next

    ' Delete all sketches
    For Each oSketch In oPartDoc.ComponentDefinition.Sketches
        oSketch.Delete()
    Next
	
	' Loop through all 3D sketches
    For Each oSketch In oPartDoc.ComponentDefinition.Sketches3D
        oSketch.Delete()
    Next
	
	' Loop through all WorkPoints
	Dim oWorkPoint As WorkPoint
	For Each oWorkPoint In oPartDoc.ComponentDefinition.WorkPoints
		If oWorkPoint.Name &amp;lt;&amp;gt; "Mittelpunkt"
			oWorkPoint.Delete()
		End If
	Next
	
	' Loop through all WorkAxes
	Dim oWorkAxe As WorkAxis
	For Each oWorkAxe In oPartDoc.ComponentDefinition.WorkAxes
		If oWorkAxe.Name &amp;lt;&amp;gt; "X-Achse" And oWorkAxe.Name &amp;lt;&amp;gt; "Y-Achse" And oWorkAxe.Name &amp;lt;&amp;gt; "Z-Achse"
			oWorkAxe.Delete()
		End If
	Next
	
	' Loop through all WorkPlanes
	Dim oWorkPlane As WorkPlane
	For Each oWorkPlane In oPartDoc.ComponentDefinition.WorkPlanes
		If oWorkPlane.Name &amp;lt;&amp;gt; "YZ-Ebene" And oWorkPlane.Name &amp;lt;&amp;gt; "XZ-Ebene" And oWorkPlane.Name &amp;lt;&amp;gt; "XY-Ebene"
			oWorkPlane.Delete()
		End If
	Next
	
    ' Reactivate the document's automatic update
    oPartDoc.Update2(True)

    MessageBox.Show("All features and sketches have been deleted.", "Success", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 16:38:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522333#M14221</guid>
      <dc:creator>1211212212112122</dc:creator>
      <dc:date>2024-01-26T16:38:34Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Everything from Part - Workplane Problem!</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522359#M14222</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/5993596"&gt;@1211212212112122&lt;/a&gt;.&amp;nbsp; Just in case you were not aware, there is an easier way to check for if the work feature belongs to the origin structure.&amp;nbsp; Each of those object types has a direct property for that exact distinction.&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=WorkPlane_IsCoordinateSystemElement" target="_blank" rel="noopener"&gt;WorkPlane.IsCoordinateSystemElement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=WorkPoint_IsCoordinateSystemElement" target="_blank" rel="noopener"&gt;WorkPoint.IsCoordinateSystemElement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://help.autodesk.com/view/INVNTOR/2024/ENU/?guid=WorkAxis_IsCoordinateSystemElement" target="_blank" rel="noopener"&gt;WorkAxis.IsCoordinateSystemElement&lt;/A&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could check the value of that ReadOnly Boolean property, instead of checking their names.&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 16:47:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522359#M14222</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-01-26T16:47:06Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Everything from Part - Workplane Problem!</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522794#M14223</link>
      <description>&lt;P&gt;FYI You can also do something as simple as this to empty all user created objects:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;If ThisDoc.Document.DocumentType &amp;lt;&amp;gt; DocumentTypeEnum.kPartDocumentObject Then Exit Sub
ThisApplication.CommandManager.ControlDefinitions.Item("PartMoveEOPToTopCmd").Execute()
Thisapplication.CommandManager.ControlDefinitions.Item("PartDeleteBelowStopNodeCtxCmd").Execute()&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 26 Jan 2024 21:14:58 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522794#M14223</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2024-01-26T21:14:58Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting Everything from Part - Workplane Problem!</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522909#M14224</link>
      <description>Wow, that is a much much faster way to delete everything, tank you!</description>
      <pubDate>Fri, 26 Jan 2024 22:40:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/deleting-everything-from-part-workplane-problem/m-p/12522909#M14224</guid>
      <dc:creator>1211212212112122</dc:creator>
      <dc:date>2024-01-26T22:40:50Z</dc:date>
    </item>
  </channel>
</rss>

