Пример #1
0
        /// <summary>
        /// 创建外形点
        /// </summary>
        /// <returns></returns>
        private Point[] CreateMinAndMaxPt()
        {
            UFSession theUFSession = UFSession.GetUFSession();

            Point[] pt       = new Point[2];
            Point3d centerPt = new Point3d();
            Point3d disPt    = new Point3d();

            List <Body> bodys = new List <Body>();

            foreach (Body body in this.workpiece.Bodies.ToArray())
            {
                bodys.Add(AssmbliesUtils.GetNXObjectOfOcc(this.workpieceComp.Tag, body.Tag) as Body);
            }
            //  Body[] bodys = this.workpiece.Bodies.ToArray();
            Matrix4 invers = this.work.WorkMatr.GetInversMatrix();
            CartesianCoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(this.work.WorkMatr, invers);//坐标

            BoundingBoxUtils.GetBoundingBoxInLocal(bodys.ToArray(), csys, this.work.WorkMatr, ref centerPt, ref disPt);
            this.CenterPt = centerPt;
            this.DisPt    = disPt;
            Point3d minPt = new Point3d(centerPt.X - disPt.X, centerPt.Y - disPt.Y, centerPt.Z - disPt.Z);
            Point3d maxPt = new Point3d(centerPt.X + disPt.X, centerPt.Y + disPt.Y, centerPt.Z + disPt.Z);

            invers.ApplyPos(ref maxPt);
            invers.ApplyPos(ref minPt);
            // PartUtils.SetPartWork(workpieceComp);
            pt[0] = PointUtils.CreatePoint(minPt);
            theUFSession.Obj.SetLayer(pt[0].Tag, 254);
            pt[1] = PointUtils.CreatePoint(maxPt);
            theUFSession.Obj.SetLayer(pt[1].Tag, 254);
            // PartUtils.SetPartWork(null);
            return(pt);
        }
Пример #2
0
        /// <summary>
        /// 复制电极
        /// </summary>
        /// <param name="eleCt"></param>
        /// <param name="workPt"></param>
        /// <returns></returns>
        public List <string> LoadEle(NXOpen.Assemblies.Component eleCt, Part workPt)
        {
            Matrix3x3     mat;
            Point3d       setPt;
            List <string> err = new List <string>();

            eleCt.GetPosition(out setPt, out mat);
            ElectrodeSetValueInfo setValue = ElectrodeSetValueInfo.GetAttribute(eleCt);

            NXOpen.PartLoadStatus partLoadStatus1 = null;
            string partPath = (eleCt.Prototype as Part).FullPath;

            try
            {
                NXOpen.Assemblies.Component copyCt = workPt.ComponentAssembly.AddComponent(partPath, "None", eleCt.Name, setPt, mat, -1, out partLoadStatus1, true);
                NXObject obj   = AssmbliesUtils.GetOccOfInstance(copyCt.Tag);
                bool     attOk = setValue.SetAttribute(obj);
                AttributeUtils.AttributeOperation("EleComponentCopy", 1, obj);
                if (!attOk)
                {
                    err.Add("写入属性错误!");
                }
            }
            catch (NXException ex)
            {
                err.Add(eleCt.Name + "复制电极错误!           " + ex.Message);
            }
            return(err);
        }
Пример #3
0
 public WorkpieceInfo(Part workpiece, WorkModel work)
 {
     this.workpiece = workpiece;
     this.work      = work;
     workpieceComp  = AssmbliesUtils.GetPartComp(this.work.PartTag, this.workpiece);
     this.poin      = CreateMinAndMaxPt();
 }
Пример #4
0
        /// <summary>
        /// 保存坐标
        /// </summary>
        /// <param name="asm"></param>
        /// <returns></returns>
        public bool SaveCsys(Part asm)
        {
            UFSession theUFSession = UFSession.GetUFSession();

            try
            {
                PartUtils.SetPartDisplay(asm);
                List <NXOpen.Assemblies.Component> ct = AssmbliesUtils.GetPartComp(asm, this.PartTag);
                CsysUtils.SetWcsOfCenteAndMatr(this.Info.Matr.GetCenter(), this.Info.Matr.GetMatrix3());
                PartUtils.SetPartWork(ct[0]);
                CartesianCoordinateSystem csys = asm.WCS.Save();
                string name   = "WORK" + this.Info.WorkNumber.ToString();
                Tag    objTag = Tag.Null;
                theUFSession.Obj.CycleByName(name, ref objTag);
                if (objTag != Tag.Null)
                {
                    theUFSession.Obj.DeleteObject(objTag);
                }
                csys.Name  = name;
                csys.Layer = 200;
                csys.Color = 186;
                PartUtils.SetPartWork(null);
                CsysUtils.SetWcsToAbs();
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("创建坐标错误" + ex.Message);
                return(false);
            }
        }
