<?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 Copy Derived Custom iProperties in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/copy-derived-custom-iproperties/m-p/10735927#M130916</link>
    <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to adapt the code from a previous &lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/copy-derived-custom-iproperties-pt-2-check-for-existing/td-p/6970390" target="_blank" rel="noopener"&gt;Post&lt;/A&gt; (works like a charm on an Part File)&amp;nbsp; so that i can run it on an assembly file.&amp;nbsp; Braking it down:&lt;BR /&gt;&lt;BR /&gt;I've an assembly file with multiple parts (some with derived parts, others don't) and i'm trying to run a code that:&lt;/P&gt;&lt;P&gt;- Checks for the file type (.ipt/.iam)&lt;/P&gt;&lt;P&gt;- If it's an assembly file: iterates trough the multiple parts&amp;nbsp; and copies the Custom iProperties from the derived Parts from each one.&lt;/P&gt;&lt;P&gt;- If it's an Part file runs the previous code, no problems there...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my Sample code:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim openDoc As Document&lt;BR /&gt;openDoc = ThisDoc.Document&lt;BR /&gt;Dim docFile As Document&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;If openDoc.DocumentType = 12291 Then&lt;BR /&gt;&lt;BR /&gt;For Each docFile In openDoc.AllReferencedDocuments&lt;BR /&gt;&lt;BR /&gt;If docFile.ComponentDefinition.BOMStructure &amp;lt;&amp;gt; BOMStructureEnum.kPurchasedBOMStructure&lt;BR /&gt;Dim oDerived As Inventor.Document = &lt;STRONG&gt;ThisApplication.ActiveDocument '&lt;/STRONG&gt; &amp;lt;-i think this is where my problem lies because it jumps out to the main assembly custom iProproperties&lt;BR /&gt;If oDerived.ReferencedDocuments.Count = 0 Then Exit Sub&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oReferenced As Inventor.Document = oDerived.ReferencedDocuments(1)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oDerProps As PropertySet = oDerived.PropertySets.Item("Inventor User Defined Properties")&lt;BR /&gt;Dim oRefProps As PropertySet = oReferenced.PropertySets.Item("Inventor User Defined Properties")&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oProList() As String = {"*"} 'Use "*" to copy all iPros&lt;BR /&gt;For Each oRefPro As Inventor.Property In oRefProps&lt;BR /&gt;Dim oSkip As Boolean = True&lt;BR /&gt;For Each ProName As String In oProList&lt;BR /&gt;If UCase(ProName) &amp;lt;&amp;gt; UCase(oRefPro.Name) And ProName &amp;lt;&amp;gt; "*" Then Continue For&lt;BR /&gt;oSkip = False&lt;BR /&gt;Exit For&lt;BR /&gt;Next&lt;BR /&gt;If oSkip Then Continue For&lt;BR /&gt;Dim oDerPro As Inventor.Property&lt;BR /&gt;Try&lt;BR /&gt;oDerPro = oDerProps(oRefPro.Name)&lt;BR /&gt;Catch&lt;BR /&gt;oDerPro = oDerProps.Add("", oRefPro.Name)&lt;BR /&gt;End Try&lt;BR /&gt;oDerPro.Value = oRefPro.Value&lt;BR /&gt;Next&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Else If openDoc.DocumentType = 12290 Then&lt;BR /&gt;&lt;BR /&gt;Dim oDerived As Inventor.Document = ThisApplication.ActiveDocument&lt;BR /&gt;If oDerived.ReferencedDocuments.Count = 0 Then Exit Sub&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oReferenced As Inventor.Document = oDerived.ReferencedDocuments(1)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oDerProps As PropertySet = oDerived.PropertySets.Item("Inventor User Defined Properties")&lt;BR /&gt;Dim oRefProps As PropertySet = oReferenced.PropertySets.Item("Inventor User Defined Properties")&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oProList() As String = {"Pri_CodFamilia", "Pri_Descricao","Pri_Descricao_Familia","Pri_Descricao_Marca","Pri_Descricao_TipoArtigo","Pri_RefMarca","Pri_Referencia","Pri_UnidadeBase"} 'Use "*" to copy all iPros&lt;BR /&gt;For Each oRefPro As Inventor.Property In oRefProps&lt;BR /&gt;Dim oSkip As Boolean = True&lt;BR /&gt;For Each ProName As String In oProList&lt;BR /&gt;If UCase(ProName) &amp;lt;&amp;gt; UCase(oRefPro.Name) And ProName &amp;lt;&amp;gt; "*" Then Continue For&lt;BR /&gt;oSkip = False&lt;BR /&gt;Exit For&lt;BR /&gt;Next&lt;BR /&gt;If oSkip Then Continue For&lt;BR /&gt;Dim oDerPro As Inventor.Property&lt;BR /&gt;Try&lt;BR /&gt;oDerPro = oDerProps(oRefPro.Name)&lt;BR /&gt;Catch&lt;BR /&gt;oDerPro = oDerProps.Add("", oRefPro.Name)&lt;BR /&gt;End Try&lt;BR /&gt;oDerPro.Value = oRefPro.Value&lt;BR /&gt;Next&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;Else&lt;BR /&gt;'MessageBox.Show("O documento Ativo tem de ser um Assembly!", "Formato de Ficheiro Errado!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Glad to anyone that can help&lt;/P&gt;</description>
    <pubDate>Thu, 04 Nov 2021 15:44:57 GMT</pubDate>
    <dc:creator>desenho33ZLER</dc:creator>
    <dc:date>2021-11-04T15:44:57Z</dc:date>
    <item>
      <title>Copy Derived Custom iProperties</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/copy-derived-custom-iproperties/m-p/10735927#M130916</link>
      <description>&lt;P&gt;Hi!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm trying to adapt the code from a previous &lt;A href="https://forums.autodesk.com/t5/inventor-ilogic-api-vba-forum/copy-derived-custom-iproperties-pt-2-check-for-existing/td-p/6970390" target="_blank" rel="noopener"&gt;Post&lt;/A&gt; (works like a charm on an Part File)&amp;nbsp; so that i can run it on an assembly file.&amp;nbsp; Braking it down:&lt;BR /&gt;&lt;BR /&gt;I've an assembly file with multiple parts (some with derived parts, others don't) and i'm trying to run a code that:&lt;/P&gt;&lt;P&gt;- Checks for the file type (.ipt/.iam)&lt;/P&gt;&lt;P&gt;- If it's an assembly file: iterates trough the multiple parts&amp;nbsp; and copies the Custom iProperties from the derived Parts from each one.&lt;/P&gt;&lt;P&gt;- If it's an Part file runs the previous code, no problems there...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is my Sample code:&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&amp;nbsp;&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim openDoc As Document&lt;BR /&gt;openDoc = ThisDoc.Document&lt;BR /&gt;Dim docFile As Document&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;If openDoc.DocumentType = 12291 Then&lt;BR /&gt;&lt;BR /&gt;For Each docFile In openDoc.AllReferencedDocuments&lt;BR /&gt;&lt;BR /&gt;If docFile.ComponentDefinition.BOMStructure &amp;lt;&amp;gt; BOMStructureEnum.kPurchasedBOMStructure&lt;BR /&gt;Dim oDerived As Inventor.Document = &lt;STRONG&gt;ThisApplication.ActiveDocument '&lt;/STRONG&gt; &amp;lt;-i think this is where my problem lies because it jumps out to the main assembly custom iProproperties&lt;BR /&gt;If oDerived.ReferencedDocuments.Count = 0 Then Exit Sub&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oReferenced As Inventor.Document = oDerived.ReferencedDocuments(1)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oDerProps As PropertySet = oDerived.PropertySets.Item("Inventor User Defined Properties")&lt;BR /&gt;Dim oRefProps As PropertySet = oReferenced.PropertySets.Item("Inventor User Defined Properties")&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oProList() As String = {"*"} 'Use "*" to copy all iPros&lt;BR /&gt;For Each oRefPro As Inventor.Property In oRefProps&lt;BR /&gt;Dim oSkip As Boolean = True&lt;BR /&gt;For Each ProName As String In oProList&lt;BR /&gt;If UCase(ProName) &amp;lt;&amp;gt; UCase(oRefPro.Name) And ProName &amp;lt;&amp;gt; "*" Then Continue For&lt;BR /&gt;oSkip = False&lt;BR /&gt;Exit For&lt;BR /&gt;Next&lt;BR /&gt;If oSkip Then Continue For&lt;BR /&gt;Dim oDerPro As Inventor.Property&lt;BR /&gt;Try&lt;BR /&gt;oDerPro = oDerProps(oRefPro.Name)&lt;BR /&gt;Catch&lt;BR /&gt;oDerPro = oDerProps.Add("", oRefPro.Name)&lt;BR /&gt;End Try&lt;BR /&gt;oDerPro.Value = oRefPro.Value&lt;BR /&gt;Next&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;End If&lt;BR /&gt;Next&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Else If openDoc.DocumentType = 12290 Then&lt;BR /&gt;&lt;BR /&gt;Dim oDerived As Inventor.Document = ThisApplication.ActiveDocument&lt;BR /&gt;If oDerived.ReferencedDocuments.Count = 0 Then Exit Sub&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oReferenced As Inventor.Document = oDerived.ReferencedDocuments(1)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oDerProps As PropertySet = oDerived.PropertySets.Item("Inventor User Defined Properties")&lt;BR /&gt;Dim oRefProps As PropertySet = oReferenced.PropertySets.Item("Inventor User Defined Properties")&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;Dim oProList() As String = {"Pri_CodFamilia", "Pri_Descricao","Pri_Descricao_Familia","Pri_Descricao_Marca","Pri_Descricao_TipoArtigo","Pri_RefMarca","Pri_Referencia","Pri_UnidadeBase"} 'Use "*" to copy all iPros&lt;BR /&gt;For Each oRefPro As Inventor.Property In oRefProps&lt;BR /&gt;Dim oSkip As Boolean = True&lt;BR /&gt;For Each ProName As String In oProList&lt;BR /&gt;If UCase(ProName) &amp;lt;&amp;gt; UCase(oRefPro.Name) And ProName &amp;lt;&amp;gt; "*" Then Continue For&lt;BR /&gt;oSkip = False&lt;BR /&gt;Exit For&lt;BR /&gt;Next&lt;BR /&gt;If oSkip Then Continue For&lt;BR /&gt;Dim oDerPro As Inventor.Property&lt;BR /&gt;Try&lt;BR /&gt;oDerPro = oDerProps(oRefPro.Name)&lt;BR /&gt;Catch&lt;BR /&gt;oDerPro = oDerProps.Add("", oRefPro.Name)&lt;BR /&gt;End Try&lt;BR /&gt;oDerPro.Value = oRefPro.Value&lt;BR /&gt;Next&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;Else&lt;BR /&gt;'MessageBox.Show("O documento Ativo tem de ser um Assembly!", "Formato de Ficheiro Errado!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation)&lt;/P&gt;&lt;P class="lia-indent-padding-left-30px"&gt;&lt;BR /&gt;End If&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Glad to anyone that can help&lt;/P&gt;</description>
      <pubDate>Thu, 04 Nov 2021 15:44:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/copy-derived-custom-iproperties/m-p/10735927#M130916</guid>
      <dc:creator>desenho33ZLER</dc:creator>
      <dc:date>2021-11-04T15:44:57Z</dc:date>
    </item>
  </channel>
</rss>

