示例#1
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);
            }
        }
        /// <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);
        }
示例#3
0
 /// <summary>
 /// 创建装配
 /// </summary>
 /// <param name="filePath"></param>
 /// <returns></returns>
 public NXOpen.Assemblies.Component CreateCompPart(string directoryPath)
 {
     this.WorkpieceDirectoryPath = directoryPath;
     this.WorkpiecePath          = directoryPath + this.AssembleName + ".prt";
     CsysUtils.SetWcsToAbs();
     CsysUtils.SetWcsOfCenteAndMatr(this.Info.Matr.GetCenter(), this.Info.Matr.GetMatrix3());
     try
     {
         NXObject obj = AssmbliesUtils.CreateNew(this.AssembleName, WorkpiecePath);
         NXOpen.Assemblies.Component comp = obj as NXOpen.Assemblies.Component;
         this.PartTag = obj.Prototype as Part;
         if (this.PartTag != null)
         {
             SetAttribute(this.PartTag);
         }
         CsysUtils.SetWcsToAbs();
         return(comp);
     }
     catch (NXException ex)
     {
         ClassItem.WriteLogFile("创建装配档错误!" + ex.Message);
         throw ex;
     }
 }