Пример #5
0
        private void GetWorkPieceComp()
        {
            Part host = Work.GetHostWorkpiece();

            if (host == null)
            {
                throw new Exception("无法找到主工件!");
            }
            foreach (NXOpen.Assemblies.Component ct in AssmbliesUtils.GetPartComp(workPart, host))
            {
                if (!ct.IsSuppressed)
                {
                    ct.Unblank();
                    this.HostComp.Add(ct);
                }
            }
            foreach (Part pt in Work.GetAllWorkpiece())
            {
                if (!host.Equals(pt))
                {
                    foreach (NXOpen.Assemblies.Component ct in AssmbliesUtils.GetPartComp(workPart, pt))
                    {
                        ct.Unblank();
                        OtherComp.Add(ct);
                    }
                }
            }
            this.OtherComp.Sort(delegate(NXOpen.Assemblies.Component a, NXOpen.Assemblies.Component b)
            {
                return(a.Name.CompareTo(b.Name));
            });
        }
        /// <summary>
        /// 移动
        /// </summary>
        /// <param name="vec"></param>
        /// <returns></returns>
        public bool MovePositionBuilder(Vector3d vec)
        {
            try
            {
                Matrix4 inv = this.work.Info.Matr.GetInversMatrix();
                CartesianCoordinateSystem csys        = BoundingBoxUtils.CreateCoordinateSystem(this.work.Info.Matr, inv);
                ElectrodeSetValueInfo     setValue    = ElectrodeSetValueInfo.GetAttribute(eleComp);
                ElectrodeSetValueInfo     newSetValue = setValue.Clone() as ElectrodeSetValueInfo;

                AssmbliesUtils.MoveCompPart(eleComp, vec, work.Info.Matr);
                NXObject instance = AssmbliesUtils.GetOccOfInstance(eleComp.Tag);
                BodyInfo info     = GetDischargeFace(csys, eleComp);
                newSetValue.EleSetValue[0]    = setValue.EleSetValue[0] + vec.X;
                newSetValue.EleSetValue[1]    = setValue.EleSetValue[1] + vec.Y;
                newSetValue.EleSetValue[2]    = setValue.EleSetValue[2] + vec.Z;
                newSetValue.Positioning       = GetPositionName();
                newSetValue.PositioningRemark = "设定值改变";
                if (info != null)
                {
                    newSetValue.ContactArea   = info.ContactArea;
                    newSetValue.ProjectedArea = info.GetProjectedArea(csys, this.work.Info.Matr);
                }
                newSetValue.SetAttribute(instance);
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("电极跑位错误!" + ex.Message);
                return(false);
            }
        }
