Ejemplo n.º 1
0
        //------------------------------------------------------------------------------
        //This method shows the dialog on the screen
        //------------------------------------------------------------------------------
        public NXOpen.UIStyler.DialogResponse Show()
        {
            try
            {
                string partType = AttributeUtils.GetAttrForString(workPart, "PartType");
                if (!partType.Equals("Work"))
                {
                    theUI.NXMessageBox.Show("错误!", NXMessageBox.DialogType.Error, "请切换到Work档下!");
                    return(0);
                }
                work.GetModelForPart(workPart);
                string asm  = work.MoldInfo.MoldNumber + "-" + work.MoldInfo.WorkpieceNumber + "-ASM";
                string name = work.MoldInfo.MoldNumber + "-" + work.MoldInfo.WorkpieceNumber;

                foreach (Part part in theSession.Parts)
                {
                    if (part.Name.Equals(asm))
                    {
                        assemble = AssembleSingleton.Instance().GetAssemble(name);
                    }
                }
                if (assemble == null)
                {
                    theUI.NXMessageBox.Show("错误!", NXMessageBox.DialogType.Error, "无法找到ASM档!");
                    return(0);
                }
                theDialog.Show();
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(0);
        }
Ejemplo n.º 2
0
        private bool PartIsAsm()
        {
            Part          workPart = Session.GetSession().Parts.Work;
            MoldInfoModel mold     = new MoldInfoModel(workPart);
            string        type     = AttributeUtils.GetAttrForString(workPart, "PartType");

            if (type.Equals("ASM"))
            {
                assemble = AssembleSingleton.Instance().GetAssemble(mold.MoldNumber + "-" + mold.WorkpieceNumber);
                foreach (WorkModel work in assemble.Works)
                {
                    if (!AttributeUtils.GetAttrForBool(work.PartTag, "Interference"))
                    {
                        UI.GetUI().NXMessageBox.Show("提示", NXMessageBox.DialogType.Error, "WORK" + work.WorkNumber.ToString()
                                                     + "没有检查电极");
                        return(false);
                    }
                }
                if (assemble.IsAssmbleOk())
                {
                    return(true);
                }
                else
                {
                    return(false);
                }
            }
            else
            {
                UI.GetUI().NXMessageBox.Show("提示", NXMessageBox.DialogType.Error, "请切换到ASM下");
                return(false);
            }
        }
Ejemplo n.º 3
0
        //------------------------------------------------------------------------------
        //Callback Name: filter_cb
        //------------------------------------------------------------------------------
        public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject)
        {
            Model.MoldInfoModel info = builder.Model.Asm.MoldInfo;

            if (this.selePart.GetSelectedObjects().Length != 0)
            {
                Part   part = (this.selePart.GetSelectedObjects()[0] as NXOpen.Assemblies.Component).Prototype as Part;
                string name = AttributeUtils.GetAttrForString(part, "PartType");
                if (name.Equals("Workpiece", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(UFConstants.UF_UI_SEL_ACCEPT);
                }
                if (selectedObject is Face)
                {
                    Face seleFace = selectedObject as Face;
                    Part selePart = (seleFace.Prototype as Face).OwningPart as Part;

                    if (selePart.Tag != part.Tag)
                    {
                        return(UFConstants.UF_UI_SEL_REJECT);
                    }
                }
            }
            return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT);
        }
