<?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 work planes based off their position/offset in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210625#M174825</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15989309"&gt;@Patrick_JohnsonSU3NC&lt;/a&gt;.&amp;nbsp; That seems like an odd request, so it is a little odd to do by code without more detailed information than that.&amp;nbsp; There are lots of ways do 'define' a WorkPlane, and which way you used will make a difference in the code used to find them, since we can't just find the ones you want by their name.&amp;nbsp; We must determine how each WorkPlane was defined, then figure out how to get the defining data from its definition, such as an offset value.&amp;nbsp; However, that will be pointing to a Inventor API Parameter object in this case.&amp;nbsp; The Parameter has a 3 main properties for figuring out what its value is, and two of them will always return the value in 'database units' (centimeters for distance/length), instead of the parameter's own units.&amp;nbsp; The other property (Expression) is like what you see in the 'equation' column of the Parameters dialog box, and is a String, including the units specifier text, instead of a true numerical value that you can do math with or compare with other numerical values.&amp;nbsp; So, when you specify what offset value you want to find, you must do so in centimeters (using math if needed), and/or specify the exact String, exactly as you see it in the Parameters dialog equation column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is an example iLogic rule code you can play around with.&amp;nbsp; I put comment in there showing you where to set the values you are looking for.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	'&amp;lt;&amp;lt;&amp;lt; CHANGE VALUES OF THESE NEXT TWO VARIABLES &amp;gt;&amp;gt;&amp;gt;
	Dim dOffsetValueToFind As Double = (12.5 / 2.54) 'specify in centimeters
	Dim sOffsetExpressionToFind As String = "12.5 in"
	Dim oWPlanes As WorkPlanes = oPDoc.ComponentDefinition.WorkPlanes
	For Each oWPlane As WorkPlane In oWPlanes
		If oWPlane.IsCoordinateSystemElement Then Continue For
		'If Not oWPlane.Consumed Then oWPlane.Delete(False) 'False  = Do Not Retain Dependents
		If oWPlane.DefinitionType = WorkPlaneDefinitionEnum.kPlaneAndOffsetWorkPlane Then
			Dim oPOWPDef As PlaneAndOffsetWorkPlaneDef = oWPlane.Definition
			Dim oParam As Inventor.Parameter = oPOWPDef.Offset
			Dim dOffSetVal As Double = oParam.Value 'will be in 'database units' (centimeters)
			Dim sOffSetExpression As String = oParam.Expression
			'&amp;lt;&amp;lt;&amp;lt; HERE IS WHERE THE CHECK IS HAPPENING &amp;gt;&amp;gt;&amp;gt;
			If dOffSetVal = dOffsetValueToFind OrElse
				sOffSetExpression = sOffsetExpressionToFind Then
				Try
					oWPlane.Delete(False) 'False  = Do Not Retain Dependents
				Catch
					'what to do if that fail, like a message
				End Try
			End If
		End If
	Next
	oPDoc.Update2(True)
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN&gt;&lt;STRONG&gt; ACCEPT SOLUTION &lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7401B55A0A518861312A0F851CD29320/emoticons/1f44d.png" alt=":thumbs_up:" title=":thumbs_up:" /&gt;.&lt;/P&gt;</description>
    <pubDate>Fri, 13 Dec 2024 19:09:52 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2024-12-13T19:09:52Z</dc:date>
    <item>
      <title>Deleting work planes based off their position/offset</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210347#M174817</link>
      <description>&lt;P&gt;I have work planes in my template part that are used for constraining different components in an assembly.&amp;nbsp; There will be situations that the end use part will not need all of them and I would like to delete them from the end use part.&amp;nbsp; I have it set up so that if a plane will not be used, its offset from the origin will be set to a specific value.&amp;nbsp; How do I go about finding these planes and deleting them?&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 16:41:27 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210347#M174817</guid>
      <dc:creator>Patrick_JohnsonSU3NC</dc:creator>
      <dc:date>2024-12-13T16:41:27Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting work planes based off their position/offset</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210625#M174825</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/15989309"&gt;@Patrick_JohnsonSU3NC&lt;/a&gt;.&amp;nbsp; That seems like an odd request, so it is a little odd to do by code without more detailed information than that.&amp;nbsp; There are lots of ways do 'define' a WorkPlane, and which way you used will make a difference in the code used to find them, since we can't just find the ones you want by their name.&amp;nbsp; We must determine how each WorkPlane was defined, then figure out how to get the defining data from its definition, such as an offset value.&amp;nbsp; However, that will be pointing to a Inventor API Parameter object in this case.&amp;nbsp; The Parameter has a 3 main properties for figuring out what its value is, and two of them will always return the value in 'database units' (centimeters for distance/length), instead of the parameter's own units.&amp;nbsp; The other property (Expression) is like what you see in the 'equation' column of the Parameters dialog box, and is a String, including the units specifier text, instead of a true numerical value that you can do math with or compare with other numerical values.&amp;nbsp; So, when you specify what offset value you want to find, you must do so in centimeters (using math if needed), and/or specify the exact String, exactly as you see it in the Parameters dialog equation column.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Below is an example iLogic rule code you can play around with.&amp;nbsp; I put comment in there showing you where to set the values you are looking for.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Sub Main
	Dim oInvApp As Inventor.Application = ThisApplication
	Dim oPDoc As PartDocument = TryCast(ThisDoc.Document, Inventor.PartDocument)
	If oPDoc Is Nothing Then Return
	'&amp;lt;&amp;lt;&amp;lt; CHANGE VALUES OF THESE NEXT TWO VARIABLES &amp;gt;&amp;gt;&amp;gt;
	Dim dOffsetValueToFind As Double = (12.5 / 2.54) 'specify in centimeters
	Dim sOffsetExpressionToFind As String = "12.5 in"
	Dim oWPlanes As WorkPlanes = oPDoc.ComponentDefinition.WorkPlanes
	For Each oWPlane As WorkPlane In oWPlanes
		If oWPlane.IsCoordinateSystemElement Then Continue For
		'If Not oWPlane.Consumed Then oWPlane.Delete(False) 'False  = Do Not Retain Dependents
		If oWPlane.DefinitionType = WorkPlaneDefinitionEnum.kPlaneAndOffsetWorkPlane Then
			Dim oPOWPDef As PlaneAndOffsetWorkPlaneDef = oWPlane.Definition
			Dim oParam As Inventor.Parameter = oPOWPDef.Offset
			Dim dOffSetVal As Double = oParam.Value 'will be in 'database units' (centimeters)
			Dim sOffSetExpression As String = oParam.Expression
			'&amp;lt;&amp;lt;&amp;lt; HERE IS WHERE THE CHECK IS HAPPENING &amp;gt;&amp;gt;&amp;gt;
			If dOffSetVal = dOffsetValueToFind OrElse
				sOffSetExpression = sOffsetExpressionToFind Then
				Try
					oWPlane.Delete(False) 'False  = Do Not Retain Dependents
				Catch
					'what to do if that fail, like a message
				End Try
			End If
		End If
	Next
	oPDoc.Update2(True)
