<?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: New Substitute&amp;gt;Derive Assembly&amp;gt;Bounding Box (.ipt only) - iLogic please. in Inventor Programming Forum</title>
    <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859333#M56636</link>
    <description>&lt;P&gt;Sorry I pulled that line out of my derived part sub routine and didn't change the variable name.&amp;nbsp; Use this instead:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;oDerivedAsmDef.ActiveDesignViewRepresentation = RepID 'Where RepID is a string of the View rep name&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-25AB5629-8280-4BFB-91E7-92FF97E8455E" target="_blank" rel="noopener"&gt;DerivedAssemblyDefinition Object&lt;/A&gt; [link to the help file for this definition's Methods/Properties]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like you can do a similar thing with the LOD if you still need to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 10 Nov 2020 16:49:20 GMT</pubDate>
    <dc:creator>J-Camper</dc:creator>
    <dc:date>2020-11-10T16:49:20Z</dc:date>
    <item>
      <title>New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9834915#M56626</link>
      <description>&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;Going to search the forum to find something which will copy the workflow below - the result will be a simplified part&amp;nbsp; made up of Bounding Boxes. not too sure how the options are set using ilogic.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Substitue Derived Part.JPG" style="width: 918px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/838450i37CD08D0F119E431/image-size/large?v=v2&amp;amp;px=999" role="button" title="Substitue Derived Part.JPG" alt="Substitue Derived Part.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 13:34:07 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9834915#M56626</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-10-30T13:34:07Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9835554#M56627</link>
      <description>&lt;P&gt;I had some code to replace part with derived part within an assembly, and modified it to do the open assembly instead:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sub Main
	If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
	
	Dim AsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim FileName As String = AsmDoc.FullFileName : FileName = Left(FileName, (FileName.Length-4)) &amp;amp; "_SUB" &amp;amp; ".ipt"
	Dim NewDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False) 'include path to template file [if defualt is insufficient] between ,  , after DocumentTypeEnum.kPartDocumentObject
	Dim oDerivedAsmDef As DerivedAssemblyDefinition = NewDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(AsmDoc.FullFileName)
	
	'Derived Assembly Options:
	oDerivedAsmDef.ScaleFactor = 1
	oDerivedAsmDef.ReducedMemoryMode = True
	oDerivedAsmDef.UseColorOverridesFromSource = True
	oDerivedAsmDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
	oDerivedAsmDef.InclusionOption = DerivedComponentOptionEnum.kDerivedBoundingBox

	Call NewDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAsmDef)

	Try
		NewDoc.SaveAs(FileName, False)
	Catch
		MessageBox.Show(NewDoc.DisplayName &amp;amp; " cannot be overwritten.", "Terminating")
		NewDoc.Close(True)
		Exit Sub
	End Try
	
	ThisApplication.Documents.Open(NewDoc.FullDocumentName, True)
	
End Sub
	&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if you have any questions or if this is not working as intended&lt;/P&gt;</description>
      <pubDate>Fri, 30 Oct 2020 18:30:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9835554#M56627</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-10-30T18:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9846070#M56628</link>
      <description>&lt;P&gt;Many Thanks, sorry it's taken a while to test but there's a hickup. I was hoping for only the parts to be blocked out - not the assembly. The result is on the left of the picture &amp;amp; the wish is for the image on the right - possible?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DeriveBlock.jpg" style="width: 999px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/840427i41801123F49798EA/image-size/large?v=v2&amp;amp;px=999" role="button" title="DeriveBlock.jpg" alt="DeriveBlock.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 19:06:50 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9846070#M56628</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-11-04T19:06:50Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9846144#M56629</link>
      <description>&lt;P&gt;Easy tweak, Just changed the InclusionOption to Exclude all then gathered all the Parts and subassembly parts into an ObjectCollection with a custom function.&amp;nbsp; Then set the InclusionOption for each Part occurrence individually before setting the definition to the new part document:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
	If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
	
	Dim AsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim FileName As String = AsmDoc.FullFileName : FileName = Left(FileName, (FileName.Length-4)) &amp;amp; "_SUB" &amp;amp; ".ipt"
	Dim NewDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False) 'include path to template file [if defualt is insufficient] between ,  , after DocumentTypeEnum.kPartDocumentObject
	Dim oDerivedAsmDef As DerivedAssemblyDefinition = NewDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(AsmDoc.FullFileName)
	
	'Derived Assembly Options:
	oDerivedAsmDef.ScaleFactor = 1
	oDerivedAsmDef.ReducedMemoryMode = True
	oDerivedAsmDef.UseColorOverridesFromSource = True
	oDerivedAsmDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
	oDerivedAsmDef.InclusionOption = DerivedComponentOptionEnum.kDerivedExcludeAll
	
	'Limit bounding box to part files only
	Dim partCol As ObjectCollection = GetOnlyParts(oDerivedAsmDef.Occurrences)
	
	For Each Oc As DerivedAssemblyOccurrence In partCol
		Oc.InclusionOption = DerivedComponentOptionEnum.kDerivedBoundingBox
	Next

	Call NewDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAsmDef)

	Try
		NewDoc.SaveAs(FileName, False)
	Catch
		MessageBox.Show(NewDoc.DisplayName &amp;amp; " cannot be overwritten.", "Terminating")
		NewDoc.Close(True)
		Exit Sub
	End Try
	
	ThisApplication.Documents.Open(NewDoc.FullDocumentName, True)
	