Пример #7
0
        /// <summary>
        /// 获取EDM下面工件
        /// </summary>
        /// <returns></returns>
        public List <Part> GetWorkPieces()
        {
            List <Part> parts = new List <Part>();

            foreach (Part pt in coll.Other)
            {
                try
                {
                    List <NXOpen.Assemblies.Component> ct = AssmbliesUtils.GetPartComp(this.workModel.PartTag, pt);
                    if (ct.Count > 0)
                    {
                        parts.Add(pt);
                    }
                }
                catch
                {
                }
            }
            parts.Sort(delegate(Part a, Part b)
            {
                return(a.Name.CompareTo(b.Name));
            }
                       );
            return(parts);
        }
        public NXObject Move(params NXObject[] objs)
        {
            if (user.UserSucceed && user.Jurisd.GetComm())
            {
                List <NXOpen.Assemblies.Component> cts = new List <NXOpen.Assemblies.Component>();

                foreach (NXObject obj in objs)
                {
                    if (obj is NXOpen.Assemblies.Component)
                    {
                        cts.Add(obj as NXOpen.Assemblies.Component);
                    }
                }
                Matrix4 mat = new Matrix4();
                mat.Identity();
                mat.TransformToCsys(csys, ref mat);
                try
                {
                    AssmbliesUtils.MoveCompPartForCsys(mat, cts.ToArray());
                    return(null);
                }
                catch (NXException ex)
                {
                    UI.GetUI().NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "无法移动--" + ex.Message);
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
Пример #9
0
        /// <summary>
        /// 干涉面
        /// </summary>
        public void GetInterferenceOfFace()
        {
            List <Tag>  outFace       = new List <Tag>();
            Body        eleBody       = GetOccsInBods(this.eleModel.PartTag)[0];
            Body        workpieceBody = GetOccsInBods(this.workpiece)[0];
            List <Face> faces         = AnalysisUtils.SetInterferenceOutFace(eleBody, workpieceBody);

            for (int i = 0; i < (faces.Count) / 2 - 1; i++)
            {
                FaceData data1 = FaceUtils.AskFaceData(faces[i * 2]);
                FaceData data2 = FaceUtils.AskFaceData(faces[i * 2 + 1]);
                if (data1.Equals(data2))
                {
                    Tag face3;
                    NXOpen.Features.Feature feat1 = AssmbliesUtils.WaveFace(faces[i * 2]);
                    NXOpen.Features.Feature feat2 = AssmbliesUtils.WaveFace(faces[i * 2 + 1]);
                    Body[] bodys1 = (feat1 as NXOpen.Features.BodyFeature).GetBodies();
                    Body[] bodys2 = (feat2 as NXOpen.Features.BodyFeature).GetBodies();

                    Tag bodyTag1 = Intersect(bodys1[0], bodys2[0]);
                    if (bodyTag1 != Tag.Null)
                    {
                        outFace.Add(bodyTag1);
                    }
                }
            }
            SewSolidBody(outFace);
        }
Пример #10
0
        public NXOpen.Assemblies.Component[] GetEleHideComp()
        {
            Part workPart = theSession.Parts.Work;
            List <NXOpen.Assemblies.Component> hide = new List <NXOpen.Assemblies.Component>();
            Part workpiece = GetWorkpiecePart();

            foreach (NXOpen.Assemblies.Component workComp in workPart.ComponentAssembly.RootComponent.GetChildren())
            {
                workComp.Blank();
                foreach (NXOpen.Assemblies.Component ct in workComp.GetChildren())
                {
                    ct.Unblank();
                    NXOpen.Assemblies.Component[] edm = ct.GetChildren();
                    if (edm.Length != 0)
                    {
                        hide.Add(ct);
                        foreach (NXOpen.Assemblies.Component workpieceComp in edm)
                        {
                            workpieceComp.Unblank();
                            hide.Add(workpieceComp);
                        }
                    }
                    else
                    {
                        hide.Add(ct);
                    }
                }
            }

            NXOpen.Assemblies.Component eleComp = AssmbliesUtils.GetPartComp(workPart, EleModel.PartTag);
            hide.Remove(eleComp);
            return(hide.ToArray());
        }
Пример #11
0
        private void GetBoundingBox()
        {
            Point3d     centerPt = new Point3d();
            Point3d     disPt    = new Point3d();
            Part        workPart = Session.GetSession().Parts.Work;
            List <Body> bodys    = new List <Body>();

            //  NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(workPart, part)[0];
            foreach (NXOpen.Assemblies.Component ct in AssmbliesUtils.GetPartComp(workPart, part))
            {
                if (!ct.IsSuppressed)
                {
                    foreach (Body body in this.part.Bodies.ToArray())
                    {
                        bodys.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, body.Tag) as Body);
                    }
                }
            }
            Matrix4 invers = workMatr.GetInversMatrix();
            CartesianCoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(workMatr, invers);//坐标

            BoundingBoxUtils.GetBoundingBoxInLocal(bodys.ToArray(), csys, workMatr, ref centerPt, ref disPt);
            LayerUtils.MoveDisplayableObject(201, bodys.ToArray());
            this.CenterPt = centerPt;
            this.DisPt    = disPt;
        }
