How do I Locate a Sub Assembly Part from Top Level Assembly

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I'm new to using the API and I need some help. I want create a rule at my Top Level Assembly to place a Part into a Sub Assembly. I then want to locate the Part I just placed within the Sub Assembly with the same rule located at the Top Level Assembly. I have code to add the part into the Sub Assembly from the Top Level already as shown below.
(101W:Column Weldment, Field:1 is the Sub Assembly Occurrence & 104-L.ipt is the Part)
Dim oAssy As Inventor.AssemblyDocument
oAssy = ThisAssembly.Document
Dim subAssy As Inventor.AssemblyDocument
subAssy = oAssy.ComponentDefinition.Occurrences.ItemByName("101W:Column Weldment, Field:1").ReferencedDocumentDescriptor.ReferencedDocument
Dim occDef As AssemblyComponentDefinition
occDef = subAssy.ComponentDefinition
Dim oMat As Matrix
oMat = ThisApplication.TransientGeometry.CreateMatrix
Dim newOcc As ComponentOccurrence
newOcc = occDef.Occurrences.Add("D:\ASI Workspace\Libraries\Standard Components\104-L.ipt", oMat)
I manually created a rule in the Sub Assembly to locate the Part as shown below.
Dim _104_L_Knee_Brace_ClPos = ThisAssembly.Geometry.Matrix(0, 0, 1, 0,
1, 0, 0, 5.495,
0, 1, 0, 31,
0, 0, 0, 1)
Dim _104_L_Knee_Brace_Cl = Components.Add("104-L:1",
"104-L.ipt",
_104_L_Knee_Brace_ClPos)
This second code snippet does me no good in our workflow. The Top Level Assembly and the Part are library parts. They will always have the same name, file path, etc. The Sub Assembly, is a fresh assembly, with a new name and location for each project.
I suppose I have to define the Sub Assembly's matrix and then define the location of the Part in the matrix, but I can't seem to figure out how to do that. Any direct help or references would be helpful.