style="PADDING-RIGHT: 0px; PADDING-LEFT: 5px; MARGIN-LEFT: 5px; BORDER-LEFT: #000000 2px solid; MARGIN-RIGHT: 0px">
"cgitzlaff" <I
href="mailto:cgitzlaff@majorskylights.com">cgitzlaff@majorskylights.com>
wrote in message
href="news:f17a24f.-1@WebX.maYIadrTaRb">news:f17a24f.-1@WebX.maYIadrTaRb...
have an assembly that contains multiple parts. I have been successful at
adding parts with VBA code, but want to place constraints (mate and flush) on
the parts I add. I created work planes specifically for this task in each of
the parts I want to constrain. If I mate Work PlaneX in Part1 to Work PlaneZ
in Part2, I will have exactly what I'm looking for. Below is the VBA code I
have been using to try this. The code references specific Part Documents and
Work Planes. These are working properly (referencing the correct parts and
documents). The constraint call is the only thing not working. Am I on the
right track?
TIA,
Chris Gitzlaff
Code:
Dim oAsmCompDef As AssemblyComponentDefinition
Set
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
Dim oPt1CompDef As PartComponentDefinition
Dim oPt2CompDef As
PartComponentDefinition
Dim oMate As MateConstraint
Dim oWPlane1 As WorkPlane
Dim oWPlane2 As WorkPlane
Set oPt1CompDef = ThisApplication.Documents.Item(3).ComponentDefinition
Set oWPlane1 = oPt1CompDef.WorkPlanes.Item(9)
Set oPt2CompDef = ThisApplication.Documents.Item(6).ComponentDefinition
Set oWPlane2 = oPt2CompDef.WorkPlanes.Item(4)
Set oMate = oAsmCompDef.Constraints.AddMateConstraint(oWPlane1, oWPlane2,
0, kInferredLine, kInferredLine)