Пример #12
0
        /// <summary>
        /// 更新图纸
        /// </summary>
        /// <returns></returns>
        private bool UpdeteDrawing(Part part)
        {
            Part workPart = Session.GetSession().Parts.Work;

            if (oldCt != null && newCt != null)
            {
                PartUtils.SetPartDisplay(part);
                foreach (NXOpen.Drawings.DrawingSheet ds in part.DrawingSheets)
                {
                    ds.Open();
                    foreach (NXOpen.Drawings.DraftingView dv in ds.GetDraftingViews())
                    {
                        Basic.DrawingUtils.HideComponent(dv, AssmbliesUtils.GetPartComp(workPart, oldCt));
                        Basic.DrawingUtils.ShowComponent(dv, AssmbliesUtils.GetPartComp(workPart, newCt));
                        dv.Update();
                    }
                }
                PartUtils.SetPartDisplay(workPart);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #13
0
        /// <summary>
        /// 获取工件实体在装配下的体
        /// </summary>
        /// <param name="ct"></param>
        /// <param name="pt"></param>
        /// <returns></returns>
        private List <Body> GetCompBodys(NXOpen.Assemblies.Component ct, Part pt)
        {
            List <Body> bodys = new List <Body>();

            if ((ct.Prototype as Part).Equals(pt))
            {
                foreach (Body by in pt.Bodies.ToArray())
                {
                    Body bo = AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, by.Tag) as Body;
                    if (bo != null)
                    {
                        bodys.Add(bo);
                    }
                }
            }
            else
            {
                foreach (NXOpen.Assemblies.Component co in AssmbliesUtils.GetPartComp(ct.Prototype as Part, pt))
                {
                    if (!co.IsSuppressed)
                    {
                        foreach (Body by in pt.Bodies.ToArray())
                        {
                            Body bo = AssmbliesUtils.GetNXObjectOfOcc(co.Tag, by.Tag) as Body;
                            if (bo != null)
                            {
                                bodys.Add(bo);
                            }
                        }
                    }
                }
            }

            return(bodys);
        }
        public bool DeleteBuilder()
        {
            Part workPart = Session.GetSession().Parts.Work;
            List <NXOpen.Assemblies.Component> eleCom = GetEleAllComponent();
            ElectrodeModel eleModel  = new ElectrodeModel(elePart);
            int            eleNumber = eleModel.Info.AllInfo.Name.EleNumber;
            string         path      = elePart.FullPath;

            if (eleCom != null)
            {
                Part work = GetEleWorkPart(eleCom);
                if (work != null)
                {
                    PartUtils.SetPartDisplay(work);
                    NXObject[] objs = LayerUtils.GetAllObjectsOnLayer(eleNumber + 100);
                    LayerUtils.MoveDisplayableObject(eleNumber + 10, objs);
                }
                PartUtils.SetPartDisplay(workPart);
                Part elePart = eleCom[0].Prototype as Part;
                AssmbliesUtils.DeleteComponent(eleCom.ToArray());

                elePart.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null);
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
                return(true);
            }
            return(false);
        }
Пример #15
0
        /// <summary>
        /// 设置连接体
        /// </summary>
        public void WaveBodys()
        {
            Part      workPart     = Session.GetSession().Parts.Work;
            UFSession theUFSession = UFSession.GetUFSession();

            if (workPart.Tag != this.PartTag.Tag)
            {
                NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(workPart, this.PartTag);
                PartUtils.SetPartWork(ct);
            }
            foreach (Part part in Session.GetSession().Parts)
            {
                string type = AttributeUtils.GetAttrForString(part, "PartType");
                if (type.Equals("Workpiece"))
                {
                    Body[] bodys = part.Bodies.ToArray();
                    NXOpen.Features.Feature feat = AssmbliesUtils.WaveAssociativeBodys(bodys);
                    Body[] waveBodys             = ((NXOpen.Features.BodyFeature)feat).GetBodies();
                    foreach (Body body in waveBodys)
                    {
                        body.Layer = 2;
                        theUFSession.Layer.SetStatus(2, 2);
                    }
                    break;
                }
            }
            PartUtils.SetPartWork(null);
        }
