Hi,
I'm trying to create a rigid joint between two faces on two occurrences, using the centre point of each face. I understand you need a GeometryIntent object for each face, and the 'Intent' parameter specifies the position on the face - however I've tried using a Point object (and also a Point2D object) for the 'Intent' parameter with no success - it errors out on the CreateAssemblyJointDefinition.
In the code below - I've already got 2 FaceProxy objects, and a Point object on the centre of each face.
Can anyone point me in the right direction?
I know that joints are new in Inventor 2014, but it would probably be useful to have another example or two in the API help if possible.
Many thanks
' Note - oPoint1 and oPoint2 are the Point objects (X Y Z in assembly coordinates)
' Create an intent to the center of Face1proxy
Dim oFaceProxy1Intent As GeometryIntent oFaceProxy1Intent = oDef.CreateGeometryIntent(oFaceProxy1, oPoint1) ' Create an intent to the center of Face2proxy
Dim oFaceProxy2Intent As GeometryIntent oFaceProxy2Intent = oDef.CreateGeometryIntent(oFaceProxy2, oPoint2) ' Create two intents to define the geometry for the connection.
Dim intentOne As GeometryIntent intentOne = oDef.CreateGeometryIntent(oFaceProxy1, oFaceProxy1Intent) Dim intentTwo As GeometryIntent intentTwo = oDef.CreateGeometryIntent(oFaceProxy2, oFaceProxy2Intent) ' Create a rigid jont between the two parts.Dim jointDef As AssemblyJointDefinition jointDef = oDef.Joints.CreateAssemblyJointDefinition(AssemblyJointTypeEnum.kRigidJointType, intentOne, intentTwo) jointDef.FlipAlignmentDirection = False jointDef.FlipOriginDirection = False Dim Joint As AssemblyJoint Joint = oDef.Connections.Add(jointDef) ' Make the joint visible.
Joint.Visible = True
Can anyone point me in the right direction for this? I'm sure this must be a fairly common requirement - a rigid joint between the centre of two faces....
Many thanks for your attention.
Hi Luke,
Could you attach your datatset so I can investigate your issue? Just attach ZIP file that includes assembly and all necessary part files as you show on attached pictures. If you have also video it would be great to attach it as well.
Thanks,
Robert
Hi Robert,
Thanks for the reply. Zipped folder attached. Contains the assembly, and a 30 second video.
The iLogic rule to create the rigid joint is already in the assembly file.
Many thanks,
Luke
Excellent.
I will contact you back with my findings over end of this week.
Thanks,
Robert
Let's see what Robert finds, but here is a sample based on another dataset, it should be rather straightforward for you to get it working with your assembly:
' This sample demonstrates creating an assembly connection. It connects the ' centers of two faces using a rigid connection. The part SamplePart.ipt must ' be used because the sample assumes there are iMates in the part which it ' used to find specific geometry. Public Sub AssemblyConnect() ' Create a new assembly document. Dim asmDoc As AssemblyDocument Set asmDoc = ThisApplication.Documents.Add(kAssemblyDocumentObject, _ ThisApplication.FileManager.GetTemplateFile(kAssemblyDocumentObject)) Dim asmDef As AssemblyComponentDefinition Set asmDef = asmDoc.ComponentDefinition ' Place an occurrence into the assembly. Dim occ1 As ComponentOccurrence Dim occ2 As ComponentOccurrence Dim trans As Matrix Set trans = ThisApplication.TransientGeometry.CreateMatrix Set occ1 = asmDef.Occurrences.Add("C:\Users\ekinsb\Documents\Presentations\AU 2012\Inventor 2014\SamplePart.ipt", trans) ' Place a second occurrence with the matrix adjusted so it fits correctly with the first occurrence. trans.Cell(1, 4) = 6 * 2.54 Set occ2 = asmDef.Occurrences.Add("C:\Users\ekinsb\Documents\Presentations\AU 2012\Inventor 2014\SamplePart.ipt", trans) ' Get Face 6 from occ1 and create a FaceProxy. Dim face1 As Face Set face1 = GetNamedEntity(occ1, "Face6") Dim face2 As Face Set face2 = GetNamedEntity(occ2, "Face7") ' Create two intents to define the geometry for the connection. Dim intentOne As GeometryIntent Set intentOne = asmDef.CreateGeometryIntent(face1, PointIntentEnum.kPlanarFaceCenterPointIntent) Dim intentTwo As GeometryIntent Set intentTwo = asmDef.CreateGeometryIntent(face2, PointIntentEnum.kPlanarFaceCenterPointIntent) ' Create a rigid connection between the two parts. Dim connectDef As AssemblyConnectionDefinition Set connectDef = asmDef.Connections.CreateAssemblyConnectionDefinition(kRigidConnectionType, intentOne, intentTwo) connectDef.FlipAlignmentDirection = False connectDef.FlipOriginDirection = True Dim connect As AssemblyConnection Set connect = asmDef.Connections.Add(connectDef) ' Make the connection visible. connect.Visible = True End Sub
' This finds the entity associated with an iMate of a specified name. This
' allows iMates to be used as a generic naming mechansim.
Private Function GetNamedEntity(Occurrence As ComponentOccurrence, Name As String) As Object
' Look for the iMate that has the specified name in the referenced file.
Dim iMate As iMateDefinition
Dim partDef As PartComponentDefinition
Set partDef = Occurrence.Definition
For Each iMate In partDef.iMateDefinitions
' Check to see if this iMate has the correct name.
If UCase(iMate.Name) = UCase(Name) Then
' Get the geometry assocated with the iMate.
Dim entity As Object
Set entity = iMate.entity
' Create a proxy.
Dim resultEntity As Object
Set resultEntity = Nothing
Call Occurrence.CreateGeometryProxy(entity, resultEntity)
Exit For
End If
Next
' Return the found entity, or Nothing if a match wasn't found.
Set GetNamedEntity = resultEntity
End Function
Regards,
Philippe.
Philippe already gave you requested answer. This is an example from joint API tutorial that places joint origins at center of planar face.
Let's take a look closer.
As you can see in Joint command when executed from UI, Inventor allows you to define joint origin on planar face only at limited set of points. Supported are:
• Linear edge or sketch line on which the start/mid/end point can be specified as origin. The direction of the linear object defines the origin direction.
• Circular/elliptical edge or sketch entity which the center will be used as origin. The normal of the object defines the origin direction.
• Cylindrical/conical/elliptical-cylindrical face which the start/mid/end point on the axis of the face can be specified as origin. The axis of the face defines the origin direction.
• Toroidal/spherical face which the center will be used as origin. The axis of the toroidal face defines the origin direction.
• Planar face that has linear/circular/elliptical edges which the start/mid/end point of linear edge or center of circular/elliptical edge can be specified as origin. The normal of the planar face defines the origin direction.
Each of these supported points is constrained to the geometry that the point belongs to. For example edge mid point preserves its position in the mid of the edge curve even if edge changes its size.
This is the reason why you can't specify an arbitrary point as geometry intent. The origin point can't be defined by exact coordinates ignoring internal constraints to jointed geometry.
Here are supported values for object of PointIntentEnum type:
kAxisStartPointIntent
kAxisMidPointIntent
kAxisEndPointIntent
kPlanarFaceCenterPointIntent
If you have more questions feel free to ask.
Robert