End Sub

Function GetOnlyParts(mainCol As DerivedAssemblyOccurrences) As ObjectCollection
	Dim Result As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	For Each Oc As DerivedAssemblyOccurrence In mainCol
		If Oc.IsAssembly = False
			Result.Add(Oc)
		Else
			For Each OcSub As DerivedAssemblyOccurrence In GetOnlyParts(Oc.SubOccurrences)
				Result.Add(OcSub)
			Next
		End If
	Next
	Return Result
End Function&lt;/LI-CODE&gt;&lt;P&gt;Let me know if you have any questions, or if it is not working as intended.&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 19:45:25 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9846144#M56629</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-11-04T19:45:25Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9846194#M56630</link>
      <description>&lt;P&gt;Many Thanks&lt;/P&gt;&lt;P&gt;One day i'll understand!&lt;/P&gt;</description>
      <pubDate>Wed, 04 Nov 2020 20:10:24 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9846194#M56630</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-11-04T20:10:24Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9850678#M56631</link>
      <description>&lt;P&gt;Working exactly as I'd hoped but could a few extra's be added&amp;nbsp;- if possible?&lt;/P&gt;&lt;P&gt;Many existing&amp;nbsp;assemblies have a LoD or View Rep set (which are best avoided)&amp;nbsp;- if&amp;nbsp;an additional &amp;nbsp;LoD /View Rep called 'For_GA' is added to the can the ilogic pick up this option?&lt;/P&gt;&lt;P&gt;Secondly, some shading collision can be seen where there's a surface on a surface - could the 'Single solid body merging out seams' be set?&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="LoD Switches.jpg" style="width: 816px;"&gt;&lt;img src="https://forums.autodesk.com/t5/image/serverpage/image-id/841190i38B5FFBBD39BB374/image-size/large?v=v2&amp;amp;px=999" role="button" title="LoD Switches.jpg" alt="LoD Switches.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Difficult to say if that's everything, certainly 99% I feel.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[The next project would be to iterate through sub assemblies - running this code, creating simple versions of the sub assemblies, then replace the sub assembly with the part. This would leave the LoD at master &amp;amp; the browser containing simplified parts]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Fri, 06 Nov 2020 15:36:35 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9850678#M56631</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-11-06T15:36:35Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9856033#M56632</link>
      <description>&lt;P&gt;The derive style is easy to change:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'Replace Line:
oDerivedAsmDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsMultipleBodies
'With the Line:
oDerivedAsmDef.DeriveStyle = DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams&lt;/LI-CODE&gt;&lt;P&gt;As for the view representations, are you saying you want to export the subassemblies in their master view/LOD state or you want to export them in the state of a custom view/LOD?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If it's master you should be able to just change the view/LOD of the main assembly to mater and all others should follow suite before running the rule.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Otherwise there will have to be additional code to check and set View/LOD for subassemblies before collection parts within those subassemblies.&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 14:38:40 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9856033#M56632</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-11-09T14:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9856125#M56633</link>
      <description>&lt;P&gt;Hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been searching &amp;amp; can't find an example of deriving the current LoD setting (or view rep)- the code always appears to export the master.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Managed to find (guess it was already in the code) the export 'No seams' option.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Many existing assemblies contain suppressed part which I'd like to exclude from the substitute.&lt;/P&gt;&lt;P&gt;My efforts are generating a few error messages!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 09 Nov 2020 15:09:12 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9856125#M56633</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-11-09T15:09:12Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859181#M56634</link>
      <description>&lt;P&gt;There is a way to link a view representation in the main assembly:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="general"&gt;oDerivedPartDef.ActiveDesignViewRepresentation = RepID 'Where RepID is a string of the View rep name&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;but I'm not sure if that would affect the Part collection function or if that function needs to be modified to verify visibility with the desired View representation.&amp;nbsp; I've done more automated part derivations than assembly derivations in my time, but it should be doable either way.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 16:12:03 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859181#M56634</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-11-10T16:12:03Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859205#M56635</link>
      <description>&lt;P&gt;Sorry for the trouble but..&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Error on Line 19 : 'oDerivedPartDef' is not declared. It may be inaccessible due to its protection level.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 16:17:54 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859205#M56635</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-11-10T16:17:54Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859333#M56636</link>
      <description>&lt;P&gt;Sorry I pulled that line out of my derived part sub routine and didn't change the variable name.&amp;nbsp; Use this instead:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;oDerivedAsmDef.ActiveDesignViewRepresentation = RepID 'Where RepID is a string of the View rep name&lt;/LI-CODE&gt;&lt;P&gt;&lt;A href="http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-25AB5629-8280-4BFB-91E7-92FF97E8455E" target="_blank" rel="noopener"&gt;DerivedAssemblyDefinition Object&lt;/A&gt; [link to the help file for this definition's Methods/Properties]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It looks like you can do a similar thing with the LOD if you still need to.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 16:49:20 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859333#M56636</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-11-10T16:49:20Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859462#M56637</link>
      <description>&lt;P&gt;The parameter is incorrect. (Exception from HRESULT: 0x80070057 (E_INVALIDARG))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've attached the test assembly - added the code on line 26.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the effort, didn't realise it would be so awkward.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 17:22:34 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859462#M56637</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-11-10T17:22:34Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859610#M56638</link>
      <description>&lt;P&gt;I don't have a 2018 version of Inventor so the sample files got saved to 2019 files while i tested them, but here is the code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
	If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
	'Main Setup:
	Dim AsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim FileName As String = AsmDoc.FullFileName : FileName = Left(FileName, (FileName.Length-4)) &amp;amp; "_SUB" &amp;amp; ".ipt"
	
	'ViewRep Sample Setup:
	Dim RepID As String = ""
	Dim RepIDlist As New List(Of String)
	'Get List from file so we can choose view from list. This Can be automated with desired name
	For Each View In AsmDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations
		RepIDlist.Add(View.Name)
	Next	

	'Temporarily choosing view from list. This can be automated with desired name
	RepID = InputListBox("", RepIDlist, RepIDlist.Item(0), Title := "Title", ListName := "List")
	If RepID = "" Then RepID = "Master" 'Setting a Default Value for nothing selected
	'Set View representation so visibility can be verified
	AsmDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepID).Activate

	'New Document Setup:
	Dim NewDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False) 'include path to template file [if defualt is insufficient] between ,  , after DocumentTypeEnum.kPartDocumentObject
	Dim oDerivedAsmDef As DerivedAssemblyDefinition = NewDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(AsmDoc.FullFileName)

	'Derived Assembly Options:
	oDerivedAsmDef.ScaleFactor = 1
	oDerivedAsmDef.ReducedMemoryMode = True
	oDerivedAsmDef.UseColorOverridesFromSource = True
	oDerivedAsmDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.DeriveStyle =  DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams
	oDerivedAsmDef.InclusionOption = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.ActiveDesignViewRepresentation = RepID 'Where RepID is a string of the View rep name

	'Limit bounding box to part files only
	Dim partCol As ObjectCollection = GetOnlyParts(oDerivedAsmDef.Occurrences)
	
	For Each Oc As DerivedAssemblyOccurrence In partCol
		Oc.InclusionOption = DerivedComponentOptionEnum.kDerivedBoundingBox
	Next

	Call NewDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAsmDef)

	Try
		NewDoc.SaveAs(FileName, False)
	Catch
		MessageBox.Show(NewDoc.DisplayName &amp;amp; " cannot be overwritten.", "Terminating")
		NewDoc.Close(True)
		Exit Sub
	End Try
	
	ThisApplication.Documents.Open(NewDoc.FullDocumentName, True)
	
