<?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 Deriving bodies to separate parts programattically in Inventor Programming - iLogic, Macros, AddIns &amp; Apprentice</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deriving-bodies-to-separate-parts-programattically/m-p/6274201#M63298</link>
    <description>&lt;P&gt;I am trying to build a script that does what the make components command does, but automates the passing of metadata from the multibody part to the individual parts.&amp;nbsp; We design most of our weldments in multibody and then derive out to create an assembly that can be used for drawings and BOM's.&amp;nbsp; The parameters that define the different pieces of steel (length width and thickness usually, but not always) live in the multibody part.&amp;nbsp; I have a nomenclature system that links parameter names with body names, so that it is easy to know which parameter should go to which part, either manually or with a script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I can either push the bodies out as base features in a script, thus losing connectivity, or derive the part into another part in a script, maintaining connectivity but unable to specify which body to choose and export programmatically.&amp;nbsp; I suspect (hope?) that there is syntax in either methods or properties of the derived part definition options to add or remove individual entities to the derived part definition but I have so far been unable to either find or fake them.&amp;nbsp; Below is the snippet in question.&amp;nbsp; first and last line work fine, if I leave out the second line I get a derived part with all the bodies from the source part.&amp;nbsp; But I cannot seem to find the structure that will get one specific body and push it to the derived part as&amp;nbsp;a derived entity. (i.e. maintaining connectivity).&amp;nbsp; Any advice or insight deeply appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'CodeStarts&lt;/P&gt;&lt;P&gt;'prior code, which all seems to work, iterates through bodies and associates them with parameters based on naming convention, and defines and creates target part&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oDerivedPrtDef = oFinalCompDef.ReferenceComponents.DerivedPartComponents.CreateDefinition(oPartDoc.FullDocumentName)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oDerivedPrtDef.Entities.Add(oBody) ' this line&amp;nbsp;is totally made up and throws errors, but gives the idea of what I need.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oFinalCompDef.ReferenceComponents.DerivedPartComponents.Add(oDerivedPrtDef)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'subsequent code saves new part with derived bits.&lt;/P&gt;&lt;P&gt;'Code Ends.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Apr 2016 00:29:55 GMT</pubDate>
    <dc:creator>mgigliotti</dc:creator>
    <dc:date>2016-04-16T00:29:55Z</dc:date>
    <item>
      <title>Deriving bodies to separate parts programattically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deriving-bodies-to-separate-parts-programattically/m-p/6274201#M63298</link>
      <description>&lt;P&gt;I am trying to build a script that does what the make components command does, but automates the passing of metadata from the multibody part to the individual parts.&amp;nbsp; We design most of our weldments in multibody and then derive out to create an assembly that can be used for drawings and BOM's.&amp;nbsp; The parameters that define the different pieces of steel (length width and thickness usually, but not always) live in the multibody part.&amp;nbsp; I have a nomenclature system that links parameter names with body names, so that it is easy to know which parameter should go to which part, either manually or with a script.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So far I can either push the bodies out as base features in a script, thus losing connectivity, or derive the part into another part in a script, maintaining connectivity but unable to specify which body to choose and export programmatically.&amp;nbsp; I suspect (hope?) that there is syntax in either methods or properties of the derived part definition options to add or remove individual entities to the derived part definition but I have so far been unable to either find or fake them.&amp;nbsp; Below is the snippet in question.&amp;nbsp; first and last line work fine, if I leave out the second line I get a derived part with all the bodies from the source part.&amp;nbsp; But I cannot seem to find the structure that will get one specific body and push it to the derived part as&amp;nbsp;a derived entity. (i.e. maintaining connectivity).&amp;nbsp; Any advice or insight deeply appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'CodeStarts&lt;/P&gt;&lt;P&gt;'prior code, which all seems to work, iterates through bodies and associates them with parameters based on naming convention, and defines and creates target part&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oDerivedPrtDef = oFinalCompDef.ReferenceComponents.DerivedPartComponents.CreateDefinition(oPartDoc.FullDocumentName)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oDerivedPrtDef.Entities.Add(oBody) ' this line&amp;nbsp;is totally made up and throws errors, but gives the idea of what I need.&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oFinalCompDef.ReferenceComponents.DerivedPartComponents.Add(oDerivedPrtDef)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'subsequent code saves new part with derived bits.&lt;/P&gt;&lt;P&gt;'Code Ends.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Apr 2016 00:29:55 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/deriving-bodies-to-separate-parts-programattically/m-p/6274201#M63298</guid>
      <dc:creator>mgigliotti</dc:creator>
      <dc:date>2016-04-16T00:29:55Z</dc:date>
    </item>
    <item>
      <title>Re: Deriving bodies to separate parts programattically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deriving-bodies-to-separate-parts-programattically/m-p/6275469#M63307</link>
      <description>&lt;P&gt;HI, I don't have acces to Inventor right now, as Im at home, so I can't test it.&lt;/P&gt;&lt;P&gt;But did you try something like this below? (made from memory, so you may need to play with the statements&amp;nbsp;- highlighted)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The idea in this is to run it for every component (as you do now, I suppose) and every time remove all components but one.&lt;/P&gt;&lt;P&gt;The "FirstComponent" name will come from the body name.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;Dim oCurrentComponent As String = "&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;FirstComponent&lt;/STRONG&gt;&lt;/FONT&gt;" &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;'Here you should write the name of the first component&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;oDerivedPrtDef = oFinalCompDef.ReferenceComponents.DerivedPartComponents.CreateDefinition(oPartDoc.FullDocumentName)
