<?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: Run iLogic from Assembly to affect all parts in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-ilogic-from-assembly-to-affect-all-parts/m-p/5648632#M56054</link>
    <description>&lt;P&gt;&lt;SPAN style="line-height: 15px;"&gt;Red text in your code returns the reference of the top assembly document (that owns the rule), while you need in the part document. &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="line-height: 15px;"&gt;As the top assembly does not have those parameters &amp;nbsp;nothing happens.&lt;/SPAN&gt;&lt;SPAN style="line-height: 15px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dim openDoc As Document = ThisDoc.Document&lt;/P&gt;
&lt;P&gt;If openDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&lt;/P&gt;
&lt;P&gt;For Each docFile As Document In openDoc.AllReferencedDocuments&lt;BR /&gt; &lt;BR /&gt; If docFile.DocumentType = DocumentTypeEnum.kPartDocumentObject Then &lt;BR /&gt; &lt;BR /&gt; Dim oParams As Parameters = &lt;FONT color="#FF0000"&gt;ThisDoc.Document.&lt;/FONT&gt;ComponentDefinition.Parameters &amp;nbsp; &amp;nbsp;&amp;lt;---&amp;nbsp;mistake&lt;BR /&gt; Dim oUserParams As UserParameters = oParams.UserParameters&lt;BR /&gt; &lt;BR /&gt; 'Look for Frame Gen Parameter and format it&lt;BR /&gt; Try&lt;BR /&gt; Dim oParam As Inventor.Parameter&lt;BR /&gt; 'Enter the name of Paramter here&lt;BR /&gt;..........................&lt;BR /&gt;&lt;SPAN&gt;..........................&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;..........................&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;So please try &amp;nbsp;this line in the following form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim oParams As Inventor.Parameters = docFile.ComponentDefinition.Parameters&lt;/PRE&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 22 May 2015 15:08:40 GMT</pubDate>
    <dc:creator>Vladimir.Ananyev</dc:creator>
    <dc:date>2015-05-22T15:08:40Z</dc:date>
    <item>
      <title>Run iLogic from Assembly to affect all parts</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-ilogic-from-assembly-to-affect-all-parts/m-p/5636755#M55917</link>
      <description>&lt;P&gt;I'm trying to quickly format parameters in parts with an external iLogic script from the assembly level.&lt;/P&gt;&lt;P&gt;I can run this script at the part level&lt;/P&gt;&lt;PRE&gt;Imports Inventor.UnitsTypeEnum

Dim oParams As Parameters
oParams=ThisDoc.Document.ComponentDefinition.Parameters

Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters

'Look for Frame Gen Parameter and format it
Try
Dim oParam As Parameter
'Enter the name of Paramter here
Dim MyParam As String = "G_L"
oParam = oUserParams(MyParam)
oParam.ExposedAsProperty = True
'format Custom Parameter
Dim oFormat As CustomPropertyFormat
oFormat = oUserParams(MyParam).CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Units="ft"
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
oFormat.ShowUnitsString = False
oFormat.ShowLeadingZeros = False
oFormat.ShowTrailingZeros = False

Catch
End Try&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But when i add it to other scripts i've found to run from the Assembly level nothing happens....&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Imports Inventor.UnitsTypeEnum

Dim openDoc As Document
openDoc = ThisDoc.Document
Dim docFile As Document
If openDoc.DocumentType = 12291 Then
For Each docFile In openDoc.AllReferencedDocuments

If docFile.DocumentType = 12290 Then

 

Dim oParams As Parameters
oParams=ThisDoc.Document.ComponentDefinition.Parameters

Dim oUserParams As UserParameters
oUserParams=oParams.UserParameters