End Sub

Function GetOnlyParts(mainCol As DerivedAssemblyOccurrences) As ObjectCollection
	Dim Result As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	For Each Oc As DerivedAssemblyOccurrence In mainCol
		If Oc.IsAssembly = False
			If Oc.ReferencedOccurrence.Suppressed = False And Oc.ReferencedOccurrence.Visible = True
				Result.Add(Oc)
			End If
		Else
			For Each OcSub As DerivedAssemblyOccurrence In GetOnlyParts(Oc.SubOccurrences)
				If OcSub.ReferencedOccurrence.Suppressed = False And OcSub.ReferencedOccurrence.Visible = True
					Result.Add(OcSub)
				End If
			Next
		End If
	Next
	Return Result
End Function&lt;/LI-CODE&gt;&lt;P&gt;Looks like I had to set the view representation before I could test the solid bodies for visibiliy/suppression, which was added to the GetOnlyParts Function.&amp;nbsp; If subassembly view reps are associated with the main assembly View Representation, It should work as intended, Otherwise digging through sub assemblies might require some extra steps.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I decided to put the view representation selection into a list, but it could be done with logic as long as the View names are consistent throughout all assemblies.&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 18:06:04 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859610#M56638</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-11-10T18:06:04Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859885#M56639</link>
      <description>&lt;P&gt;Excellent - however my ability to find odd problems continues.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've moved the code to an external rule folder &amp;amp; it works on the test assembly.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There was a 'real' assembly which was being looked at &amp;amp; this returns a message:&lt;/P&gt;&lt;P&gt;Terminating - Part * cannot be overwritten&lt;/P&gt;&lt;P&gt;* up to part 11 now -not sure if a Part11 exist's somewhere, very likely.&lt;/P&gt;&lt;P&gt;Testing continues 99.9% there &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Working ok on a different test assembly..&lt;/P&gt;</description>
      <pubDate>Tue, 10 Nov 2020 19:50:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9859885#M56639</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-11-10T19:50:38Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9860743#M56640</link>
      <description>&lt;P&gt;What you are seeing is the save attempt in the code:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Try
		NewDoc.SaveAs(FileName, False)
	Catch
		MessageBox.Show(NewDoc.DisplayName &amp;amp; " cannot be overwritten.", "Terminating")
		NewDoc.Close(True)
		Exit Sub
	End Try&lt;/LI-CODE&gt;&lt;P&gt;It "Trys" to do a save as on the new open document we are building, "Part*".&amp;nbsp; When the "Try" fails the&amp;nbsp; "Catch" Triggers, where it says it can't be over written then closes the open document without saving.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Was the part open in another tab? Or maybe it's checked out in the vault or set to read only?&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 03:07:30 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9860743#M56640</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2020-11-11T03:07:30Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9861288#M56641</link>
      <description>&lt;P&gt;All good.&lt;/P&gt;&lt;P&gt;The part was already saved from an earlier test last week - thanks again.&lt;/P&gt;</description>
      <pubDate>Wed, 11 Nov 2020 09:23:23 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/9861288#M56641</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2020-11-11T09:23:23Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/10841151#M56642</link>
      <description>Still like this program &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;BR /&gt;Wondering if a filter by size can be added?&lt;BR /&gt;So the Bounding Box is only applied to parts less than 200mm on the diagonal (value adjustable)&lt;BR /&gt;Regards&lt;BR /&gt;&lt;BR /&gt;Andrew</description>
      <pubDate>Fri, 24 Dec 2021 09:57:33 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/10841151#M56642</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2021-12-24T09:57:33Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/10862074#M56643</link>
      <description>&lt;P&gt;I wanted to reach out real quick.&amp;nbsp; I didn't look at the forum over the holidays and my area was hit with a major snow storm which has left me without power for several days on going.&amp;nbsp; I will look into this, as it should be possible, but I won't have time for a while longer.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If you want to look into this your self, my approach would be to take the Object Collection of Parts only and run it through another custom function to "Refine" the Object collection for bounding box size then pass the "Refined" Object Collection into the DerivedPartDefinition. This is where I think the "Refining" Function would go:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;'Limit bounding box to part files only
	Dim partCol As ObjectCollection = GetOnlyParts(oDerivedAsmDef.Occurrences)
	
