<?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: Toggle between parameters in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10561314#M127955</link>
    <description>&lt;P&gt;I'm not 100% sure I understand what you are wanting.&amp;nbsp; Are you planning on using a Form to allow the user to specify parameter values?&amp;nbsp; After looking at your model sketch and parameters, I'm guessing you want to change which 2 (out of 3) dimensions have 'driving' control, and which 1 will be 'driven'?&amp;nbsp; If this is the case, you will need to access the sketch, enter into 'edit mode', find &amp;amp; identify those 3 dimensional constraints, then toggle their properties between 'driving' and 'driven' as needed, all though an iLogic rule.&amp;nbsp; This is possible, but might be challenging/complicated to achieve.&amp;nbsp; And if anything happens to those sketch dimensions (like deleted), it will leave your rule useless.&amp;nbsp; Does that sound like the process you were looking for?&lt;/P&gt;</description>
    <pubDate>Fri, 20 Aug 2021 16:46:49 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2021-08-20T16:46:49Z</dc:date>
    <item>
      <title>Toggle between parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10560206#M127928</link>
      <description>&lt;P&gt;Hi forum, I have one part full constraint, I would like to keep the internal and externa Ø as a default parameter and then create another parameter wall thickness so can have the option to toggle between the internal Ø and wall the thickness.&lt;BR /&gt;Thanks&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 08:20:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10560206#M127928</guid>
      <dc:creator>SpokenEarth</dc:creator>
      <dc:date>2021-08-20T08:20:53Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle between parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10561314#M127955</link>
      <description>&lt;P&gt;I'm not 100% sure I understand what you are wanting.&amp;nbsp; Are you planning on using a Form to allow the user to specify parameter values?&amp;nbsp; After looking at your model sketch and parameters, I'm guessing you want to change which 2 (out of 3) dimensions have 'driving' control, and which 1 will be 'driven'?&amp;nbsp; If this is the case, you will need to access the sketch, enter into 'edit mode', find &amp;amp; identify those 3 dimensional constraints, then toggle their properties between 'driving' and 'driven' as needed, all though an iLogic rule.&amp;nbsp; This is possible, but might be challenging/complicated to achieve.&amp;nbsp; And if anything happens to those sketch dimensions (like deleted), it will leave your rule useless.&amp;nbsp; Does that sound like the process you were looking for?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 16:46:49 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10561314#M127955</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-08-20T16:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle between parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10561536#M127960</link>
      <description>&lt;P&gt;For some reason, it's not letting me toggle the Driven property of those dimension constraints between True &amp;amp; False.&amp;nbsp; It seems like it will let me toggle one, but not the other.&amp;nbsp; I know you have to do it in the right order, or it will throw an error, because you can't have two driving dimension trying to control the same fully constrained sketch entity, so I'm being careful with that, but still getting an error.&amp;nbsp; I am also aware that when you toggle a sketch dimension between 'driving' and 'driven' it also switches the parameter that the dimension represents between being a regular model parameter and being a reference parameter.&amp;nbsp; Maybe this has something to do with it.&amp;nbsp; For some reason it is thinking that a dimension (the ID dimension) is 'Driven', when it's not, and is trying to set it to 'driving', which I believe is where the error is happening.&amp;nbsp; I'm not sure how to deal with that situation, since it seems to be a 'Bug'.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Anyways, here is the iLogic rule I created for your provided part document.&amp;nbsp; I believe it is finding the dimensions OK, just not toggling their 'Driven' property correctly.&amp;nbsp; I had a ton of Msgbox's in there before trying to track down where the error is happening, and why, but have removed most of them, leaving the Try...Catch blocks in there for now.&amp;nbsp; I know where the error is happening (mentioned above), just not sure how to fix it.&lt;/P&gt;
&lt;LI-CODE lang="general"&gt;Dim oPDoc As PartDocument = ThisDoc.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oSketch As PlanarSketch
Try
	oSketch = oPDef.Sketches.Item("SK BS 4825-3")
Catch
	MsgBox("Couldn't find that sketch.  Exiting Rule.", , "")
	Exit Sub
End Try
oPDoc.Update2(True)
oSketch.Edit
'identify the 3 dimensions
Dim oID, oOD, oThickness As DimensionConstraint
For Each oDC As DimensionConstraint In oSketch.DimensionConstraints
	If oDC.Parameter.Name = "BS4825:1" Then
		oID = oDC
		MsgBox("oID was found.  It's value is " &amp;amp; oID.Parameter.Value.ToString,,"")
	ElseIf oDC.Parameter.Name = "BS4825:2" Then
		oOD = oDC 'we're leaving this one alone for now
		MsgBox("oOD was found.  It's value is " &amp;amp; oOD.Parameter.Value.ToString,,"")
	ElseIf oDC.Parameter.Name = "d109" Then
		oThickness = oDC
		MsgBox("oThickness was found.  It's value is " &amp;amp; oThickness.Parameter.Value.ToString,,"")
	End If
