One focus of the 2014 release is “Ease of use”. An example of this is the new Joint command that will definitely make it easier to make relationships between parts in an assembly. This command is on the Assemble tab next to Constrain.
When you run this command new graphic feedback shows you where the joints could be added before you add the joint.
API Support for Joints
The API also supports Joints. Here are several of the new classes, new method and an enum related to Joints.
AssemblyJoint, AssemblyJointDefinition
AssemblyComponentDefinition.Joints (collection)
AssemblyJointTypeEnum, CreateAssemblyJointDefinition
You use an AssemblyJointDefinition as input to create a joint. To create this use the CreateAssemblyJointDefinition method of the Joints collection. (Property of the AssemblyComponentDefinition) This method takes a Joint Type and two GeometryIntent objects. If you have used the API to create drawing annotations you will be familiar with GeometryIntent objects. To create the joint use the Add method of the Joints collection.
Below are the functions from this C# example that create a joint. (zip includes the ipt) This example was converted to C# from the VBA example in the help file. After you run the example you will see a new assembly with two components that share a joint.
I dragged the part (rotated) to show the joint.
C# functions:
public void AssemblyJoint()
{
// Create a new assembly document.
AssemblyDocument asmDoc =
(AssemblyDocument)ThisApplication.Documents.Add
(DocumentTypeEnum.kAssemblyDocumentObject,
ThisApplication.FileManager.GetTemplateFile
(DocumentTypeEnum.kAssemblyDocumentObject));
AssemblyComponentDefinition asmDef =
asmDoc.ComponentDefinition;
Matrix trans =
ThisApplication.TransientGeometry.CreateMatrix();
// Place an occurrence into the assembly.
ComponentOccurrence occ1 =
asmDef.Occurrences.Add
("C:\\Inventor2014APISamples\\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;
ComponentOccurrence occ2 =
asmDef.Occurrences.Add
("C:\\Inventor2014APISamples\\SamplePart.ipt",
trans);
// Get Face 1 from occ1 and
// create a FaceProxy.
Face face1 =
(Face)GetNamedEntity(occ1, "Face1");
// Get Face 2 from occ2 and
// create a FaceProxy.
Face face2 =
(Face)GetNamedEntity(occ2, "Face2");
// Get Edge 1 from occ2 and
// create an EdgeProxy.
Edge Edge1 =
(Edge)GetNamedEntity(occ2, "Edge1");
// Get Edge 3 from occ1 and
// create an EdgeProxy.
Edge Edge3 =
(Edge)GetNamedEntity(occ1, "Edge3");
// Create an intent to the
// center of Edge1.
GeometryIntent edge1Intent =
asmDef.CreateGeometryIntent
(Edge1, PointIntentEnum.kMidPointIntent);
// Create an intent to the center of Edge3.
GeometryIntent edge3Intent =
asmDef.CreateGeometryIntent
(Edge3, PointIntentEnum.kMidPointIntent);
// Create two intents to define
// the geometry for the joint.
GeometryIntent intentOne =
asmDef.CreateGeometryIntent
(face2, edge1Intent);
GeometryIntent intentTwo =
asmDef.CreateGeometryIntent
(face1, edge3Intent);
// Create a rotation joint between the two parts.
AssemblyJointDefinition jointDef =
asmDef.Joints.CreateAssemblyJointDefinition
(AssemblyJointTypeEnum.kRotationalJointType,
intentOne, intentTwo);
jointDef.FlipAlignmentDirection = false;
jointDef.FlipOriginDirection = true;
AssemblyJoint joint =
asmDef.Joints.Add(jointDef);
// Make the joint visible.
joint.Visible = true;
// Drive the joint to animate it.
joint.DriveSettings.StartValue = "0 deg";
joint.DriveSettings.EndValue = "180 deg";
joint.DriveSettings.GoToStart();
joint.DriveSettings.PlayForward();
joint.DriveSettings.PlayReverse();
}
// This finds the entity associated with
// an iMate of a specified name. This
// allows iMates to be used as a generic
// naming mechansim.
private object GetNamedEntity
(ComponentOccurrence Occurrence, string Name)
{
// Look for the iMate that has the
// specified name in the referenced file.
PartComponentDefinition partDef =
(PartComponentDefinition)Occurrence.Definition;
object resultEntity = null;
resultEntity = null;
foreach (iMateDefinition iMate
in partDef.iMateDefinitions)
{
// Check to see if this iMate has
// the correct name
if (iMate.Name.ToUpper() ==
Name.ToUpper())
{
// Get the geometry associated
// with the iMate. Using InvokeMember
// because the iMateDefinition is the
// base class and does not have an
// Entity property
object entity = null;
entity = iMate.GetType().InvokeMember
("Entity",
BindingFlags.GetProperty,
null, iMate, null);
// Create a proxy.
Occurrence.CreateGeometryProxy
(entity, out resultEntity);
break;
}
}
// Return the found entity, or Nothing
// if a match wasn't found.
return resultEntity;
}
-Wayne