End Sub&lt;/LI-CODE&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN&gt;&lt;STRONG&gt; ACCEPT SOLUTION &lt;/STRONG&gt;&lt;/SPAN&gt;.&lt;BR /&gt;Or, if this helped you, please click (LIKE or KUDOS) &lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@7401B55A0A518861312A0F851CD29320/emoticons/1f44d.png" alt=":thumbs_up:" title=":thumbs_up:" /&gt;.&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 19:09:52 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210625#M174825</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2024-12-13T19:09:52Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting work planes based off their position/offset</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210893#M174831</link>
      <description>&lt;P&gt;Hey&amp;nbsp;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/7812054"&gt;@WCrihfield&lt;/a&gt;&amp;nbsp;, thank you so much for the detailed response.&amp;nbsp; I will mess around with your example code for what I am trying to accomplish.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I can provide more detailed information if that would help clear up my, probably poorly explained, post and maybe help someone else in the future.&amp;nbsp; Let me know.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 21:58:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210893#M174831</guid>
      <dc:creator>Patrick_JohnsonSU3NC</dc:creator>
      <dc:date>2024-12-13T21:58:32Z</dc:date>
    </item>
    <item>
      <title>Re: Deleting work planes based off their position/offset</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210940#M174833</link>
      <description>&lt;P&gt;&lt;SPAN&gt;Hi, maybe this will do the trick&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;   &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;offset&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt; = 5  &lt;SPAN&gt;'50 mm offset&lt;/SPAN&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;ThisApplication&lt;/SPAN&gt;.&lt;SPAN&gt;ActiveDocument&lt;/SPAN&gt;
   &lt;SPAN&gt;Try&lt;/SPAN&gt;
       &lt;SPAN&gt;' Get the component definition of the part&lt;/SPAN&gt;
       &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;compDef&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;PartComponentDefinition&lt;/SPAN&gt; = &lt;SPAN&gt;oPartDoc&lt;/SPAN&gt;.&lt;SPAN&gt;ComponentDefinition&lt;/SPAN&gt;
       &lt;SPAN&gt;' Get the workplanes collection&lt;/SPAN&gt;
       &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;workPlanes&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;WorkPlanes&lt;/SPAN&gt; = &lt;SPAN&gt;compDef&lt;/SPAN&gt;.&lt;SPAN&gt;WorkPlanes&lt;/SPAN&gt;
       &lt;SPAN&gt;' Loop through the workplanes in reverse order (to avoid index shifting during deletion)&lt;/SPAN&gt;
       &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;obc&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;ObjectCollection&lt;/SPAN&gt;
       &lt;SPAN&gt;For&lt;/SPAN&gt; &lt;SPAN&gt;i&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Integer&lt;/SPAN&gt; = &lt;SPAN&gt;workPlanes&lt;/SPAN&gt;.&lt;SPAN&gt;Count&lt;/SPAN&gt; &lt;SPAN&gt;To&lt;/SPAN&gt; 1 &lt;SPAN&gt;Step&lt;/SPAN&gt; -1
           &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;workPlane&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;WorkPlane&lt;/SPAN&gt; = &lt;SPAN&gt;workPlanes&lt;/SPAN&gt;.&lt;SPAN&gt;Item&lt;/SPAN&gt;(&lt;SPAN&gt;i&lt;/SPAN&gt;)
           &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;oPoint&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Point&lt;/SPAN&gt; = &lt;SPAN&gt;workPlane&lt;/SPAN&gt;.&lt;SPAN&gt;Plane&lt;/SPAN&gt;.&lt;SPAN&gt;RootPoint&lt;/SPAN&gt;
           &lt;SPAN&gt;Dim&lt;/SPAN&gt; &lt;SPAN&gt;z&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Double&lt;/SPAN&gt; = &lt;SPAN&gt;oPoint&lt;/SPAN&gt;.&lt;SPAN&gt;Z&lt;/SPAN&gt;
           &lt;SPAN&gt;If&lt;/SPAN&gt; &lt;SPAN&gt;offset&lt;/SPAN&gt; = &lt;SPAN&gt;oPoint&lt;/SPAN&gt;.&lt;SPAN&gt;Z&lt;/SPAN&gt; &lt;SPAN&gt;Then&lt;/SPAN&gt;
               &lt;SPAN&gt;workPlane&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;SPAN&gt;Catch&lt;/SPAN&gt; &lt;SPAN&gt;ex&lt;/SPAN&gt; &lt;SPAN&gt;As&lt;/SPAN&gt; &lt;SPAN&gt;Exception&lt;/SPAN&gt;

   &lt;SPAN&gt;End&lt;/SPAN&gt; &lt;SPAN&gt;Try&lt;/SPAN&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;If a response answers your question, please use&amp;nbsp;&lt;STRONG&gt;&amp;nbsp;ACCEPT SOLUTION&amp;nbsp;&lt;/STRONG&gt;&amp;nbsp;to assist other users later.&lt;/P&gt;&lt;P&gt;Also be generous with Likes!&amp;nbsp; Thank you and enjoy!&lt;/P&gt;</description>
      <pubDate>Fri, 13 Dec 2024 22:51:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/deleting-work-planes-based-off-their-position-offset/m-p/13210940#M174833</guid>
      <dc:creator>nstevelmans</dc:creator>
      <dc:date>2024-12-13T22:51:18Z</dc:date>
    </item>
  </channel>
</rss>