oFinalCompDef.ReferenceComponents.DerivedPartComponents.Add(oDerivedPrtDef)&lt;BR /&gt;Dim oCom As &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;PartComponent&lt;/STRONG&gt;&lt;BR /&gt;&lt;FONT color="#000000"&gt;For Each oCom In oFinalCompDef.ReferenceComponents.DerivedPartComponents&lt;BR /&gt;    MsgBox(oCom.Name) &lt;FONT color="#0000FF"&gt;&lt;STRONG&gt;' For testing purposes&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;    If Not oCom.Name = oCurrentComponent Than&lt;BR /&gt;        oCom.&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Remove&lt;/STRONG&gt;&lt;/FONT&gt;&lt;BR /&gt;    End If&lt;BR /&gt;&lt;/FONT&gt;&lt;FONT color="#000000"&gt;Next&lt;/FONT&gt;&lt;BR /&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 17 Apr 2016 21:02:26 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/deriving-bodies-to-separate-parts-programattically/m-p/6275469#M63307</guid>
      <dc:creator>Owner2229</dc:creator>
      <dc:date>2016-04-17T21:02:26Z</dc:date>
    </item>
    <item>
      <title>Re: Deriving bodies to separate parts programattically</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-ilogic/deriving-bodies-to-separate-parts-programattically/m-p/6276522#M63329</link>
      <description>&lt;P&gt;Mike;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply.&amp;nbsp; After I posted, I dug a little deeper and found some more options in the api and came up with the below.&amp;nbsp; Same basic approach as you suggested, make the derived part and then underive all but one body in each, and adjust metadata accordingly.&amp;nbsp; (Again, this represents only the block concerned with creating the derived part.&amp;nbsp; I have also however attached the entire rule below.&amp;nbsp; Still need to write the bit to create the new assembly and put all the new parts in it.)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;'StartCode&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oPartDocFinal = CType(ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False),PartDocument)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oFinalCompDef = oPartDocFinal.ComponentDefinition&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oPartDocFinal.UnitsOfMeasure.LengthUnits = UnitsTypeEnum.kInchLengthUnits&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oDerivedPrtDef = oFinalCompDef.ReferenceComponents.DerivedPartComponents.CreateDefinition(oPartDoc.FullDocumentName)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'oDerivedPrtDef.ExcludeAll&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'oDerivedPrtDef.IncludeAllSolids=kDerivedIncludeAll'kDerivedIndividualDefined&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oDerivedPrtDef.IncludeAllParameters=True&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For each oDerivedEntity in oDerivedPrtDef.Solids&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;strEName = oDerivedEntity.ReferencedEntity.Name&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;msgBox (strEName)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;If strEName &amp;lt;&amp;gt; strBName Then&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oDerivedEntity.IncludeEntity = False&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;End If&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'oDerivedPrtDef.Solids.Add(oBody)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oFinalCompDef.ReferenceComponents.DerivedPartComponents.Add(oDerivedPrtDef)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;For q = 0 to 3&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oTargetParams = oFinalCompDef.Parameters.UserParameters&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oTargetParameter =&amp;nbsp;oTargetParams.AddByValue(aProperties(q),1,UnitsTypeEnum.kInchLengthUnits)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;strPExpression = strBName &amp;amp; aPropAbbr(q)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oTargetParameter.Expression = strPExpression&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Next q&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;'oPartDocFinal.ComponentDefinition.Features.NonParametricBaseFeatures.Add(oBody,oMatrix)&lt;BR /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;oPartDocFinal.SaveAs(strWorkPath &amp;amp; "\" &amp;amp; "PT_" &amp;amp; strBName &amp;amp; ".ipt", True)&lt;/P&gt;&lt;P&gt;'EndCode.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 18 Apr 2016 13:25:11 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-ilogic/deriving-bodies-to-separate-parts-programattically/m-p/6276522#M63329</guid>
      <dc:creator>mgigliotti</dc:creator>
      <dc:date>2016-04-18T13:25:11Z</dc:date>
    </item>
  </channel>
</rss>