Ejemplo n.º 4
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                NXOpen.Assemblies.Component ct = this.seleComp.GetSelectedObjects()[0] as NXOpen.Assemblies.Component;
                Part   pt   = ct.Prototype as Part;
                string type = AttributeUtils.GetAttrForString(pt, "PartType");
                if (type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase))
                {
                    ElectrodeModel model = new ElectrodeModel();
                    model.GetModelForPart(pt);
                    ReplacePart.ReplaceElectrode(model, this.strEleName.Value.ToUpper());
                }
                else
                {
                    ReplacePart.Replace(pt, this.strEleName.Value.ToUpper());
                }
                bool           anyPartsModified;
                PartSaveStatus saveStatus;
                theSession.Parts.SaveAll(out anyPartsModified, out saveStatus);
            }
            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>
        private void SetHeadColour()
        {
            Matrix4 matr = new Matrix4();

            matr.Identity();
            Matrix4 inv = matr.GetInversMatrix();
            CartesianCoordinateSystem csys = BoundingBoxUtils.CreateCoordinateSystem(matr, inv);
            List <Body> bodys     = Session.GetSession().Parts.Work.Bodies.ToArray().ToList();
            var         toolhList = bodys.GroupBy(a => AttributeUtils.GetAttrForString(a, "ToolhName"));
            List <ElectrodeToolhInfo[, ]> toolhInfos = new List <ElectrodeToolhInfo[, ]>();

            try
            {
                foreach (var toolh in toolhList)
                {
                    ElectrodeToolhInfo[,] toolhInfo = pitch.GetToolhInfosForAttribute(toolh.ToList(), matr, csys);
                    toolhInfos.Add(toolhInfo);
                }
                if (toolhInfos.Count != 0)
                {
                    gapValue.SetERToolh(toolhInfos);
                }
            }
            catch (Exception ex)
            {
                ClassItem.WriteLogFile("设置颜色错误!" + ex.Message);
            }
        }
Ejemplo n.º 6
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);
        }
        private void GetEFanERFace(List <Face> faces, out Dictionary <double, Face[]> dic)
        {
            List <Face> erFaces = new List <Face>();
            List <Face> efFaces = new List <Face>();

            dic = new Dictionary <double, Face[]>();
            if (faces.Count > 0)
            {
                foreach (Face fe in faces)
                {
                    string er = AttributeUtils.GetAttrForString(fe, "ToolhGapValue");
                    if (er.Equals("ER", StringComparison.CurrentCultureIgnoreCase))
                    {
                        erFaces.Add(fe);
                    }
                    else if (er.Equals("EF", StringComparison.CurrentCultureIgnoreCase))
                    {
                        efFaces.Add(fe);
                    }
                }
            }
            if (!this.IsOffsetInter)
            {
                dic.Add(this.model.Info.AllInfo.GapValue.FineInter, efFaces.ToArray());
                dic.Add(this.model.Info.AllInfo.GapValue.DuringInter, erFaces.ToArray());
            }
            else
            {
                dic.Add(0, faces.ToArray());
            }
        }
Ejemplo n.º 8
0
        public bool SetOffsetInter(List <Face> ErFace, double ErSide, List <Face> EfFace, double EfSide)
        {
            string mb = AttributeUtils.GetAttrForString(pt, "MdblsShrinkBody");

            if (mb.Equals("1", StringComparison.CurrentCultureIgnoreCase))
            {
                return(true);
            }
            if (mb.Equals("0", StringComparison.CurrentCultureIgnoreCase))
            {
                return(false);
            }
            bool       isokEr       = false;
            bool       isokEf       = false;
            UFSession  theUFSession = UFSession.GetUFSession();
            List <Tag> featureTags  = new List <Tag>();
            Tag        groupTag;

            foreach (NXOpen.Features.Feature fe in pt.Features)
            {
                featureTags.Add(fe.Tag);
            }
            theUFSession.Modl.CreateSetOfFeature("电极特征", featureTags.ToArray(), featureTags.Count, 1, out groupTag);
            NXObject objEr = null;

            try
            {
                objEr = OffsetRegionUtils.Offset(-ErSide, out isokEr, ErFace.ToArray());
                if (isokEr)
                {
                    objEr.SetName((-ErSide).ToString());
                }
            }
            catch
            {
                this.SetAttribute(true);
                return(false);
            }
            try
            {
                NXObject obj = OffsetRegionUtils.Offset(-EfSide, out isokEf, EfFace.ToArray());
                if (isokEf)
                {
                    obj.SetName((-EfSide).ToString());
                }
                this.SetAttribute(true);
                return(true);
            }
            catch
            {
                if (objEr != null)
                {
                    DeleteObject.Delete(objEr);
                }
                this.SetAttribute(false);
                return(false);
            }
        }
