ilogic to link multibody solid parameters to assembly

ilogic to link multibody solid parameters to assembly

MCCJohnPetty
Enthusiast Enthusiast
881 Views
3 Replies
Message 1 of 4

ilogic to link multibody solid parameters to assembly

MCCJohnPetty
Enthusiast
Enthusiast

I have a multi-body part that I have created (make components) an assembly.  I want to be able to copy the multi-body parameters to this assembly so that I can Pattern, use Insert ilogic component, etc, and have them linked to the design parameters defined in my multi-body part.

 

I have been able to locate some code to do this, but it also copies the folders of each of the individual components generated from the multi-body part.

 

is there a way that I can "filter" to just the parent(s) of these components and link just that to my assembly?

 

Dim oApp As Application
Dim oAD As AssemblyDocument
Dim oACD As AssemblyComponentDefinition
Dim oAP As Parameters
Dim oRefDoc As Document


oApp = ThisApplication
oAD = oApp.ActiveDocument
oACD = oAD.ComponentDefinition
oAP = oACD.Parameters

On Error Resume Next
For Each oRefDoc In oAD.AllReferencedDocuments
	
		If oRefDoc.DocumentType = kPartDocumentObject Then	
    		refdocpath = oRefDoc.FullDocumentName
		MsgBox(refdocpath)
	Call oAP.DerivedParameterTables.Add(refdocpath)  

Else
End If
Next

(

0 Likes
Accepted solutions (1)
882 Views
3 Replies
Replies (3)
Message 2 of 4

J-Camper
Advisor
Advisor
Accepted solution

So all the components are coming from the same multisolid part, or at least the first few components in your assembly are since you used make components.  You shouldn't need to loop through all referenced documents for this, but you do need to make sure all your parameters you want to bring over are marked for export.  I added an option to mark all parameters for export or not:

Dim oApp As Inventor.Application = ThisApplication
Dim oAD As AssemblyDocument  = oApp.ActiveDocument
Dim oACD As AssemblyComponentDefinition = oAD.ComponentDefinition
Dim oAP As Parameters = oACD.Parameters
Dim oRefDoc As Document
'Get first instance only because the parts were all made from 1 parent assembly
oRefDoc = oACD.Occurrences.Item(1).Definition.Document
If MessageBox.Show("Would you like to mark all parameters for export?", oRefDoc.AllReferencedDocuments.Item(1).DisplayName, MessageBoxButtons.YesNo) = vbNo Then GoTo SkipHere
'Collect Parameters in parent document to mark all for export
Dim FillThis As ObjectCollection = oApp.TransientObjects.CreateObjectCollection
For Each p As Parameter In oRefDoc.AllReferencedDocuments.Item(1).ComponentDefinition.Parameters
	FillThis.Add(p)
Next
oRefDoc.AllReferencedDocuments.Item(1).ComponentDefinition.ExportObjects(FillThis)
SkipHere:
'Create Derived Link
Call oAP.DerivedParameterTables.Add(oRefDoc.AllReferencedDocuments.Item(1).FullDocumentName)

 You could add a filter to the parameter loop if you want to restrict which parameters get marked for export.  You could also eliminate that section if your parent part already has all the parameters you want marked for export.

 

Let me know if you have any questions or if this isn't doing what you want.

0 Likes
Message 3 of 4

MCCJohnPetty
Enthusiast
Enthusiast

Works wonderfully.  Thanks.  I am tweaking a bit to remove all "d" parameters, but that is pretty simple.

 

Question though, there are quite a few commands used here like "TransientObjects", and "ExportObjects", that are not Intelli marked for the methods, etc that are being called.  Where can I find information about these types?  Would love to learn more.

 

Thanks again for your help

 

0 Likes
Message 4 of 4

J-Camper
Advisor
Advisor

@MCCJohnPetty,

You can find The object tree with associated methods/Properties through the local Help > Programing/API Help > Inventor API Reference Manual > Objects

or online InventorHelpPage under Programming Interface > Inventor API Reference Manual

 

Under the Application Object you can find Properties like TransientObjects, which you can click on to find its methods/Properties, and so on.

 

Under PartComponentDefinition Object  You can find methods like ExportObjects, which you can click on to find the syntax for what it needs in order to call.

 

There are even some sample programs linked to some of the Objects/Methods/Properties to help understand how to use them.

 

0 Likes