Пример #16
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here
                bool anyPartsModified1;
                NXOpen.PartSaveStatus partSaveStatus1;
                Session.GetSession().Parts.SaveAll(out anyPartsModified1, out partSaveStatus1);
                NXOpen.Assemblies.Component eleComp = this.SeleElePart.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;
                string name = eleComp.Name + "-" + this.StrName.Value.ToUpper();
                if (!this.EleDuplicationOfName(name))
                {
                    this.StrName.Value = "";
                    return(0);
                }
                ElectrodeModel eleModel = new ElectrodeModel();
                eleModel.GetModelForPart(eleComp.Prototype as Part);
                name = work.WorkpieceDirectoryPath + name + ".prt";
                Vector3d movePt = new Vector3d(double_x.Value, double_y.Value, double_z.Value);
                NXOpen.Assemblies.Component copyComp = AssmbliesUtils.MoveCompCopyPart(eleComp, movePt, work.WorkMatr);
                AssmbliesUtils.MakeUnique(copyComp, name);
                ElectrodeInfo newInfo = this.SetEleInfo(eleModel.EleInfo);
                newInfo.SetAttribute(copyComp.Prototype as Part);
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
Пример #17
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----

                Session.UndoMarkId          markId  = Session.GetSession().SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "删除电极");
                ElectrodeModel              ele     = new ElectrodeModel();
                NXOpen.Assemblies.Component eleComp = this.selection_Ele.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;
                Part elePart = eleComp.Prototype as Part;
                ele.GetModelForPart(elePart);
                int ok = theUI.NXMessageBox.Show("删除", NXOpen.NXMessageBox.DialogType.Question, elePart.Name + "电极是否删除");
                if (ok == 1)
                {
                    string path = elePart.FullPath;
                    elePart.Close(NXOpen.BasePart.CloseWholeTree.False, NXOpen.BasePart.CloseModified.UseResponses, null);
                    AssmbliesUtils.DeleteComponent(eleComp);
                    LayerUtils.MoveDisplayableObject(ele.EleInfo.EleNumber + 10, LayerUtils.GetAllObjectsOnLayer(ele.EleInfo.EleNumber + 100));
                    if (File.Exists(path))
                    {
                        File.Delete(path);
                    }
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
Пример #18
0
        /// <summary>
        /// 获取work
        /// </summary>
        /// <param name="model"></param>
        /// <param name="asmPart"></param>
        /// <returns></returns>
        private WorkModel GetWorkModel(ElectrodeModel model)
        {
            List <NXOpen.Assemblies.Component> eleComs = AssmbliesUtils.GetPartComp(this.asmPart, model.PartTag);
            List <WorkModel> works = new List <WorkModel>();

            foreach (NXOpen.Assemblies.Component ct in eleComs)
            {
                NXOpen.Assemblies.Component parent = ct.Parent;
                if (parent != null)
                {
                    Part pt = parent.Prototype as Part;
                    if (WorkModel.IsWork(pt) && !works.Exists(a => a.PartTag.Equals(pt)) && ParentAssmblieInfo.GetAttribute(pt).MoldInfo.Equals(model.Info.MoldInfo))
                    {
                        works.Add(new WorkModel(pt));
                    }
                }
            }
            works.Sort();
            if (works.Count != 0)
            {
                return(works[0]);
            }
            else
            {
                return(null);
            }
        }
Пример #19
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                CoordinateSystem wcs = theSession.Parts.Work.WCS.CoordinateSystem;
                Matrix4          mat = new Matrix4();
                mat.Identity();
                mat.TransformToCsys(wcs, ref mat);
                Component ct     = selectionBody.GetSelectedObjects()[0] as Component;
                Part      parent = ct.Parent.Prototype as Part;
                if (!parent.Equals(workPart))
                {
                    PartUtils.SetPartWork(ct.Parent);
                }
                AssmbliesUtils.MoveCompPartForCsys(mat, ct);
                PartUtils.SetPartWork(null);
                if (points.Count > 0)
                {
                    DeleteObject.Delete(points.ToArray());
                }
                CsysUtils.SetWcsToAbs();
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
        /// <summary>
        /// 转换点
        /// </summary>
        /// <param name="pt"></param>
        /// <returns></returns>
        private Point3d GetSetWorkPoint3d(Point pt, Component eleCt)
        {
            Point   compCt = AssmbliesUtils.GetNXObjectOfOcc(eleCt.Tag, pt.Tag) as Point;
            Point3d temp   = compCt.Coordinates;

            work.Info.Matr.ApplyPos(ref temp);
            return(temp);
        }
Пример #21
0
        /// <summary>
        /// 装配Work
        /// </summary>
        public void LoadWork()
        {
            Matrix4 mat = new Matrix4();

            mat.Identity();
            PartUtils.SetPartDisplay(this.PartTag);
            AssmbliesUtils.PartLoad(this.PartTag, work.WorkpiecePath, work.AssembleName, mat, new Point3d(0, 0, 0));
        }
Пример #22
0
        /// <summary>
        /// 获取Work下原点
        /// </summary>
        /// <returns></returns>
        public Point GetWorkCompPoint()
        {
            Part      workPart     = Session.GetSession().Parts.Work;
            UFSession theUFSession = UFSession.GetUFSession();
            Component ct           = AssmbliesUtils.GetPartComp(this.PartTag, work.PartTag)[0];
            Point     pt           = work.CreateCenterPoint();

            return(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, pt.Tag) as Point);
        }