'Look for Frame Gen Parameter and format it
Try
Dim oParam As Parameter
'Enter the name of Paramter here
Dim MyParam As String = "G_L"
oParam = oUserParams(MyParam)
oParam.ExposedAsProperty = True
'format Custom Parameter
Dim oFormat As CustomPropertyFormat
oFormat = oUserParams(MyParam).CustomPropertyFormat
oFormat.PropertyType=Inventor.CustomPropertyTypeEnum.kTextPropertyType
oFormat.Units="ft"
oFormat.Precision=Inventor.CustomPropertyPrecisionEnum.kSixteenthsFractionalLengthPrecision
oFormat.ShowUnitsString = False
oFormat.ShowLeadingZeros = False
oFormat.ShowTrailingZeros = False

Catch
End Try

End If
Next
Else
MessageBox.Show("You must have a valid Assembly document open before using this code!", "File Type Mismatch!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)
End If &lt;/PRE&gt;&lt;P&gt;Any ideas?&lt;/P&gt;&lt;P&gt;thanks!!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 15 May 2015 13:58:08 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-ilogic-from-assembly-to-affect-all-parts/m-p/5636755#M55917</guid>
      <dc:creator>beardrafting</dc:creator>
      <dc:date>2015-05-15T13:58:08Z</dc:date>
    </item>
    <item>
      <title>Re: Run iLogic from Assembly to affect all parts</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-ilogic-from-assembly-to-affect-all-parts/m-p/5648632#M56054</link>
      <description>&lt;P&gt;&lt;SPAN style="line-height: 15px;"&gt;Red text in your code returns the reference of the top assembly document (that owns the rule), while you need in the part document. &amp;nbsp;&lt;/SPAN&gt;&lt;SPAN style="line-height: 15px;"&gt;As the top assembly does not have those parameters &amp;nbsp;nothing happens.&lt;/SPAN&gt;&lt;SPAN style="line-height: 15px;"&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Dim openDoc As Document = ThisDoc.Document&lt;/P&gt;
&lt;P&gt;If openDoc.DocumentType = DocumentTypeEnum.kAssemblyDocumentObject Then&lt;/P&gt;
&lt;P&gt;For Each docFile As Document In openDoc.AllReferencedDocuments&lt;BR /&gt; &lt;BR /&gt; If docFile.DocumentType = DocumentTypeEnum.kPartDocumentObject Then &lt;BR /&gt; &lt;BR /&gt; Dim oParams As Parameters = &lt;FONT color="#FF0000"&gt;ThisDoc.Document.&lt;/FONT&gt;ComponentDefinition.Parameters &amp;nbsp; &amp;nbsp;&amp;lt;---&amp;nbsp;mistake&lt;BR /&gt; Dim oUserParams As UserParameters = oParams.UserParameters&lt;BR /&gt; &lt;BR /&gt; 'Look for Frame Gen Parameter and format it&lt;BR /&gt; Try&lt;BR /&gt; Dim oParam As Inventor.Parameter&lt;BR /&gt; 'Enter the name of Paramter here&lt;BR /&gt;..........................&lt;BR /&gt;&lt;SPAN&gt;..........................&lt;BR /&gt;&lt;/SPAN&gt;&lt;SPAN&gt;..........................&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;So please try &amp;nbsp;this line in the following form:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;PRE&gt;Dim oParams As Inventor.Parameters = docFile.ComponentDefinition.Parameters&lt;/PRE&gt;
&lt;P&gt;Hope this helps.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 22 May 2015 15:08:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-ilogic-from-assembly-to-affect-all-parts/m-p/5648632#M56054</guid>
      <dc:creator>Vladimir.Ananyev</dc:creator>
      <dc:date>2015-05-22T15:08:40Z</dc:date>
    </item>
    <item>
      <title>Re: Run iLogic from Assembly to affect all parts</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-ilogic-from-assembly-to-affect-all-parts/m-p/5664651#M56441</link>
      <description>&lt;P&gt;perfect thanks!!!!&lt;/P&gt;</description>
      <pubDate>Thu, 04 Jun 2015 15:06:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/run-ilogic-from-assembly-to-affect-all-parts/m-p/5664651#M56441</guid>
      <dc:creator>beardrafting</dc:creator>
      <dc:date>2015-06-04T15:06:25Z</dc:date>
    </item>
  </channel>
</rss>

