Hi @Mark.Hynd,
See this example. I'm not sure if this is exactly what you are looking for, but it does place an angle rather than a flush
I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com
'oAngle = 15 'angle in degrees
oAngle = InputBox("Enter angle", "iLogic", 0)
If oAngle Is Nothing Then Exit Sub
If IsNumeric(oAngle) = False Then Exit Sub
oConstraintName = "XY_Angle"
Dim oAsmCompDef As AssemblyComponentDefinition
oAsmCompDef = ThisApplication.ActiveDocument.ComponentDefinition
'Delete Existing Constraints
Dim oConstraint As AssemblyConstraint
For Each oConstraint In oAsmCompDef.Constraints
If oConstraint.Name.Contains(oConstraintName) Then
oConstraint.Delete
End If
Next
Dim oPlane As WorkPlane
Dim oProxyPlane As WorkPlaneProxy
'Iterate through all of the occurrences
Dim oOccurrence As ComponentOccurrence
i = 1
For Each oOccurrence In oAsmCompDef.Occurrences.AllReferencedOccurrences(oAsmCompDef)
'check for and skip virtual components
'(in case a virtual component trips things up)
If Not TypeOf oOccurrence.Definition Is VirtualComponentDefinition Then
oPlane = oOccurrence.Definition.WorkPlanes.Item(3) 'XY plane
'create component proxy plane in assembly
Call oOccurrence.CreateGeometryProxy(oPlane, oProxyPlane)
End If
'get assembly plane
Dim oPlane2 As WorkPlane
oPlane2 = oAsmCompDef.WorkPlanes.Item(3) 'XY plane
' Create the constraint using the work plane proxies.
oConstraint = oAsmCompDef.Constraints.AddAngleConstraint(oProxyPlane, oPlane2, oAngle * 180 / PI,
AngleConstraintSolutionTypeEnum.kReferenceVectorSolution, oAsmCompDef.WorkAxes.Item("X Axis"))
'optionaly you could use this line and NOT specify an rotation vector
'oConstraint = oAsmCompDef.Constraints.AddAngleConstraint(oProxyPlane, oPlane2, oAngle * 180 / PI)
oConstraint.Name = oConstraintName & i
i = i + 1
Next