Пример #23
0
 //------------------------------------------------------------------------------
 //Callback Name: update_cb
 //------------------------------------------------------------------------------
 public int update_cb(NXOpen.BlockStyler.UIBlock block)
 {
     try
     {
         if (block == selectionBody)
         {
             //---------Enter your code here-----------
             if (points.Count > 0)
             {
                 DeleteObject.Delete(points.ToArray());
             }
             points.Clear();
             Component ct = selectionBody.GetLastSelectedObjects()[0] as Component;
             foreach (Body by in (ct.Prototype as Part).Bodies)
             {
                 if (by.IsBlanked)
                 {
                     nxObjects.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, by.Tag));
                 }
             }
             this.aoo = new NXObjectAooearancePoint(nxObjects.ToArray());
             points   = aoo.CreatePoint();
         }
         else if (block == get_point)
         {
             //---------Enter your code here-----------
             Point3d temp = this.GetPoint();
             if (this.selectionPt != null)
             {
                 Basic.CsysUtils.SetWcsOfCentePoint(temp);
             }
         }
         else if (block == rotation_x)
         {
             //---------Enter your code here-----------
             CsysUtils.RotateWcs(WCS.Axis.XAxis, 90);
         }
         else if (block == rotation_y)
         {
             //---------Enter your code here-----------
             CsysUtils.RotateWcs(WCS.Axis.YAxis, 90);
         }
         else if (block == rotation_z)
         {
             //---------Enter your code here-----------
             CsysUtils.RotateWcs(WCS.Axis.ZAxis, 90);
         }
     }
     catch (Exception ex)
     {
         //---- Enter your exception handling code here -----
         theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
     }
     return(0);
 }
Пример #24
0
        /// <summary>
        /// 创建装配
        /// </summary>
        /// <param name="filePath"></param>
        /// <returns></returns>
        public NXOpen.Assemblies.Component CreateCompPart()
        {
            CsysUtils.SetWcsOfCenteAndMatr(this.CenterPt, this.EleMatr.GetMatrix3());
            NXObject obj = AssmbliesUtils.CreateNew(this.AssembleName, WorkpiecePath);

            NXOpen.Assemblies.Component comp = obj as NXOpen.Assemblies.Component;
            this.PartTag = obj.Prototype as Part;
            SetAttribute();
            CsysUtils.SetWcsToAbs();
            return(comp);
        }
Пример #25
0
 /// <summary>
 /// 创建part档
 /// </summary>
 /// <returns></returns>
 private NXOpen.Assemblies.Component CreateElePart()
 {
     NXOpen.Assemblies.Component eleComp = elePart.Create();
     if (eleComp != null)
     {
         PartUtils.SetPartWork(eleComp);
         NXOpen.Features.Feature feat = AssmbliesUtils.WaveBodys(this.head.ConditionModel.Bodys.ToArray());
         this.waveBodys = (feat as NXOpen.Features.BodyFeature).GetBodies();
     }
     return(eleComp);
 }
