/// <summary> /// 创建包容块 /// </summary> public static Snap.NX.Block Box(List <Face> faces, double positiveX, double negativeX, double positiveY, double negativeY, double positiveZ, double negativeZ) { Session theSession = Session.GetSession(); Part workPart = theSession.Parts.Work; var box = GetBox3d(faces); box = new Snap.Geom.Box3d(box.MinX - negativeX, box.MinY - negativeY, box.MinZ - negativeZ, box.MaxX + positiveX, box.MaxY + positiveY, box.MaxZ + positiveZ); var block = Snap.Create.Block(box.MinXYZ, box.MaxX - box.MinX, box.MaxY - box.MinY, box.MaxZ - box.MinZ); return(block); }
public static Snap.Geom.Box3d AcsToWcsBox3d(Snap.Geom.Box3d box, Snap.Orientation wcs) { var corners = new List <Snap.Position>(); box.Corners.ToList().ForEach(u => { var acsOrientation = Snap.Orientation.Identity; var wcsOrientation = wcs; var transR = Snap.Geom.Transform.CreateRotation(acsOrientation, wcsOrientation); corners.Add(u.Copy(transR)); }); var xList = Enumerable.Select(corners, u => u.X).ToList(); var yList = Enumerable.Select(corners, u => u.Y).ToList(); var zList = Enumerable.Select(corners, u => u.Z).ToList(); return(new Snap.Geom.Box3d(xList.Min(), yList.Min(), zList.Min(), xList.Max(), yList.Max(), zList.Max())); }
/// <summary> /// 获取BOX /// </summary> /// <param name="face"></param> /// <returns></returns> public static Snap.Geom.Box3d BoxEx(this Snap.NX.Face face) { int surfaceType; double radius1; double radius2; int normalFlip; double[] point = new double[3]; double[] dir = new double[3]; double[] box = new double[6]; try { NXOpen.UF.UFSession uFSession = NXOpen.UF.UFSession.GetUFSession(); uFSession.Modl.AskFaceData(face.NXOpenTag, out surfaceType, point, dir, box, out radius1, out radius2, out normalFlip); var faceBox = new Snap.Geom.Box3d(box[0], box[1], box[2], box[3], box[4], box[5]); return(faceBox); } catch (Exception ex) { Console.WriteLine(ex.Message); return(face.Box); } }
public void Init(ElecManage.Electrode ele, CNCConfig.CAMConfig camConfig) { CamConfig = camConfig; Electrode = ele; var body = ele.ElecBody; var basePos = ele.GetElecBasePos(); var eleInfo = ele.GetElectrodeInfo(); BodyBox = body.Box; //分析面 var faces = ele.ElecBody.Faces; double judgeValue = 15; var camFaces = new List <CAMFace>(); ele.ElecHeadFaces.ForEach(u => { camFaces.Add(new CAMFace { FaceTag = u.NXOpenTag, DraftAngle = u.GetDraftAngle() }); }); //基准面 AllBaseFaces = faces.Where(u => camFaces.FirstOrDefault(m => m.FaceTag == u.NXOpenTag) == null).ToList(); //垂直面 VerticalFaces = camFaces.Where(u => u.DraftAngle == 0 //&& u.GetSnapFace().ObjectSubType == Snap.NX.ObjectTypes.SubType.FacePlane ).ToList(); //水平面 HorizontalFaces = camFaces.Where(u => u.DraftAngle == 90 && u.GetSnapFace().ObjectSubType == Snap.NX.ObjectTypes.SubType.FacePlane ).ToList(); //平缓面(等高面) GentleFaces = camFaces.Where(u => (u.DraftAngle >= judgeValue && u.DraftAngle < 90) || (u.DraftAngle == 90 && u.GetSnapFace().ObjectSubType != Snap.NX.ObjectTypes.SubType.FacePlane) ).ToList(); //陡峭面 var steepFaces = camFaces.Where(u => (u.DraftAngle < judgeValue && u.DraftAngle > 0) //|| //(u.DraftAngle == 0 && u.GetSnapFace().ObjectSubType != Snap.NX.ObjectTypes.SubType.FacePlane) ).ToList(); //倒扣面 ButtonedFaces = camFaces.Where(u => u.DraftAngle < 0).ToList(); //非平面 var nonPlanefaces = ele.ElecHeadFaces.Where(u => u.ObjectSubType != Snap.NX.ObjectTypes.SubType.FacePlane).ToList(); //设置基准面颜色 AllBaseFaces.ForEach(u => { CAMFace.SetColor(camConfig.BaseFaceColor, u.NXOpenTag); }); //设置垂直面颜色 VerticalFaces.ForEach(u => { u.SetColor(camConfig.VerticalPlaneColor); }); //设置水平面颜色 HorizontalFaces.ForEach(u => { u.SetColor(camConfig.HorizontalPlaneColor); }); //设置平缓面颜色 GentleFaces.ForEach(u => { u.SetColor(camConfig.GentlePlaneColor); }); //设置陡峭面颜色 steepFaces.ForEach(u => { u.SetColor(camConfig.CurveSurfaceColor); }); //倒扣面 ButtonedFaces.ForEach(u => { u.SetColor(camConfig.ButtonedFaceColor); }); //分析方案 CamScheme = E_CamScheme.SIMPLE; }