<?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 Rule to be Ran Before Save in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389879#M107131</link>
    <description>&lt;P&gt;Sorry for the delay.&amp;nbsp; Busy at work.&amp;nbsp; I created some quick code for you to try out.&lt;/P&gt;&lt;P&gt;See below code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;'Assuming the main assembly is open and active when you run this rule
'To change the main assembly's Part number use this line
iProperties.Value("Project", "Part Number") = "Whatever you want to put here"

'To change the Part Number of a ComponentOccurrence within the main assembly
'to its "Name" you would use code similar to the following

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument

'For a single Occurrence...Uncomment the next line (you may need to change which Occurrence)
'Dim oOcc As ComponentOccurrence = oADoc.ComponentDefinition.Occurrences.Item(1)

'Or...to loop through all Occurrences - Uncomment the next 3 lines
'For Each oOcc As ComponentOccurrence In oADoc.ComponentDefinition.Occurrences
'	iProperties.Value(oOcc.Name, "Project", "Part Number") = oOcc.Name
'Next

'Or...another route
For Each oDoc As Document In oADoc.AllReferencedDocuments
	'Open each referenced document, so you can access its iProperties
	ThisApplication.Documents.Open(oDoc.FullFileName, False)
	oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = oDoc.DisplayName
Next&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;BR /&gt;If this solves your problem, or answers your questions, please click 'Accept As Solution".&lt;BR /&gt;Or, if this helps you reach your goal, please click 'LIKES" &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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.&lt;BR /&gt;If you agree with any of them, please vote for them.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Add more capabilities to the 'Customize' dialog box (exe. Add Tab &amp;amp; Add Panel) &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/add-more-capabilities-to-the-customize-dialog-box-exe-add-tab/idi-p/9371747/" target="_blank" rel="noopener"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;MessageBox, InputBox, and InputListBox Size &amp;amp; Format Options &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/text-format-amp-size-options-messagebox-inputbox-inputlistbox/idi-p/9169817/" target="_blank" rel="noopener"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Constrain &amp;amp; Dimension Images In Assembly Sketches &amp;amp; Drawing Sketches (TitleBlocks &amp;amp; SketchedSymbols) &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/we-need-the-ability-to-fully-constrain-amp-dimension-images/idi-p/9299088/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/save-section-view-status-in-designviewrepresentation-so-is/idi-p/9270962/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Add SolidBodies Folder In iLogic Rule Editor Model Tab &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/ilogic-rule-editor-gt-model-tab-add-a-solid-bodies-folder-for/idi-p/9270898/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/drawings-in-oldversions-set-all-views-to-raster-before-autosave/idi-p/9185521/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;SetDesignViewRepresentation - Fix limitations for DrawingView of a Part &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/setdesignviewrepresentation-fix-limitations-for-drawingview-of-a/idi-p/9369920/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;A href="http://help.autodesk.com/view/INVNTOR/2020/ENU/" target="_blank"&gt;Inventor 2020 Help &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-forum/bd-p/78/" target="_blank"&gt;Inventor Forum &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-customization/bd-p/120/" target="_blank"&gt;Inventor Customization Forum &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232/" target="_blank"&gt;Inventor Ideas Forum &lt;/A&gt;&lt;/P&gt;</description>
    <pubDate>Fri, 20 Mar 2020 15:52:38 GMT</pubDate>
    <dc:creator>WCrihfield</dc:creator>
    <dc:date>2020-03-20T15:52:38Z</dc:date>
    <item>
      <title>iLogic Rule to be Ran Before Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389285#M107122</link>
      <description>&lt;P&gt;Hello Everyone,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have skimmed through several posts about running iLogic rules for BOM structures and its naming convention, and I have managed to find a rule that I believe would work to change the part number to its display name in the model browser.&lt;/P&gt;&lt;P&gt;However, as I have a model already created, I'm struggling to pick apart other code that allows the rule to run for an assembly and its referenced files?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is the code:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;iProperties.Value("Project", "Part Number") = iProperties.Value("Occurrence", "Name")&lt;/LI-CODE&gt;&lt;P&gt;Could I please have some help to run this for my current assembly?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 11:30:28 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389285#M107122</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-20T11:30:28Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Rule to be Ran Before Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389408#M107124</link>
      <description>&lt;P&gt;Can you be more specific / informational about what you are trying to do?&lt;/P&gt;&lt;P&gt;Do you have a main assembly open, and trying to change a ComponentOccurrence's "Part Number" property to that same Occurrence's (Occurrence.Name)?&lt;/P&gt;&lt;P&gt;Are you trying to change your main assembly "Part Number" property to one of the assembly's ComponentOccurrence names?&lt;/P&gt;&lt;P&gt;Are you trying to change a BOMRow Item Number, within a main assembly, to a ComponentOccurrence name instead of an Integer?&lt;/P&gt;&lt;P&gt;Have you already created a custom PropertySet named "Occurrence", within the main assembly, and added a property named "Name" to it, that you're wanting to use?&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 12:33:13 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389408#M107124</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-03-20T12:33:13Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Rule to be Ran Before Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389560#M107128</link>
      <description>&lt;P&gt;Yes sorry,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to make the part number the same as that shown in the occurrence name in the iProperties options.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have an assembly all made, where I've used the frame generator tool, but the part number shows the 'standard-section-length'. Therefore I need to run the iLogic command in the assembly when using the generator, instead of manually changing the save file name or the part number.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have not made a custom property as I thought that the occurrence section in the iProperties would already be built into 'code' ready to use.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also would change the assemblies part number to a bespoke format instead of its saved file name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 13:33:18 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389560#M107128</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-20T13:33:18Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Rule to be Ran Before Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389879#M107131</link>
      <description>&lt;P&gt;Sorry for the delay.&amp;nbsp; Busy at work.&amp;nbsp; I created some quick code for you to try out.&lt;/P&gt;&lt;P&gt;See below code.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;'Assuming the main assembly is open and active when you run this rule
