Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 装配工件
        /// </summary>
        /// <param name="edm"></param>
        /// <param name="ct"></param>
        /// <returns></returns>
        private List <string> LoadWorkpiece(Part edm, NXOpen.Assemblies.Component ct)
        {
            List <string> err = new List <string>();

            try
            {
                Matrix3x3             mat;
                Point3d               setPt;
                NXOpen.PartLoadStatus partLoadStatus1 = null;
                Part pt = ct.Prototype as Part;
                ct.GetPosition(out setPt, out mat);
                NXOpen.Assemblies.Component copyCt = edm.ComponentAssembly.AddComponent(pt.FullPath, "None", ct.Name, setPt, mat, -1, out partLoadStatus1, true);
            }
            catch (NXException ex)
            {
                err.Add("无法装配" + ct.Name + "工件         " + ex.Message);
            }
            return(err);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 加载部件
        /// </summary>
        /// <param name="part">部件下面</param>
        /// <param name="partPath">部件地址</param>
        /// <param name="partName">部件名字</param>
        /// <param name="csys">加载坐标</param>
        /// <param name="basePoint">装配位置点</param>
        /// <returns>Component</returns>
        public static NXOpen.Assemblies.Component PartLoad(Part part, string partPath, string partName, Matrix4 matr, Point3d basePoint)
        {
            //  Part workPart = theSession.Parts.Work;

            NXOpen.PartLoadStatus       partLoadStatus1 = null;
            NXOpen.Assemblies.Component component1;
            try
            {
                component1 = part.ComponentAssembly.AddComponent(partPath, "None", partName, basePoint, matr.GetMatrix3(), -1, out partLoadStatus1, true);
                return(component1);
            }
            catch (Exception ex)
            {
                LogMgr.WriteLog("AssmbliesUtils:PartLoad:" + ex.Message);
                return(null);
            }
            finally
            {
                partLoadStatus1.Dispose();
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 设置显示部件
        /// </summary>
        /// <param name="part"></param>
        public static void SetPartWork(NXOpen.Assemblies.Component comp)
        {
            Part workPart    = theSession.Parts.Work;
            Part displayPart = theSession.Parts.Display;

            NXOpen.PartLoadStatus partLoadStatus1 = null;
            try
            {
                theSession.Parts.SetWorkComponent(comp, NXOpen.PartCollection.RefsetOption.Entire, NXOpen.PartCollection.WorkComponentOption.Visible, out partLoadStatus1);
            }
            catch (Exception ex)
            {
                LogMgr.WriteLog("PartUtils.SetPartWork" + ex.Message);
            }
            finally
            {
                workPart = theSession.Parts.Work;
                if (partLoadStatus1 != null)
                {
                    partLoadStatus1.Dispose();
                }
            }
        }