/// <summary> /// 创建探针 /// </summary> Snap.NX.Body CreateProbe(ProbeData data) { Snap.NX.CoordinateSystem wcs = Globals.WorkPart.NXOpenPart.WCS.CoordinateSystem; var vector = wcs.AxisZ; var position = new Snap.Position(0, 0, data.SphereRadius); //创建探球 var body = Snap.Create.Sphere(position, data.SphereRadius * 2).Body; //创建测针 var body1 = Snap.Create.Cylinder(position, position + (data.ArrowLength * vector), data.ArrowRadius * 2).Body; body1.IsHidden = true; position = position + (data.ArrowLength * vector); //创建加长杆 var body2 = Snap.Create.Cylinder(position, position + (data.ExtensionBarLength * vector), data.ExtensionBarRadius * 2).Body; body2.IsHidden = true; //创建测头 position = position + (data.ExtensionBarLength * vector); var body3 = Snap.Create.Cylinder(position, position + (data.HeadLength * vector), data.HeadRadius * 2).Body; body3.IsHidden = true; var r = Snap.Create.Unite(body, body1, body2, body3); r.Orphan(); return(body); }
public static Vector MapCsysToCsys(Vector inputVector, Snap.NX.CoordinateSystem inputCsys, Snap.NX.CoordinateSystem outputCsys) { Vector axisX = inputCsys.AxisX; Vector axisY = inputCsys.AxisY; Vector axisZ = inputCsys.AxisZ; Vector vector4 = (Vector)(((inputVector.X * axisX) + (inputVector.Y * axisY)) + (inputVector.Z * axisZ)); double x = (double)(vector4 * outputCsys.AxisX); double y = (double)(vector4 * outputCsys.AxisY); return(new Vector(x, y, (double)(vector4 * outputCsys.AxisZ))); }
internal static Snap.NX.NXObject CreateNXObject(TaggedObject nxopenTaggedObject) { Snap.NX.NXObject obj2 = null; NXOpen.NXObject nxopenObject = nxopenTaggedObject as NXOpen.NXObject; if (nxopenObject != null) { obj2 = new Snap.NX.NXObject(nxopenObject); NXOpen.Curve nxopenCurve = nxopenObject as NXOpen.Curve; if (nxopenCurve != null) { obj2 = Snap.NX.Curve.CreateCurve(nxopenCurve); } switch (GetTypeFromTag(nxopenObject.Tag)) { case ObjectTypes.Type.Point: obj2 = new Snap.NX.Point((NXOpen.Point)nxopenObject); break; case ObjectTypes.Type.DatumPlane: obj2 = new Snap.NX.DatumPlane((DatumPlaneFeature)nxopenObject); break; case ObjectTypes.Type.DatumAxis: obj2 = new Snap.NX.DatumAxis((DatumAxisFeature)nxopenObject); break; case ObjectTypes.Type.CoordinateSystem: obj2 = new Snap.NX.CoordinateSystem((NXOpen.CoordinateSystem)nxopenObject); break; case ObjectTypes.Type.Body: obj2 = new Snap.NX.Body((NXOpen.Body)nxopenObject); break; case ObjectTypes.Type.Face: obj2 = Snap.NX.Face.CreateFace((NXOpen.Face)nxopenObject); break; case ObjectTypes.Type.Edge: obj2 = Snap.NX.Edge.CreateEdge((NXOpen.Edge)nxopenObject); break; case ObjectTypes.Type.Feature: obj2 = Snap.NX.Feature.CreateFeature((NXOpen.Features.Feature)nxopenObject); break; case ObjectTypes.Type.Component: return(new Snap.NX.Component((NXOpen.Assemblies.Component)nxopenObject)); } } return(obj2); }
public static Snap.Position MapCsysToCsys(Snap.Position inputCoords, Snap.NX.CoordinateSystem inputCsys, Snap.NX.CoordinateSystem outputCsys) { Snap.Position origin = inputCsys.Origin; Vector axisX = inputCsys.AxisX; Vector axisY = inputCsys.AxisY; Vector axisZ = inputCsys.AxisZ; Snap.Position position2 = (Snap.Position)(((origin + (inputCoords.X * axisX)) + (inputCoords.Y * axisY)) + (inputCoords.Z * axisZ)); Vector vector4 = (Vector)(position2 - outputCsys.Origin); double x = (double)(vector4 * outputCsys.AxisX); double y = (double)(vector4 * outputCsys.AxisY); return(new Snap.Position(x, y, (double)(vector4 * outputCsys.AxisZ))); }