<?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: iLogic Try Catch w/ Parameters in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778121#M116026</link>
    <description>Yeah; it works because you are specifying the document rather than hoping that the snippet is accessing the document you intended; it starts causing errors if you run rules that modify iProperties of invisible documents... Which is what specifying the document clears up.</description>
    <pubDate>Wed, 19 Aug 2015 17:23:19 GMT</pubDate>
    <dc:creator>MechMachineMan</dc:creator>
    <dc:date>2015-08-19T17:23:19Z</dc:date>
    <item>
      <title>iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5777974#M116022</link>
      <description>&lt;P&gt;I'm using the rule below at the assembly level to go through all parts in the assembly and change the schedule to whatever is set at the assembly level. I used a Try/Catch statement since not all parts will have the "Sch" parameter - only piping and fittings will have that parameter. Maybe I am not using this statement correctly though? I have message boxes for debugging purposes on both the Try and Catch. When I run the rule, I get the Catch message box for all parts as if it couldn't find that Parameter, but then the parts update&amp;nbsp;as expected&amp;nbsp;anyway! Note, the "Sch" parameter at both the assembly and part levels are multivalue text. Could that have something to do with it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See code below and I've also attached a sample part, so feel free to try it out for yourself. As always, any help is much appreciated!&lt;/P&gt;&lt;PRE&gt;' Set a reference to the assembly component definintion
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Iterate through all occurrences
Dim oOcc As ComponentOccurrence
For Each oOcc In oAsmCompDef.Occurrences
	Try
		Parameter(oOcc.Name,"Sch") = PipeSch
		Parameter(oOcc.Name,"PipeSch") = PipeSch
		' For debugging:
		 MessageBox.Show(oOcc.Name &amp;amp; " was updated." &amp;amp; vbLf &amp;amp;
		 "Schedule set to: " &amp;amp; iProperties.Value(oOcc.Name,"Project","Description"), "Debug Message - Pipe_Sch")
		
	Catch
		MsgBox(oOcc.Name &amp;amp; vbLf &amp;amp; "Parameter 'Sch' not found. Proceeding to next part...")
	
	End Try
Next&lt;/PRE&gt;</description>
      <pubDate>Wed, 19 Aug 2015 16:15:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5777974#M116022</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-19T16:15:28Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5777990#M116023</link>
      <description>&lt;P&gt;See if switching they syntax of your params helps;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;oOcc.Definition.Parameters.Item("Sch").Value()&lt;/P&gt;&lt;P&gt;Or&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;oOcc.Definition.Parameters.Item("Sch").Expression&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Also,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;The less sloppy way of accessing iProperties would be:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;oOcc.Definition.Document.PropertySets.Item("Design Tracking Properties").Item("Description").Value&lt;/SPAN&gt;&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;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2015 16:22:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5777990#M116023</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2015-08-19T16:22:14Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778089#M116024</link>
      <description>&lt;P&gt;Thanks for the tips, Mech. I tried both of your&amp;nbsp;parameter access methods. The .Expression modifier doesn't seem to work - I don't get any error messages, but the models don't update.&amp;nbsp;The .Value() modifier does the exact same thing as was happening before where I get the Catch debug message, but then everything still updates as expected anyway.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hmm.. This seemed like a fairly straight-forward bit of code. I guess it's never as simple as you first think it is!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;P.S. that makes sense about the iProperties - To access the document &lt;EM&gt;before &lt;/EM&gt;telling it to look for a parameter. I'm guessing that's the idea anyway.&amp;nbsp;Although it is a little more lengthy.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2015 17:00:32 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778089#M116024</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-19T17:00:32Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778116#M116025</link>
      <description>&lt;P&gt;Hey there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Looking at your sample part, you're missing the PipeSch parameter.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Your code ran fine in my testing.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2015 17:20:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778116#M116025</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-19T17:20:20Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778121#M116026</link>
      <description>Yeah; it works because you are specifying the document rather than hoping that the snippet is accessing the document you intended; it starts causing errors if you run rules that modify iProperties of invisible documents... Which is what specifying the document clears up.</description>
      <pubDate>Wed, 19 Aug 2015 17:23:19 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778121#M116026</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2015-08-19T17:23:19Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778126#M116027</link>
      <description>&lt;P&gt;Yes, you are correct, rsmabery. The elbow doesn't contain the parameter "PipeSch", but for my flange parts, I used "PipeSch" rather than "Sch". So I just wrote my code to look for both those parameter names. I&amp;nbsp;may go back and update my flanges later though so all are sharing the same parameter names.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So&amp;nbsp;the code is&amp;nbsp;working fine for you? That is weird. I wonder why mine is acting funny. Maybe I just need to restart the app? I'll give that a try.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2015 17:26:46 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778126#M116027</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-19T17:26:46Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778138#M116028</link>
      <description>&lt;P&gt;Try separating the two parameter lines into two separate Try/Catch Blocks. &amp;nbsp;I didn't realize you didn't have the same parameter in all parts.&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2015 17:29:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778138#M116028</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-19T17:29:11Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778139#M116029</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;HR /&gt;&lt;P&gt;APatterson_1 wrote:&lt;/P&gt;&lt;P&gt;I'm using the rule below at the assembly level to go through all parts in the assembly and change the schedule to whatever is set at the assembly level. I used a Try/Catch statement since not all parts will have the "Sch" parameter - only piping and fittings will have that parameter. Maybe I am not using this statement correctly though? I have message boxes for debugging purposes on both the Try and Catch. When I run the rule, I get the Catch message box for all parts as if it couldn't find that Parameter, but then the parts update&amp;nbsp;as expected&amp;nbsp;anyway! Note, the "Sch" parameter at both the assembly and part levels are multivalue text. Could that have something to do with it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;See code below and I've also attached a sample part, so feel free to try it out for yourself. As always, any help is much appreciated!&lt;/P&gt;&lt;PRE&gt;' Set a reference to the assembly component definintion
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition

' Iterate through all occurrences
Dim oOcc As ComponentOccurrence
For Each oOcc In oAsmCompDef.Occurrences
	Try
		Parameter(oOcc.Name,"Sch") = PipeSch
		Parameter(oOcc.Name,"PipeSch") = PipeSch
		' For debugging:
		 &lt;STRONG&gt;MessageBox.Show&lt;/STRONG&gt;(oOcc.Name &amp;amp; " was updated." &amp;amp; vbLf &amp;amp;
		 "Schedule set to: " &amp;amp; iProperties.Value(oOcc.Name,"Project","Description"), "Debug Message - Pipe_Sch")
		
	Catch
		&lt;STRONG&gt;MsgBox&lt;/STRONG&gt;(oOcc.Name &amp;amp; vbLf &amp;amp; "Parameter 'Sch' not found. Proceeding to next part...")
	
	End Try
Next&lt;/PRE&gt;&lt;BLOCKQUOTE&gt;Also, looking through your code again, I think the issue is that when you use a try loop, it still PERFORMS all of the actions up until the point where it throws the error in the loop.&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;ie; if it has sch but no pipesch it will still change the sch parameter.&lt;/BLOCKQUOTE&gt;&lt;BLOCKQUOTE&gt;I would try a simpler check before you run the changing; ie;&lt;/BLOCKQUOTE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;oCheck = oParam.Item("Sch").Name &amp;nbsp;'will throw an error if it does not exist. (This is referring to the syntax i talked about in my other post)&lt;/P&gt;&lt;BLOCKQUOTE&gt;Also, double check your message box syntax as it seems your are using 2 different versions... not sure if that will actually cause any issues, but it doesn't hurt to keep it consistent.&lt;/BLOCKQUOTE&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, 19 Aug 2015 17:29:14 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778139#M116029</guid>
      <dc:creator>MechMachineMan</dc:creator>
      <dc:date>2015-08-19T17:29:14Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778153#M116030</link>
      <description>&lt;P&gt;Aaaahhhh.... I just had a face-palm moment. That makes perfect sense now that if even though the "Sch" parameter is there, it will still give me&amp;nbsp;the Catch error handling&amp;nbsp;if the "PipeSch" is not there. Yep, now it works fine! The importance of consistancy is becoming all to real lol. I will definitely go back and update my other parts' parameter names.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what happens when I take vacation days and immediately jump into coding when I return....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the help, guys!&lt;/P&gt;</description>
      <pubDate>Wed, 19 Aug 2015 17:38:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/5778153#M116030</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2015-08-19T17:38:13Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Try Catch w/ Parameters</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/11614378#M116031</link>
      <description>&lt;P&gt;-&lt;/P&gt;</description>
      <pubDate>Mon, 12 Dec 2022 14:31:44 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/ilogic-try-catch-w-parameters/m-p/11614378#M116031</guid>
      <dc:creator>Daan_M</dc:creator>
      <dc:date>2022-12-12T14:31:44Z</dc:date>
    </item>
  </channel>
</rss>