'To change the main assembly's Part number use this line
iProperties.Value("Project", "Part Number") = "Whatever you want to put here"

'To change the Part Number of a ComponentOccurrence within the main assembly
'to its "Name" you would use code similar to the following

Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument

'For a single Occurrence...Uncomment the next line (you may need to change which Occurrence)
'Dim oOcc As ComponentOccurrence = oADoc.ComponentDefinition.Occurrences.Item(1)

'Or...to loop through all Occurrences - Uncomment the next 3 lines
'For Each oOcc As ComponentOccurrence In oADoc.ComponentDefinition.Occurrences
'	iProperties.Value(oOcc.Name, "Project", "Part Number") = oOcc.Name
'Next

'Or...another route
For Each oDoc As Document In oADoc.AllReferencedDocuments
	'Open each referenced document, so you can access its iProperties
	ThisApplication.Documents.Open(oDoc.FullFileName, False)
	oDoc.PropertySets.Item("Design Tracking Properties").Item("Part Number").Value = oDoc.DisplayName
Next&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope this helps.&lt;BR /&gt;If this solves your problem, or answers your questions, please click 'Accept As Solution".&lt;BR /&gt;Or, if this helps you reach your goal, please click 'LIKES" &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;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also, if you're interested, here are a few of the 'Ideas' I'd like to get implemented.&lt;BR /&gt;If you agree with any of them, please vote for them.&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Add more capabilities to the 'Customize' dialog box (exe. Add Tab &amp;amp; Add Panel) &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/add-more-capabilities-to-the-customize-dialog-box-exe-add-tab/idi-p/9371747/" target="_blank" rel="noopener"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;MessageBox, InputBox, and InputListBox Size &amp;amp; Format Options &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/text-format-amp-size-options-messagebox-inputbox-inputlistbox/idi-p/9169817/" target="_blank" rel="noopener"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Constrain &amp;amp; Dimension Images In Assembly Sketches &amp;amp; Drawing Sketches (TitleBlocks &amp;amp; SketchedSymbols) &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/we-need-the-ability-to-fully-constrain-amp-dimension-images/idi-p/9299088/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Save Section View Status In DesignViewRepresentation (So It Can Be Used In The Drawing) &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/save-section-view-status-in-designviewrepresentation-so-is/idi-p/9270962/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Add SolidBodies Folder In iLogic Rule Editor Model Tab &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/ilogic-rule-editor-gt-model-tab-add-a-solid-bodies-folder-for/idi-p/9270898/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;Convert All Views To Raster Before Autosave Stores To 'OldVersions' Folder &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/drawings-in-oldversions-set-all-views-to-raster-before-autosave/idi-p/9185521/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;LI&gt;SetDesignViewRepresentation - Fix limitations for DrawingView of a Part &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/setdesignviewrepresentation-fix-limitations-for-drawingview-of-a/idi-p/9369920/" target=" Blank"&gt;Click Here &lt;/A&gt;&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&lt;A href="http://help.autodesk.com/view/INVNTOR/2020/ENU/" target="_blank"&gt;Inventor 2020 Help &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-forum/bd-p/78/" target="_blank"&gt;Inventor Forum &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-customization/bd-p/120/" target="_blank"&gt;Inventor Customization Forum &lt;/A&gt;| &lt;A href="https://forums.autodesk.com/t5/inventor-ideas/idb-p/v1232/" target="_blank"&gt;Inventor Ideas Forum &lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 15:52:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9389879#M107131</guid>
      <dc:creator>WCrihfield</dc:creator>
      <dc:date>2020-03-20T15:52:38Z</dc:date>
    </item>
    <item>
      <title>Re: iLogic Rule to be Ran Before Save</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9412247#M107504</link>
      <description>&lt;P&gt;Hi there, incredibly sorry for replying sooner. The current situation has caused some margin of chaos at the office.&lt;/P&gt;&lt;P&gt;I haven't been able to try the code as of yet due to a shift in priority at work.&lt;/P&gt;&lt;P&gt;Once I'm back on the project I'll give it a bash.&lt;/P&gt;</description>
      <pubDate>Tue, 31 Mar 2020 14:04:53 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/ilogic-rule-to-be-ran-before-save/m-p/9412247#M107504</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-31T14:04:53Z</dc:date>
    </item>
  </channel>
</rss>