Dim RefinedpartCol As ObjectCollection = RefineParts(partCol, "200mm")

	For Each Oc As DerivedAssemblyOccurrence In RefinedpartCol
		Oc.InclusionOption = DerivedComponentOptionEnum.kDerivedBoundingBox
	Next&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RefineParts(partCol, "200mm") would be a function that returns an Object Collection whose parts all have a bounding box dimension greater than 200mm.&amp;nbsp; In that function you would need to use bondingBox or OrientedBoundingBox to get corners you can pull a diagonal of.&amp;nbsp; For each part in the supplied collection you test and add to result if passes.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Again, I can look into this further after I get power restored and back to normal home life.&amp;nbsp; Someone else on the forum might be able to help before I get a chance to really dig in.&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 14:31:57 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/10862074#M56643</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2022-01-06T14:31:57Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/10862370#M56644</link>
      <description>&lt;P&gt;Hello J&lt;/P&gt;&lt;P&gt;Hopefully you can dig you way out of the snow soon!&lt;/P&gt;&lt;P&gt;I'm pretty sure whenever you have chance to revisit this will be quicker than me trying to update the code - managed to break it already! (too many arguments?)&lt;/P&gt;&lt;P&gt;But if it does work it'd be amazing - why it's not an option already bemuses me - I see hiding parts will lighted a model but it's still useful to know there's something there.&lt;/P&gt;&lt;P&gt;Many thanks for the update.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Regards&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Andrew&lt;/P&gt;</description>
      <pubDate>Thu, 06 Jan 2022 16:49:10 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/10862370#M56644</guid>
      <dc:creator>andrew_canfield</dc:creator>
      <dc:date>2022-01-06T16:49:10Z</dc:date>
    </item>
    <item>
      <title>Re: New Substitute&gt;Derive Assembly&gt;Bounding Box (.ipt only) - iLogic please.</title>
      <link>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/10870448#M56645</link>
      <description>&lt;P&gt;&lt;a href="https://forums.autodesk.com/t5/user/viewprofilepage/user-id/4610648"&gt;@andrew_canfield&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Try This and let me know if it is working as intended:&lt;/P&gt;&lt;LI-CODE lang="general"&gt;Sub Main
	If ThisApplication.ActiveDocumentType &amp;lt;&amp;gt; kAssemblyDocumentObject Then MessageBox.Show("This rule is designed to only work in assembly documents.", "Wrong Document Type") : Exit Sub
	'Main Setup:
	Dim AsmDoc As AssemblyDocument = ThisApplication.ActiveDocument
	Dim FileName As String = AsmDoc.FullFileName : FileName = Left(FileName, (FileName.Length-4)) &amp;amp; "_SUB" &amp;amp; ".ipt"
	
	'ViewRep Sample Setup:
	Dim RepID As String = ""
	Dim RepIDlist As New List(Of String)
	'Get List from file so we can choose view from list. This Can be automated with desired name
	For Each View In AsmDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations
		RepIDlist.Add(View.Name)
	Next	

	'Temporarily choosing view from list. This can be automated with desired name
	RepID = InputListBox("Select a View Rep to derive", RepIDlist, RepIDlist.Item(0), Title := "View Representations", ListName := "Available:")
	If RepID = "" Then RepID = "Master" 'Setting a Default Value for nothing selected
	'Set View representation so visibility can be verified
	AsmDoc.ComponentDefinition.RepresentationsManager.DesignViewRepresentations.Item(RepID).Activate

	'New Document Setup:
	Dim NewDoc As PartDocument = ThisApplication.Documents.Add(DocumentTypeEnum.kPartDocumentObject, , False) 'include path to template file [if defualt is insufficient] between ,  , after DocumentTypeEnum.kPartDocumentObject
	Dim oDerivedAsmDef As DerivedAssemblyDefinition = NewDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.CreateDefinition(AsmDoc.FullFileName)

	'Derived Assembly Options:
	oDerivedAsmDef.ScaleFactor = 1
	oDerivedAsmDef.ReducedMemoryMode = True
	oDerivedAsmDef.UseColorOverridesFromSource = True
	oDerivedAsmDef.IncludeAllTopLeveliMateDefinitions = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelParameters = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelSketches = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.IncludeAllTopLevelWorkFeatures = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.DeriveStyle =  DerivedComponentStyleEnum.kDeriveAsSingleBodyNoSeams
	oDerivedAsmDef.InclusionOption = DerivedComponentOptionEnum.kDerivedExcludeAll
	oDerivedAsmDef.ActiveDesignViewRepresentation = RepID 'Where RepID is a string of the View rep name

	'Limit bounding box to part files only
	Dim partCol As ObjectCollection = GetOnlyParts(oDerivedAsmDef.Occurrences)
	
	'Limit bounding box to smaller than target
	Dim minLimit As Double = 20 'cm [internal units are cm]
	Dim RefinedpartCol As ObjectCollection = RefinePartsMin(partCol, minLimit)
	
	For Each Oc As DerivedAssemblyOccurrence In RefinedpartCol
		Oc.InclusionOption = DerivedComponentOptionEnum.kDerivedBoundingBox
	Next

	Call NewDoc.ComponentDefinition.ReferenceComponents.DerivedAssemblyComponents.Add(oDerivedAsmDef)

	Try
		NewDoc.SaveAs(FileName, False)
	Catch
		MessageBox.Show(NewDoc.DisplayName &amp;amp; " cannot be overwritten.", "Terminating")
		NewDoc.Close(True)
		Exit Sub
	End Try
	
	ThisApplication.Documents.Open(NewDoc.FullDocumentName, True)
	
