- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
I am unsuccessful in my attempt to create a component mate constraint between an assembly workplane and a part workplane from a second assembly, where both are inserted in a 'Master Assembly', (MA)
I have an assembly that I create reference workplanes, driven from an .xlsx file. (lets call this my 'Reference Assembly', RA). I am trying to create a rule that allows me to place an assembly and the rule automatically creates mate/flush constraints with this 'New Assembly'(NA). My rule works when I try to create a mate between planes located within the RA and the NA. I can not figure out how to create a component mate between a plane located within a .ipt in my 'New Assembly' and a plane located inside my RA.
I have a subroutine to loop through my NA to locate the required workplane
FindSubPlane(NA.Definition.Document, SrchWPlane, "PlaneName"
Where NA references my freshly inserted assembly from a FileDialog
Dim NA As ComponentOccurrence
Dim aDoc As AssemblyDocument = ThisApplication.ActiveEditDocument Dim acomDef As AssemblyComponentDefinition = aDoc.ComponentDefinition
NA = acomDef.Occurrences.Add(File, InMatrix)
NA.Grounded = False
My subroutine is as follows;
Sub FindSubPlane(aDoc As AssemblyDocument, ByRef PPlane As WorkPlane, PName As String)
'^^^^ I have also tried defining PPlane As WorkPlaneProxy Dim acomDef As ComponentDefinition = aDoc.ComponentDefinition Dim aOcc As ComponentOccurrences = acomDef.Occurrences Dim MasterP As String ' MasterP is a parameter inside my .iam file that indicates the Key .ipt within Try MasterP = Parameter(aDoc.DisplayName, "MasterP") Catch MasterP = "" End Try
For Each GrOcc As Inventor.ComponentOccurrence In aOcc If GrOcc.Name = MasterP Then For Each SrchPl As WorkPlane In GrOcc.Definition.WorkPlanes If SrchPl.Name = PName Then PPlane = SrchPl 'GrOcc.CreateGeometryProxy(SrchPl, PPlane) '^^^ the above line is what I used when I attempted to create the WorkPlaneProxy inside the subroutine Exit Sub End If Next End If Next End Sub
The above routine seems to find the correct WorkPlane. (or create my WorkPlaneProxy if that is what I was attempting)
If I simply pass back the WorkPlane, I fail at the following;
NA.CreateGeometryProxy(SrchWPlane, ProxSrchWPlane)
If I return the WorkPlaneProxy, I fail at the following;
acomDef.Constraints.AddFlushConstraint(ProxSrchWPlane, RAProxWPlane, 0)
The above .AddFlush or .AddMateConstraint works fine, If the ProxyPlanes are from the ReferenceAssembly and the NewAssembly. I fails as soon as the ProxyPlane is from an .ipt within the NA.
What am I missing/doing wrong?
Solved! Go to Solution.