Next
'make sure we've got them
If IsNothing(oID) Or IsNothing(oOD) Or IsNothing(oThickness) Then Exit Sub
	
'now try to toggle them
'toggling needs to happen in correct order, or it will throw an error
If oID.Driven = True And oThickness.Driven = False Then
	MsgBox("oID.Diven = True And oThickness.Driven = False")
	Try
		oID.Driven = False
		MsgBox("Just toggled oID.Diven to False")
	Catch oEx As Exception
		MsgBox("oID.Driven was True.  Failed to toggle it to False." &amp;amp; vbCrLf &amp;amp; _
		oEx.Message &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; _
		oEx.StackTrace &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; _
		oEx.Source,,"")
	End Try
	oPDoc.Update2(True)
	Try
		oThickness.Driven = True
		MsgBox("Just toggled oThickness.Diven to True")
	Catch oEx As Exception
		MsgBox("oThickness.Driven was False.  Failed to toggle it to True." &amp;amp; vbCrLf &amp;amp; _
		oEx.Message &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; _
		oEx.StackTrace &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; _
		oEx.Source,,"")
	End Try
ElseIf oID.Driven = False And oThickness.Driven = True Then
	MsgBox("oID.Driven = False And oThickness.Driven = True")
	Try
		oThickness.Driven = False
		MsgBox("Just toggled oThickness.Diven to False")
	Catch oEx As Exception
		MsgBox("oThickness.Driven was True.  Failed to toggle it to False." &amp;amp; vbCrLf &amp;amp; _
		oEx.Message &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; _
		oEx.StackTrace &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; _
		oEx.Source,,"")
	End Try
	oPDoc.Update2(True)
	Try
		oID.Driven = True
		MsgBox("Just toggled oID.Diven to True")
	Catch oEx As Exception
		MsgBox("oID.Driven was False.  Failed to toggle it to True." &amp;amp; vbCrLf &amp;amp; _
		oEx.Message &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; _
		oEx.StackTrace &amp;amp; vbCrLf &amp;amp; vbCrLf &amp;amp; _
		oEx.Source,,"")
	End Try
End If
oSketch.ExitEdit
oPDoc.Update2(True)&lt;/LI-CODE&gt;
&lt;P&gt;If this solved your problem, or answered your question, please click &lt;SPAN style="background-color: green; color: white;"&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;SPAN&gt;&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;/SPAN&gt;.&lt;/P&gt;
&lt;P&gt;If you want and have time, I would appreciate your Vote(s) for &lt;A href="https://forums.autodesk.com/t5/forums/recentpostspage/post-type/message/interaction-style/idea/user-id/7812054/" target="_blank"&gt;My IDEAS &lt;SPAN&gt;&lt;img class="lia-deferred-image lia-image-emoji" src="https://forums.autodesk.com/html/@B166FEBB95D67CFA84899D32D8E17FC1/emoticons/1f4a1.png" alt=":light_bulb:" title=":light_bulb:" /&gt;&lt;/SPAN&gt;&lt;/A&gt;or you can Explore &lt;A href="https://knowledge.autodesk.com/profile/LTSUSR7HXMSAE/articles" target="_blank"&gt;My CONTRIBUTIONS &lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Aug 2021 18:15:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10561536#M127960</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2021-08-20T18:15:44Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle between parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10562635#M127966</link>
      <description>&lt;P&gt;Thank you for the time you took to review my posts and your effort to find a solution.&lt;BR /&gt;My thought was to have a foul constraint sketch, double dimensioning the parameter ID and make additional parameter (Wall_Thickness) with the intention to choose controlling the actual wall thickness from the parameter ID or Wall_Thickness.&lt;BR /&gt;I was thinking if this would possible to achieve this without making true false statement,&amp;nbsp;&lt;SPAN&gt;I'm&amp;nbsp;not&amp;nbsp;&lt;/SPAN&gt;quite sure if it will be&amp;nbsp;doable by creating a List(Of String) and add ranges, I haven't&amp;nbsp; tried&amp;nbsp; yet but I don't think this would work either.&lt;/P&gt;&lt;P&gt;Best Regards.&lt;/P&gt;&lt;P&gt;Achilles&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 21 Aug 2021 07:51:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10562635#M127966</guid>
      <dc:creator>SpokenEarth</dc:creator>
      <dc:date>2021-08-21T07:51:32Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle between parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10563019#M127967</link>
      <description>&lt;P&gt;I think the best way to do this is by adding 2 dummy parameters. (InnerDiameter and WallThickness) A dummy parameter for InnerDiameter is maybe not what you expect. But you need it to see if the&amp;nbsp;InnerDiameter or the&amp;nbsp;WallThickness has been changed. As an example, I used a tube. In the screencast below you will see all parameters that i used.&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="ChangeBoth.gif" style="width: 782px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/955599i30D25C9419AA2C31/image-size/large?v=v2&amp;amp;px=999" role="button" title="ChangeBoth.gif" alt="ChangeBoth.gif" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;And this is the iLogic code to make it work:&lt;/P&gt;&lt;PRE&gt;&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;wt&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Double&lt;/SPAN&gt; = &lt;SPAN style="color: #0000ff;"&gt;WallThickness&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;id&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Double&lt;/SPAN&gt; = &lt;SPAN style="color: #0000ff;"&gt;InnerDiameter&lt;/SPAN&gt;
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;idr&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Double&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"InnerDiameterReal"&lt;/SPAN&gt;)
&lt;SPAN style="color: #ff0000;"&gt;Dim&lt;/SPAN&gt; &lt;SPAN style="color: #800000;"&gt;odr&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;As&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;Double&lt;/SPAN&gt; = &lt;SPAN style="color: #800080;"&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"OuterDiameterReal"&lt;/SPAN&gt;)

