Message 1 of 3
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello all!
So I'm trying to ridig joint an assembly to another item. This other item is simply picked with the commandmanager.
Inside the assembly template is a part with a named face. I want the user only need to pick the hole and it'll create the joint.
But I get an runtime error. Somebody knows whats going wrong? (the code works if I replace the named face code for just another commandmanager face pick)
Public Sub AssemblyConnect()
' Create a new assembly document.
Dim asmDoc As AssemblyDocument
Set asmDoc = ThisApplication.ActiveDocument
Dim asmDef As AssemblyComponentDefinition
Set asmDef = asmDoc.ComponentDefinition
Dim oOcc As ComponentOccurrence
Set oOcc = asmDoc.SelectSet(1)
Dim occsub As ComponentOccurrence
Set occsub = oOcc.SubOccurrences.Item(2)
Dim oPartDoc As PartDocument
Set oPartDoc = occsub.Definition.Document
Dim oFace2 As face
Set oFace2 = oPartDoc.AttributeManager.FindObjects(, , "Jointface")(1)
Dim oAdoc As AssemblyDocument
Set oAdoc = oOcc.Definition.Document
Dim oFace1 As Edge
Set oFace1 = ThisApplication.CommandManager.Pick(kPartEdgeCircularFilter, "select a hole")
' Create two intents to define the geometry for the connection.
Dim intentOne As GeometryIntent
Set intentOne = asmDef.CreateGeometryIntent(oFace1, PointIntentEnum.kCenterPointIntent)
Dim intentTwo As GeometryIntent
Set intentTwo = asmDef.CreateGeometryIntent(oFace2, PointIntentEnum.kPlanarFaceCenterPointIntent)
' Create a rigid connection between the two parts.
Dim connectDef As AssemblyJointDefinition
Set connectDef = asmDef.Joints.CreateAssemblyJointDefinition(kRigidConnectionType, intentTwo, intentOne)
connectDef.FlipAlignmentDirection = False
connectDef.FlipOriginDirection = False
Dim connect As AssemblyJoint
Set connect = asmDef.Joints.Add(connectDef)
' Make the connection visible.
connect.Visible = False
End Sub
Thanks in advance and kind regards,
Peter
Solved! Go to Solution.