private void InternalSetPosition(double x, double y, double z) { Inventor.Point newLocation = InventorPersistenceManager.InventorApplication.TransientGeometry.CreatePoint(x, y, z); AssemblyWorkPointDef wpDef = (AssemblyWorkPointDef)InternalWorkPoint.Definition; wpDef.Point = newLocation; }
private InvWorkPoint(double x, double y, double z) { //this.VerifyContextSettings(); AssemblyDocument assDoc = InventorPersistenceManager.ActiveAssemblyDoc; AssemblyComponentDefinition compDef = (AssemblyComponentDefinition)assDoc.ComponentDefinition; Inventor.Point point = InventorPersistenceManager.InventorApplication.TransientGeometry.CreatePoint(x, y, z); Inventor.WorkPoint wp = compDef.WorkPoints.AddFixed(point, false); byte[] refKey = new byte[] { }; //wp.GetReferenceKey(ref refKey, (int)InventorSettings.KeyContext); //wp.GetReferenceKey(ref refKey, (int)ReferenceManager.KeyContext); //ComponentOccurrenceKeys.Add(refKey); //return wp; InternalSetWorkPoint(wp); }
internal void PlaceWorkGeometryForContsraints(PartComponentDefinition layoutComponentDefinition, ComponentOccurrence layoutOccurrence, int moduleNumber) { PartDocument partDoc = (PartDocument)layoutComponentDefinition.Document; ReferenceKeyManager refKeyManager = partDoc.ReferenceKeyManager; //TODO: Property ModuleId can be factored out and _binder.ContextData can be used instead. ModuleId = moduleNumber; for (int i = 0; i < PointObjects.Count; i++) { //Each ModuleObject needs to have its ContextManager set. PointObjects[i].Binder.ContextManager.BindingContextManager = refKeyManager; WorkPoint workPoint; if (PointObjects[i].Binder.GetObjectFromTrace <WorkPoint>(out workPoint)) { Inventor.Point newLocation = PersistenceManager.InventorApplication.TransientGeometry.CreatePoint(InternalModulePoints[i].X, InternalModulePoints[i].Y, InternalModulePoints[i].Z); workPoint.SetFixed(InternalModulePoints[i].ToPoint()); } else { workPoint = layoutComponentDefinition.WorkPoints.AddFixed(InternalModulePoints[i].ToPoint(), false); PointObjects[i].Binder.SetObjectForTrace <WorkPoint>(workPoint, ModuleUtilities.ReferenceKeysSorter); } //workPoint.Visible = false; object workPointProxyObject; layoutOccurrence.CreateGeometryProxy(workPoint, out workPointProxyObject); LayoutWorkPointProxies.Add((WorkPointProxy)workPointProxyObject); LayoutWorkPoints.Add(workPoint); } //If we will have more than 2 constraints, it will help assembly stability later //if we have a plane to constrain to first. if (InternalModulePoints.Count > 2) { WorkPlane workPlane; //TODO: Is this a good idea? Why is this a list? Will we ever have more //than work plane? PlaneObjects[0].Binder.ContextManager.BindingContextManager = refKeyManager; if (PlaneObjects[0].Binder.GetObjectFromTrace <WorkPlane>(out workPlane)) { if (workPlane.DefinitionType == WorkPlaneDefinitionEnum.kThreePointsWorkPlane) { workPlane.SetByThreePoints(LayoutWorkPoints[0], LayoutWorkPoints[1], LayoutWorkPoints[2]); LayoutWorkPlane = workPlane; object wPlaneProxyObject; layoutOccurrence.CreateGeometryProxy(workPlane, out wPlaneProxyObject); LayoutWorkPlaneProxy = (WorkPlaneProxy)wPlaneProxyObject; } } else { //If the first three points are colinear, adding a workplane will fail. We will check the area of a triangle //described by the first three points. If the area is very close to 0, we can assume these points are colinear, and we should //not attempt to construct a work plane from them. Inventor.Point pt1 = LayoutWorkPoints[0].Point; Inventor.Point pt2 = LayoutWorkPoints[1].Point; Inventor.Point pt3 = LayoutWorkPoints[2].Point; if (Math.Abs(pt1.X * (pt2.Y - pt3.Y) + pt2.X * (pt3.Y - pt1.Y) + pt3.X * (pt1.Y - pt2.Y)) > .0000001) { workPlane = layoutComponentDefinition.WorkPlanes.AddByThreePoints(LayoutWorkPoints[0], LayoutWorkPoints[1], LayoutWorkPoints[2], false); PlaneObjects[0].Binder.SetObjectForTrace <WorkPlane>(workPlane, ModuleUtilities.ReferenceKeysSorter); workPlane.Grounded = true; //workPlane.Visible = false; LayoutWorkPlane = workPlane; object wPlaneProxyObject; layoutOccurrence.CreateGeometryProxy(workPlane, out wPlaneProxyObject); LayoutWorkPlaneProxy = (WorkPlaneProxy)wPlaneProxyObject; } } } }
private InvPoint(Inventor.Point invPoint) { InternalPoint = invPoint; }
public static InvPoint ByInvPoint(Inventor.Point invPoint) { return(new InvPoint(invPoint)); }