Exemple #1
0
        private static Snap.Geom.Transform GetTrans(Snap.Position pos, ProbeData.AB ab)
        {
            var trans = Snap.Geom.Transform.CreateRotation(pos, -Snap.Orientation.Identity.AxisX, ab.A);

            trans = Snap.Geom.Transform.Composition(trans, Snap.Geom.Transform.CreateRotation(pos, -Snap.Orientation.Identity.AxisZ, -ab.B));
            return(trans);
        }
Exemple #2
0
        /// <summary>
        /// 获取球心
        /// </summary>
        public Snap.Position GetCentreOfSphere(ProbeData.AB ab)
        {
            var sphere = GetBody(ab);

            Snap.NX.Face.Sphere sphereFace = sphere.Faces.FirstOrDefault(u => u.IsHasAttr(Business.EACTPROBESPHEREFACE)) as Snap.NX.Face.Sphere;
            return(sphereFace.Geometry.Center);
        }
Exemple #3
0
        /// <summary>
        /// 获取干涉数据
        /// </summary>
        public List <Snap.Position> GetInspectionPoints(ProbeData.AB ab)
        {
            var result = new List <Snap.Position>();
            var sphere = GetBody(ab);

            if (ab != null)
            {
                var str = sphere.GetAttrValue(Business.EACT_PROBEINSPECTIONPOINT);
                result = Newtonsoft.Json.JsonConvert.DeserializeObject <List <Snap.Position> >(str) ?? new List <Snap.Position>();
            }
            return(result);
        }
Exemple #4
0
        /// <summary>
        /// 干涉点检查
        /// </summary>
        public bool CheckInspectionPath(ProbeData.AB ab, List <Snap.Position> inspectionPath, params Snap.NX.NXObject[] inspectionBodies)
        {
            //var mark = Snap.Globals.SetUndoMark(Snap.Globals.MarkVisibility.Invisible, "CheckInspectionPath");
            var reuslt = false;

            try
            {
                if (inspectionBodies.Count() <= 0 && inspectionPath.Count >= 2)
                {
                    return(reuslt);
                }
                var inspectionPoints = GetInspectionPoints(ab);
                var trans            = new List <Snap.Geom.Transform>();
                inspectionPath.ForEach(u => {
                    var tran = Snap.Geom.Transform.CreateTranslation(u - Snap.Position.Origin);
                    trans.Add(tran);
                });

                foreach (var item in inspectionPoints)
                {
                    var listP = new List <Snap.Position>();
                    foreach (var tranItem in trans)
                    {
                        listP.Add(item.Copy(tranItem));
                    }
                    //碰撞检测
                    for (int i = 0; i < listP.Count - 1; i++)
                    {
                        reuslt = SnapEx.Create.Intersect(inspectionBodies, listP[i], listP[i + 1]);
                        if (reuslt)
                        {
                            break;
                        }
                    }

                    if (reuslt)
                    {
                        break;
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                //Snap.Globals.UndoToMark(mark, null);
            }
            return(reuslt);
        }
Exemple #5
0
 /// <summary>
 /// 获取体
 /// </summary>
 public Snap.NX.Body GetBody(ProbeData.AB ab)
 {
     Snap.NX.Body result = null;
     result = Snap.Globals.WorkPart.Bodies.FirstOrDefault(u => u.IsHasAttr(SnapEx.ConstString.CMM_INSPECTION_SPHERE) && u.Name == string.Format("{0}A{1}B{2}", this.ProbeName, ab.A, ab.B));
     return(result);
 }