&lt;SPAN style="color: #ff0000;"&gt;If&lt;/SPAN&gt; (&lt;SPAN style="color: #800080;"&gt;DoubleUtil&lt;/SPAN&gt;.&lt;SPAN style="color: #800080;"&gt;DoublesAreEqual&lt;/SPAN&gt;(&lt;SPAN style="color: #800000;"&gt;id&lt;/SPAN&gt;, &lt;SPAN style="color: #800000;"&gt;idr&lt;/SPAN&gt;)) &lt;SPAN style="color: #ff0000;"&gt;Then&lt;/SPAN&gt;
	&lt;SPAN style="color: #808080;"&gt;' wall thickness has been changed&lt;/SPAN&gt;
	&lt;SPAN style="color: #800080;"&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"InnerDiameterReal"&lt;/SPAN&gt;) = &lt;SPAN style="color: #800000;"&gt;odr&lt;/SPAN&gt; - 2 * &lt;SPAN style="color: #800000;"&gt;wt&lt;/SPAN&gt;
	&lt;SPAN style="color: #800080;"&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"InnerDiameter"&lt;/SPAN&gt;) = &lt;SPAN style="color: #800000;"&gt;odr&lt;/SPAN&gt; - 2*&lt;SPAN style="color: #800000;"&gt;wt&lt;/SPAN&gt;
	&lt;SPAN style="color: #800080;"&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"WallThickness"&lt;/SPAN&gt;) = &lt;SPAN style="color: #800000;"&gt;wt&lt;/SPAN&gt;	
&lt;SPAN style="color: #ff0000;"&gt;Else&lt;/SPAN&gt;
	&lt;SPAN style="color: #808080;"&gt;' inner diameter has been changed&lt;/SPAN&gt;
	&lt;SPAN style="color: #800080;"&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"WallThickness"&lt;/SPAN&gt;) = (&lt;SPAN style="color: #800000;"&gt;odr&lt;/SPAN&gt; - &lt;SPAN style="color: #800000;"&gt;id&lt;/SPAN&gt;)/2
	&lt;SPAN style="color: #800080;"&gt;Parameter&lt;/SPAN&gt;(&lt;SPAN style="color: #008080;"&gt;"InnerDiameterReal"&lt;/SPAN&gt;) = &lt;SPAN style="color: #800000;"&gt;id&lt;/SPAN&gt;
	
&lt;SPAN style="color: #ff0000;"&gt;End&lt;/SPAN&gt; &lt;SPAN style="color: #ff0000;"&gt;If&lt;/SPAN&gt;&lt;/PRE&gt;</description>
      <pubDate>Sat, 21 Aug 2021 13:20:06 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10563019#M127967</guid>
      <dc:creator>JelteDeJong</dc:creator>
      <dc:date>2021-08-21T13:20:06Z</dc:date>
    </item>
    <item>
      <title>Re: Toggle between parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10564441#M127975</link>
      <description>&lt;P&gt;Thank you, that will work&lt;/P&gt;</description>
      <pubDate>Sun, 22 Aug 2021 12:01:37 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/toggle-between-parameters/m-p/10564441#M127975</guid>
      <dc:creator>SpokenEarth</dc:creator>
      <dc:date>2021-08-22T12:01:37Z</dc:date>
    </item>
  </channel>
</rss>

