public void AlterMove(ElectrodeModel model)
        {
            List <Body> bodys = new List <Body>();

            NXOpen.Features.Feature moveFeature    = null;
            NXOpen.Features.Feature patternFeature = null;
            NXOpen.Features.Feature linkedFeature  = null;
            foreach (NXOpen.Features.Feature ft in model.PartTag.Features.ToArray())
            {
                if (ft.FeatureType.Equals("MOVE_OBJECT", StringComparison.CurrentCultureIgnoreCase))
                {
                    moveFeature = ft;
                }
                if (ft.FeatureType.Equals("Pattern Geometry", StringComparison.CurrentCultureIgnoreCase))
                {
                    patternFeature = ft;
                }
                if (ft.FeatureType.Equals("LINKED_BODY", StringComparison.CurrentCultureIgnoreCase))
                {
                    linkedFeature = ft;
                }
            }
            bodys.AddRange(((NXOpen.Features.BodyFeature)linkedFeature).GetBodies());
            bodys.AddRange(((NXOpen.Features.PatternGeometry)patternFeature).GetAssociatedBodies());

            MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", moveFeature as NXOpen.Features.MoveObject, bodys.ToArray());
        }
Beispiel #2
0
        /// <summary>
        /// 更新Pitch
        /// </summary>
        private bool UpdatePitch()
        {
            Part workPart = Session.GetSession().Parts.Work;

            NXOpen.Features.ExtractFace     ext;
            NXOpen.Features.MoveObject      move;
            NXOpen.Features.PatternGeometry patt;
            List <Body> bodys = new List <Body>();
            Body        boolBody;
            List <NXOpen.Features.BooleanFeature> extBools;

            GetExtrudeBooleanBody(out boolBody, out extBools);
            GetFeature(out ext, out move, out patt);
            if (ext == null || move == null || patt == null || boolBody == null)
            {
                return(false);
            }
            if (extBools.Count > 0)
            {
                DeleteObject.Delete(extBools.ToArray());
            }
            bodys.AddRange(ext.GetBodies());
            bodys.AddRange(patt.GetAssociatedBodies());
            try
            {
                MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", move as NXOpen.Features.MoveObject, bodys.ToArray());
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("更新移动错误!" + ex.Message);
                return(false);
            }
            List <Body> bys = eleModel.PartTag.Bodies.ToArray().ToList();

            bys.Remove(boolBody);
            SetHeadColour(newAllInfo.Pitch, newAllInfo.GapValue, bys);
            try
            {
                PartUtils.SetPartWork(AssmbliesUtils.GetPartComp(asm, eleModel.PartTag)[0]);
                Body elebody = BooleanUtils.CreateBooleanFeature(boolBody, false, false, NXOpen.Features.Feature.BooleanType.Unite, bys.ToArray()).GetBodies()[0];
                SetEleColor(elebody);
                PartUtils.SetPartWork(null);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("更新求和错误!" + ex.Message);
                return(false);
            }
            return(true);
        }
Beispiel #3
0
        /// <summary>
        /// 创建体特征
        /// </summary>
        private void CreateBodyFeature(double zHeight)
        {
            List <Body> allbody = new List <Body>();
            Matrix4     mat     = new Matrix4();

            mat.Identity();
            foreach (Face face in GetMaxFaceForWave(waveBodys))
            {
                PullFaceUtils.CreatePullFace(new Vector3d(0, 0, -1), zHeight, face);
            }
            NXOpen.Features.PatternGeometry patt = PatternUtils.CreatePattern(" xNCopies", "xPitchDistance", "yNCopies", " yPitchDistance"
                                                                              , mat, waveBodys); //创建阵列(就是绝对坐标的矩阵)
            allbody.AddRange(patt.GetAssociatedBodies());
            allbody.AddRange(waveBodys);
            MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", null, allbody.ToArray());
        }
        private bool CreatFeeler()
        {
            double z = this.datum.EleHeight;

            try
            {
                this.FeelerBody = ExtrudeUtils.CreateExtrude(new Vector3d(0, 0, 1), "0", z.ToString(), null, sketch.Center).GetBodies()[0];
                MoveObject.CreateMoveObjToXYZ("moveBoxX", "moveBoxY", "moveBoxZ", null, FeelerBody);
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("创建对刀台错误!" + ex.Message);
                return(false);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 创建基准座
        /// </summary>
        private void CreateSeat(double zHeigth, bool zDatum)
        {
            List <Body> bodys = new List <Body>();

            bodys.AddRange(elePart.Model.PartTag.Bodies.ToArray());
            ElectrodeSketchBuilder builder = new ElectrodeSketchBuilder(eleInfo.Preparation[0], eleInfo.Preparation[1], -zHeigth);

            builder.CreateEleSketch();
            NXOpen.Features.Feature ext1 = ExtrudedUtils.CreateExtruded(new Vector3d(0, 0, -1), "0", "2", null, builder.LeiLine);
            NXOpen.Features.Feature ext2 = ExtrudedUtils.CreateExtruded(new Vector3d(0, 0, -1), "2", "20", null, builder.WaiLine);
            if (zDatum)
            {
                NXOpen.Features.Feature ext3 = ExtrudedUtils.CreateExtruded(new Vector3d(0, 0, 1), "0", zHeigth.ToString(), null, builder.Center);
                Body extBody3 = (ext3 as NXOpen.Features.BodyFeature).GetBodies()[0];
                MoveObject.CreateMoveObjToXYZ("moveBoxX", "moveBoxY", "moveBoxZ", null, extBody3);
                bodys.Add(extBody3);
            }
            Body extBody1 = (ext1 as NXOpen.Features.BodyFeature).GetBodies()[0];
            Body extBody2 = (ext2 as NXOpen.Features.BodyFeature).GetBodies()[0];

            CreateChamfer(extBody1.Tag);
            CreateUnite(bodys.ToArray(), extBody1.Tag, extBody2.Tag);
        }
        private bool CreatWave()
        {
            Matrix4 mat = new Matrix4();

            mat.Identity();
            try
            {
                //  Body[] waveBodys = AssmbliesUtils.WaveAssociativeBodys(this.headBodys.ToArray()).GetBodies();
                PullFaceForWave(headBodys);
                NXOpen.Features.PatternGeometry patt = PatternUtils.CreatePattern(" xNCopies", "xPitchDistance", "yNCopies", " yPitchDistance"
                                                                                  , mat, headBodys.ToArray()); //创建阵列(就是绝对坐标的矩阵)
                AllBodys.AddRange(patt.GetAssociatedBodies());
                AllBodys.AddRange(headBodys);
                MoveObject.CreateMoveObjToXYZ("moveX", "moveY", "moveZ", null, AllBodys.ToArray());
                SetHeadColour();
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("创建Part档错误!" + ex.Message);
                return(false);
            }
        }