Ejemplo n.º 9
0
        //------------------------------------------------------------------------------
        //Callback Name: apply_cb
        //------------------------------------------------------------------------------
        public int apply_cb()
        {
            int errorCode = 0;

            try
            {
                //---- Enter your callback code here -----
                List <string> newFileName = new List <string>();
                if (file.Path == "")
                {
                    theUI.NXMessageBox.Show("错误", NXMessageBox.DialogType.Error, "请指定文件位置");
                    return(1);
                }
                foreach (Node node in treeElectrode.GetSelectedNodes())
                {
                    ElectrodeModel model = assemble.Electrodes.Find(a => node.Equals(a.Node));
                    if (model != null)
                    {
                        ExportFile path = new ExportFile(model);
                        string     temp = path.NewFile(file.Path);
                        newFileName.Add(temp);
                        model.PartTag.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null);
                        Part newPart = PartUtils.OpenPartFile(temp);
                        PartUtils.SetPartDisplay(newPart);
                        if (this.toggleShops.Value && IsPartProgram(newPart))
                        {
                            PartPost        elePost = new PartPost(newPart);
                            List <NCGroup>  groups  = elePost.GetGroup();
                            CreatePostExcel excel   = new CreatePostExcel(groups, newPart);
                            excel.CreateExcel();
                            string[] name = elePost.GetElectrodePostName(groups);
                            foreach (string str in name)
                            {
                                elePost.Post(str, groups.ToArray());
                            }
                        }
                        newPart.Save(BasePart.SaveComponents.True, BasePart.CloseAfterSave.False);
                    }
                }
                foreach (Part part in theSession.Parts)//关闭其他
                {
                    string type = AttributeUtils.GetAttrForString(part, "PartType");
                    if (!type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase))
                    {
                        part.Close(BasePart.CloseWholeTree.False, BasePart.CloseModified.CloseModified, null);
                    }
                }
            }
            catch (Exception ex)
            {
                //---- Enter your exception handling code here -----
                errorCode = 1;
                theUI.NXMessageBox.Show("Block Styler", NXMessageBox.DialogType.Error, ex.ToString());
            }
            return(errorCode);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 获取电极矩阵
        /// </summary>
        /// <param name="part"></param>
        /// <returns></returns>
        public Matrix4 GetEleMatrix4(Part part)
        {
            string[] temp = new string[4];
            for (int i = 0; i < 4; i++)
            {
                temp[i] = AttributeUtils.GetAttrForString(part, "Matrx4", i);
            }

            return(StringToMatrx4(temp));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 读取模具属性
 /// </summary>
 /// <param name="part"></param>
 public void GetAttribute(Part part)
 {
     this.MoldNumber      = AttributeUtils.GetAttrForString(part, "MoldNumber");
     this.WorkpieceNumber = AttributeUtils.GetAttrForString(part, "PieceNumber");
     this.EditionNumber   = AttributeUtils.GetAttrForString(part, "EditionNumber");
     this.MoldType        = AttributeUtils.GetAttrForString(part, "MoldType");
     this.ClientName      = AttributeUtils.GetAttrForString(part, "ClientName");
     this.CreatorName     = AttributeUtils.GetAttrForString(part, "CreatorName");
     this.CreatedDate     = AttributeUtils.GetAttrForString(part, "CreatedDate");
 }
Ejemplo n.º 12
0
        //------------------------------------------------------------------------------
        //Callback Name: filter_cb
        //------------------------------------------------------------------------------
        public int filter_cb(NXOpen.BlockStyler.UIBlock block, NXOpen.TaggedObject selectedObject)
        {
            Part   part     = (selectedObject as NXOpen.Assemblies.Component).Prototype as Part;
            string partType = AttributeUtils.GetAttrForString(part, "PartType");

            if (!partType.Equals("Electrode"))
            {
                return(UFConstants.UF_UI_SEL_REJECT);
            }
            return(NXOpen.UF.UFConstants.UF_UI_SEL_ACCEPT);
        }
Ejemplo n.º 13
0
 protected override void GetAttribute(Part part)
 {
     base.GetAttribute(part);
     this.WorkNumber = AttributeUtils.GetAttrForInt(part, "WorkNumber");
     string[] temp = new string[4];
     for (int i = 0; i < 4; i++)
     {
         temp[i] = AttributeUtils.GetAttrForString(part, "Matrx4", i);
     }
     this.WorkMatr = StringToMatrx4(temp);
 }
Ejemplo n.º 14
0
        /// <summary>
        /// 判断Part是否是电极
        /// </summary>
        /// <returns></returns>
        public static bool IsPartElectrode(Part part)
        {
            string type = AttributeUtils.GetAttrForString(part, "PartType");

            if (type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Ejemplo n.º 15
0
 /// <summary>
 /// 获取用户
 /// </summary>
 /// <param name="user"></param>
 /// <param name="date"></param>
 public void GetUserInfo(out string user, out string date)
 {
     date = AttributeUtils.GetAttrForString(this.pt, "CreatedCAMDate");
     user = AttributeUtils.GetAttrForString(this.pt, "CreatorCAMName");
     if (date == "")
     {
         date = DateTime.Now.ToString("yyyy-MM-dd");
     }
     if (user == "")
     {
         user = Environment.UserName;//获取电脑用户名
     }
 }
Ejemplo n.º 16
0
        /// <summary>
        /// 判断Part是否有信息
        /// </summary>
        /// <returns></returns>
        public static bool IsPartInfo(Part part)
        {
            string type = AttributeUtils.GetAttrForString(part, "PartType");

            if (type.Equals(""))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 17
0
        /// <summary>
        /// 获取全部装配
        /// </summary>
        private void GetAssembleInfo()
        {
            foreach (Part pt in Session.GetSession().Parts)
            {
                if (pt.Name.Length > moldAndWorkpieceNum.Length)
                {
                    if (moldAndWorkpieceNum.Equals(pt.Name.Substring(0, moldAndWorkpieceNum.Length))) //判断是否一个模号
                    {
                        string partType = AttributeUtils.GetAttrForString(pt, "PartType");

                        switch (partType)
                        {
                        case "ASM":
                        {
                            ASMModel asm = new ASMModel();
                            asm.GetModelForPart(pt);
                            this.Asm = asm;
                            break;
                        }

                        case "EDM":
                        {
                            EDMModel edm = new EDMModel();
                            edm.GetModelForPart(pt);
                            this.Edm = edm;
                            break;
                        }

                        case "Work":
                        {
                            WorkModel model = new WorkModel();
                            model.GetModelForPart(pt);
                            this.Works.Add(model);
                            break;
                        }

                        case "Electrode":
                        {
                            ElectrodeModel model = new ElectrodeModel();
                            model.GetModelForPart(pt);
                            this.Electrodes.Add(model);
                            break;
                        }

                        default:
                            break;
                        }
                    }
                }
            }
        }
        private List <Component> GetEleAllComp()
        {
            List <Component> eleComps = new List <Component>();

            foreach (Component ct in workComp.GetChildren())
            {
                string partType = AttributeUtils.GetAttrForString(ct, "PartType");
                if (partType.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase))
                {
                    eleComps.Add(ct);
                }
            }
            return(eleComps);
        }
Ejemplo n.º 19
0
 /// <summary>
 /// 以属性得到实体
 /// </summary>
 /// <param name="obj"></param>
 /// <returns></returns>
 public static ParentAssmblieInfo GetAttribute(NXObject obj)
 {
     try
     {
         string             partType = AttributeUtils.GetAttrForString(obj, "PartType");
         ParentAssmblieInfo info     = new ParentAssmblieInfo(MoldInfo.GetAttribute(obj), UserModel.GetAttribute(obj));
         info.Type = (PartType)Enum.Parse(typeof(PartType), partType);
         return(info);
     }
     catch (NXException ex)
     {
         throw ex;
     }
 }
        /// <summary>
        /// 获取电极齿信息
        /// </summary>
        /// <param name="bodys"></param>
        /// <returns></returns>
        private List <ElectrodeToolhInfo> GetToolhInfo(List <Body> bodys)
        {
            List <ElectrodeToolhInfo> toolhs = new List <ElectrodeToolhInfo>();
            // var toolhNameList = bodys.GroupBy(a => AttributeUtils.GetAttrForString(a, "ToolhName"));
            var toolhNameList = bodys.GroupBy(delegate(Body a)
            {
                string temp = AttributeUtils.GetAttrForString(a, "ToolhName");
                char result;
                double tp = 0;
                if (Char.TryParse(temp, out result))
                {
                    return((int)result);
                }
                else
                {
                    if (Double.TryParse(temp, out tp))
                    {
                        return(tp);
                    }
                }
                return(0);
            });
            List <Double> keys = new List <Double>();

            foreach (IGrouping <Double, Body> group in toolhNameList)
            {
                keys.Add(group.Key);
            }
            keys.Sort();
            toolhNameList.OrderByDescending(a => a.Key);
            int num = 65;

            for (int j = 0; j < keys.Count; j++)
            {
                foreach (var te in toolhNameList)
                {
                    if (te.Key == keys[j])
                    {
                        ElectrodeToolhInfo toolh = ElectrodeToolhInfo.GetToolhInfoForAttribute(te.ToArray());
                        char k = (char)num;
                        toolh.SetToolhName(k.ToString());
                        toolhs.Add(toolh);
                        num++;
                        break;
                    }
                }
            }
            return(toolhs);
        }
Ejemplo n.º 21
0
        public static UserModel GetAttribute(NXObject obj)
        {
            UserModel model = new UserModel();

            try
            {
                model.CreatorName = AttributeUtils.GetAttrForString(obj, "CreatorName");
                model.CreatedDate = AttributeUtils.GetAttrForString(obj, "CreatedDate");
                return(model);
            }
            catch (NXException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 22
0
 /// <summary>
 /// 设置颜色
 /// </summary>
 /// <param name="by"></param>
 private void SetEleColor(Body by)
 {
     foreach (Face fe in by.GetFaces())
     {
         string gap = AttributeUtils.GetAttrForString(fe, "ToolhGapValue");
         if (gap.Equals("ER", StringComparison.CurrentCultureIgnoreCase))
         {
             fe.Color = 6;
         }
         if (gap.Equals("EF", StringComparison.CurrentCultureIgnoreCase))
         {
             fe.Color = 108;
         }
     }
 }
Ejemplo n.º 23
0
        /// <summary>
        /// 读取属性
        /// </summary>
        public void GetAttribute(Part obj)
        {
            this.EleName    = AttributeUtils.GetAttrForString(obj, "EleName");
            this.BorrowName = AttributeUtils.GetAttrForString(obj, "BorrowName");

            this.PitchX    = AttributeUtils.GetAttrForDouble(obj, "PitchX");
            this.PitchXNum = AttributeUtils.GetAttrForInt(obj, "PitchXNum");
            this.PitchY    = AttributeUtils.GetAttrForDouble(obj, "PitchY");
            this.PitchYNum = AttributeUtils.GetAttrForInt(obj, "PitchYNum");

            this.CrudeInter  = AttributeUtils.GetAttrForDouble(obj, "CrudeInter");
            this.CrudeNum    = AttributeUtils.GetAttrForInt(obj, "CrudeNum");
            this.DuringInter = AttributeUtils.GetAttrForDouble(obj, "DuringInter");
            this.DuringNum   = AttributeUtils.GetAttrForInt(obj, "DuringNum");
            this.FineInter   = AttributeUtils.GetAttrForDouble(obj, "FineInter");
            this.FineNum     = AttributeUtils.GetAttrForInt(obj, "FineNum");

            this.Material    = AttributeUtils.GetAttrForString(obj, "Material1");
            this.EleType     = AttributeUtils.GetAttrForString(obj, "EleType");
            this.Condition   = AttributeUtils.GetAttrForString(obj, "Condition");
            this.Extrudewith = AttributeUtils.GetAttrForDouble(obj, "Extrudewith");
            this.Ch          = AttributeUtils.GetAttrForString(obj, "CH");

            this.IsPreparation = AttributeUtils.GetAttrForBool(obj, "IsPreparation");
            this.Remarks       = AttributeUtils.GetAttrForString(obj, "Remarks");
            this.Technology    = AttributeUtils.GetAttrForString(obj, "Technology");
            this.CamTemplate   = AttributeUtils.GetAttrForString(obj, "CamTemplate");

            for (int i = 0; i < 3; i++)
            {
                this.EleSetValue[i] = AttributeUtils.GetAttrForDouble(obj, "EleSetValue", i);
            }
            for (int i = 0; i < 3; i++)
            {
                this.Preparation[i] = AttributeUtils.GetAttrForInt(obj, "Preparation", i);
            }

            this.Positioning     = AttributeUtils.GetAttrForString(obj, "Positioning");
            this.ElePresentation = AttributeUtils.GetAttrForString(obj, "ElePresentation");
            this.Area            = AttributeUtils.GetAttrForDouble(obj, "Area");
            this.EleNumber       = AttributeUtils.GetAttrForInt(obj, "EleNumber");
            this.DatumWidth      = AttributeUtils.GetAttrForDouble(obj, "DatumWidth");
            this.EleMinDim       = AttributeUtils.GetAttrForDouble(obj, "EleMinDim");
            for (int i = 0; i < 2; i++)
            {
                this.EleHeadDis[i] = AttributeUtils.GetAttrForDouble(obj, "EleHeadDis", i);
            }
        }
Ejemplo n.º 24
0
        public void CreateExcel()
        {
            string dllPath           = AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
            string excelTemplatePath = dllPath.Replace("application\\", "Cofigure\\ShopDoc_Template-test.xlsx");
            string path = part.FullPath;

            path = System.IO.Path.GetDirectoryName(path) + "\\" + part.Name + ".xlsx";

            IWorkbook workbook = ExcelUtils.CreateExeclFile(excelTemplatePath);

            if (workbook == null)
            {
                return;
            }
            IFont font = workbook.CreateFont();

            font.FontName           = "微软雅黑";
            font.FontHeightInPoints = 8;
            ICellStyle style     = ExcelUtils.SetCellStyle(workbook, font);
            ICellStyle styleDate = ExcelUtils.SetCellStyle(workbook, font);

            styleDate.DataFormat = 21;
            ISheet sheet = workbook.GetSheetAt(0);

            if (PostPartInfo.IsPartInfo(part))
            {
                SetMoldInfoToExcel(new MoldInfoModel(part), sheet, style);
            }
            if (PostPartInfo.IsPartElectrode(part))
            {
                SetEleMoldInfoToExcel(new PostElectrodenfo(part), sheet, style);
            }
            string name = AttributeUtils.GetAttrForString(part, "CAMUser");

            if (name.Equals(""))
            {
                name = Environment.UserName;
            }

            SetUser(name, sheet, style);
            SetRowData(sheet, style, styleDate);
            FileStream fs = File.Create(path);

            workbook.Write(fs);
            fs.Close();
            workbook.Close();
        }
Ejemplo n.º 25
0
        /// <summary>
        /// 读取属性
        /// </summary>
        public static ElectrodeNameInfo GetAttribute(NXObject obj)
        {
            ElectrodeNameInfo info = new ElectrodeNameInfo();

            try
            {
                info.EleName          = AttributeUtils.GetAttrForString(obj, "EleName");
                info.BorrowName       = AttributeUtils.GetAttrForString(obj, "BorrowName");
                info.EleNumber        = AttributeUtils.GetAttrForInt(obj, "EleNumber");
                info.EleEditionNumber = AttributeUtils.GetAttrForString(obj, "EleEditionNumber");
                return(info);
            }
            catch (NXException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 26
0
        /// <summary>
        /// 读取属性
        /// </summary>
        public static ElectrodeDatumInfo GetAttribute(NXObject obj)
        {
            ElectrodeDatumInfo info = new ElectrodeDatumInfo();

            try
            {
                info.DatumWidth    = AttributeUtils.GetAttrForDouble(obj, "DatumWidth");
                info.DatumHeigth   = AttributeUtils.GetAttrForDouble(obj, "DatumHeigth");
                info.ExtrudeHeight = AttributeUtils.GetAttrForDouble(obj, "Extrudewith");
                info.EleHeight     = AttributeUtils.GetAttrForDouble(obj, "EleHeight");
                info.EleProcessDir = AttributeUtils.GetAttrForString(obj, "EleProcessDir");
                return(info);
            }
            catch (NXException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// 获得基准面
        /// </summary>
        /// <returns></returns>
        private FaceData GetDatumFace()
        {
            string er = AttributeUtils.GetAttrForString(analysisBody.AnaFaces[1].Face, "DatumFace");

            if (er.Equals("Datum", StringComparison.CurrentCultureIgnoreCase))
            {
                return(analysisBody.AnaFaces[1].Data);
            }
            foreach (AnalysisFaceSlopeAndDia fe in analysisBody.AnaFaces)
            {
                string da = AttributeUtils.GetAttrForString(fe.Face, "DatumFace");
                if (da.Equals("Datum", StringComparison.CurrentCultureIgnoreCase))
                {
                    return(fe.Data);
                }
            }
            FaceLoopUtils.LoopList[] loops = FaceLoopUtils.AskFaceLoops(analysisBody.AnaFaces[0].Face.Tag);
            foreach (FaceLoopUtils.LoopList lt in FaceLoopUtils.AskFaceLoops(analysisBody.AnaFaces[0].Face.Tag)) //找到竖直面
            {
                if (lt.Type == 2)
                {
                    Edge edg = NXObjectManager.Get(lt.EdgeList[0]) as Edge;
                    foreach (Face fe in edg.GetFaces())
                    {
                        if (!fe.Equals(analysisBody.AnaFaces[0].Face))
                        {
                            foreach (Edge eg in fe.GetEdges())
                            {
                                foreach (Face fc in eg.GetFaces())
                                {
                                    FaceData fd    = FaceUtils.AskFaceData(fc);
                                    double   angle = UMathUtils.Angle(fd.Dir, new Vector3d(0, 0, 1));
                                    if (UMathUtils.IsEqual(angle, 0))
                                    {
                                        return(fd);
                                    }
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
        public static void Create()
        {
            Part   workPart = Session.GetSession().Parts.Work;
            string type     = AttributeUtils.GetAttrForString(workPart, "PartType");

            if (type.Equals("Electrode", StringComparison.CurrentCultureIgnoreCase))
            {
                ElectrodeModel model = new ElectrodeModel();
                model.GetModelForPart(workPart);
                CreateElectrodeCAM cam = new CreateElectrodeCAM(model, "User");
                cam.CreateOperName();
                cam.CreateOper();
            }
            else
            {
                UI.GetUI().NXMessageBox.Show("注意", NXMessageBox.DialogType.Error, "电极不标准");
                return;
            }
        }
Ejemplo n.º 29
0
        /// <summary>
        /// 读取模具属性
        /// </summary>
        /// <param name="part"></param>
        public static MoldInfo GetAttribute(NXObject obj)
        {
            MoldInfo info = new MoldInfo();

            try
            {
                info.MoldNumber      = AttributeUtils.GetAttrForString(obj, "MoldNumber");
                info.WorkpieceNumber = AttributeUtils.GetAttrForString(obj, "PieceNumber");
                info.EditionNumber   = AttributeUtils.GetAttrForString(obj, "EditionNumber");
                info.MoldType        = AttributeUtils.GetAttrForString(obj, "MoldType");
                info.ClientName      = AttributeUtils.GetAttrForString(obj, "ClientName");
                info.MachineType     = AttributeUtils.GetAttrForString(obj, "MachineType");
                return(info);
            }
            catch (NXException ex)
            {
                throw ex;
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 读取属性
        /// </summary>
        public static ElectrodePreparationInfo GetAttribute(NXObject obj)
        {
            ElectrodePreparationInfo info = new ElectrodePreparationInfo();

            try
            {
                info.IsPreparation = AttributeUtils.GetAttrForBool(obj, "IsPreparation");
                info.Material      = AttributeUtils.GetAttrForString(obj, "Material1");
                for (int i = 0; i < 3; i++)
                {
                    info.Preparation[i] = AttributeUtils.GetAttrForInt(obj, "Preparation", i);
                }
                return(info);
            }
            catch (NXException ex)
            {
                throw ex;
            }
        }