End Sub

Function RefinePartsMin(mainCol As ObjectCollection, limit As Double) As ObjectCollection
	Dim Result As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	For Each Oc As DerivedAssemblyOccurrence In mainCol
		Dim oBox As Box = Oc.ReferencedOccurrence.RangeBox
		Dim diagonal As Vector = oBox.MinPoint.VectorTo(oBox.MaxPoint)
		If diagonal.Length &amp;lt;= limit Then Result.Add(Oc)
	Next
	
	Return Result
End Function

Function GetOnlyParts(mainCol As DerivedAssemblyOccurrences) As ObjectCollection
	Dim Result As ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	For Each Oc As DerivedAssemblyOccurrence In mainCol
		
		If Oc.IsAssembly = False
			
			If Oc.ReferencedOccurrence.Suppressed = False And Oc.ReferencedOccurrence.Visible = True
				Result.Add(Oc)
			End If
		
		Else
			
			For Each OcSub As DerivedAssemblyOccurrence In GetOnlyParts(Oc.SubOccurrences)
				If OcSub.ReferencedOccurrence.Suppressed = False And OcSub.ReferencedOccurrence.Visible = True
					Result.Add(OcSub)
				End If
			Next
		
		End If
	Next
	
	Return Result
End Function&lt;/LI-CODE&gt;&lt;P&gt;I added a function that limits the bounding box setting to parts that have a diagonal less than or equal to 20cm [internal units for API are in cm].&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Let me know if you have any question or if this is not working as intended.&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jan 2022 01:31:38 GMT</pubDate>
      <guid>https://forums.autodesk.com/t5/inventor-programming-forum/new-substitute-gt-derive-assembly-gt-bounding-box-ipt-only/m-p/10870448#M56645</guid>
      <dc:creator>J-Camper</dc:creator>
      <dc:date>2022-01-11T01:31:38Z</dc:date>
    </item>
  </channel>
</rss>