Пример #26
0
        /// <summary>
        /// 更新work零件明细表
        /// </summary>
        private void AlterWorkDrawing()
        {
            Part      workPart     = Session.GetSession().Parts.Work;
            UFSession theUFSession = UFSession.GetUFSession();

            if (!workPart.Equals(work.PartTag))
            {
                NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(workPart, work.PartTag);
                PartUtils.SetPartWork(ct);
            }
            theUFSession.Plist.UpdateAllPlists();
            PartUtils.SetPartWork(null);
        }
 /// <summary>
 /// 移动电极
 /// </summary>
 /// <param name="dir"></param>
 /// <returns></returns>
 private bool MoveElePart(Component eleCt, ElectrodePitchInfo pitch, int dir)
 {
     if ((pitch.PitchXNum > 1 && Math.Abs(pitch.PitchX) > 0) ||
         (pitch.PitchYNum > 1 && Math.Abs(pitch.PitchY) > 0))
     {
         Vector3d vec = new Vector3d();
         vec.X = (pitch.PitchXNum - 1) * pitch.PitchX * dir;
         vec.Y = (pitch.PitchYNum - 1) * pitch.PitchY * dir;
         AssmbliesUtils.MoveCompPart(eleCt, vec, this.work.Info.Matr);
         return(true);
     }
     return(false);
 }
Пример #28
0
        /// <summary>
        /// 画中心点和中心线
        /// </summary>
        /// <param name="disPt"></param>
        public void CreatePointAndCenterLine(Point3d centerPt, Point3d disPt)
        {
            Part workPart = Session.GetSession().Parts.Work;

            if (workPart.Tag != PartTag.Tag)
            {
                NXOpen.Assemblies.Component ct = AssmbliesUtils.GetPartComp(workPart, PartTag);
                PartUtils.SetPartWork(ct);
            }
            CreateCenterLine(centerPt, disPt);
            CreateCenterPoint();
            PartUtils.SetPartWork(null);
        }
Пример #29
0
 /// <summary>
 /// 移动电极
 /// </summary>
 /// <param name="dir"></param>
 /// <returns></returns>
 private bool MoveElePart(int dir)
 {
     if ((this.eleModel.EleInfo.PitchXNum > 1 && Math.Abs(this.eleModel.EleInfo.PitchX) > 0) ||
         (this.eleModel.EleInfo.PitchYNum > 1 && Math.Abs(this.eleModel.EleInfo.PitchY) > 0))
     {
         Vector3d vec = new Vector3d();
         vec.X = (this.eleModel.EleInfo.PitchXNum - 1) * this.eleModel.EleInfo.PitchX * dir;
         vec.Y = (this.eleModel.EleInfo.PitchYNum - 1) * this.eleModel.EleInfo.PitchY * dir;
         AssmbliesUtils.MoveCompPart(this.eleModel.GetPartComp(workPart), vec, this.work.WorkMatr);
         return(true);
     }
     return(false);
 }
Пример #30
0
        /// <summary>
        /// 获取边
        /// </summary>
        /// <param name="xEdge"></param>
        /// <param name="yEdge"></param>
        public void GetEdge(out List <Edge> xEdge, out Point centerCom)
        {
            xEdge     = new List <Edge>();
            centerCom = null;
            string         str = "";
            ElectrodeModel ele = null;

            foreach (ElectrodeModel em in eleModels)
            {
                if (em.Info.AllInfo.SetValue.Positioning == "" || em.Info.AllInfo.SetValue.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    ele = em;
                }
            }
            if (ele == null)
            {
                return;
            }

            List <Face> faces = new List <Face>();

            faces.AddRange(ele.PartTag.Bodies.ToArray()[0].GetFaces());
            Point elePoint = ele.GetSetPoint();

            faces.Sort(delegate(Face a, Face b)
            {
                FaceData data1 = FaceUtils.AskFaceData(a);
                FaceData data2 = FaceUtils.AskFaceData(b);
                return(data1.Point.Z.CompareTo((data2.Point.Z)));
            });
            foreach (Component ct in AssmbliesUtils.GetPartComp(this.PartTag, ele.PartTag))
            {
                ElectrodeSetValueInfo value = ElectrodeSetValueInfo.GetAttribute(ct);
                if (value.Positioning == "" || value.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    centerCom = AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, elePoint.Tag) as Point;
                    foreach (Edge eg in faces[10].GetEdges())
                    {
                        NXOpen.UF.UFEval.Line lineData;
                        if (EdgeUtils.GetLineData(eg, out lineData, ref str))
                        {
                            if (UMathUtils.IsEqual(lineData.start[1], lineData.end[1]))
                            {
                                xEdge.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, eg.Tag) as Edge);
                            }
                        }
                    }
                }
            }
        }