/// <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);
        }
        /// <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);
            }
        }
Beispiel #3
0
        /// <summary>
        /// 修改设定值
        /// </summary>
        /// <param name="asm"></param>
        /// <returns></returns>
        public bool AlterEleSetValue()
        {
            List <ElectrodeModel> eleModels = new List <ElectrodeModel>();

            try
            {
                foreach (Part pt in Session.GetSession().Parts)
                {
                    List <NXOpen.Assemblies.Component> ct = AssmbliesUtils.GetPartComp(this.PartTag, pt);
                    if (ct.Count > 0 && ElectrodeModel.IsElectrode(pt))
                    {
                        eleModels.Add(new ElectrodeModel(pt));
                    }
                }
                foreach (ElectrodeModel em in eleModels)
                {
                    List <Component> eleCt = AssmbliesUtils.GetPartComp(this.PartTag, em.PartTag);
                    Point            pt    = em.GetSetPoint();
                    foreach (Component ct in eleCt)
                    {
                        Point   ptOcc = AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, pt.Tag) as Point;
                        Point3d value = ptOcc.Coordinates;
                        this.Info.Matr.ApplyPos(ref value);
                        ElectrodeSetValueInfo setValue    = ElectrodeSetValueInfo.GetAttribute(ct);
                        ElectrodeSetValueInfo newSetValue = setValue.Clone() as ElectrodeSetValueInfo;
                        newSetValue.EleSetValue = new double[] { value.X, value.Y, value.Z };
                        if (setValue.Positioning == "" || setValue.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                        {
                            newSetValue.SetAttribute(em.PartTag);
                        }
                        else
                        {
                            NXObject obj = AssmbliesUtils.GetOccOfInstance(ct.Tag);
                            newSetValue.SetAttribute(obj);
                        }
                    }
                }

                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("修改电极设定值错误!" + ex.Message);
                return(false);
            }
        }
Beispiel #4
0
        private bool UpdateAttr(NXOpen.Assemblies.Component eleAsmComp)
        {
            ElectrodeAllInfo      all          = newAllInfo.Clone() as ElectrodeAllInfo;
            ElectrodeSetValueInfo setValueInfo = ElectrodeSetValueInfo.GetAttribute(eleAsmComp);

            all.SetValue = setValueInfo;
            try
            {
                NXObject obj = AssmbliesUtils.GetOccOfInstance(eleAsmComp.Tag);
                all.SetAttribute(obj);
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("移动组件错误!" + ex.Message);
                return(false);
            }
        }
        /// <summary>
        /// AB齿跑位
        /// </summary>
        /// <param name="eleComp"></param>
        public void MoveEleComp(NXOpen.Assemblies.Component eleComp)
        {
            for (int i = 1; i < condition.ToolhInfo.Count; i++)
            {
                Vector3d temp = new Vector3d();
                temp.X = -condition.ToolhInfo[i].Offset[0];
                temp.Y = -condition.ToolhInfo[i].Offset[1];
                temp.Z = 0;
                NXOpen.Assemblies.Component ct = AssmbliesUtils.MoveCompCopyPart(eleComp, temp, condition.Work.Info.Matr);
                NXObject instance = AssmbliesUtils.GetOccOfInstance(ct.Tag);
                ElectrodeSetValueInfo setValue = allInfo.SetValue.Clone() as ElectrodeSetValueInfo;
                setValue.EleSetValue[0] = setValue.EleSetValue[0] + temp.X;
                setValue.EleSetValue[1] = setValue.EleSetValue[1] + temp.Y;

                setValue.ContactArea   = condition.ToolhInfo[i].GetAllContactArea();
                setValue.ProjectedArea = condition.ToolhInfo[i].GetProjectedArea(condition.Work.Info.Matr);
                setValue.Positioning   = condition.ToolhInfo[i].ToolhName;
                setValue.SetAttribute(instance);
            }
        }
Beispiel #6
0
        private List <NXObject> AskEleAllInstance(Part ele)
        {
            List <NXObject> objs = new List <NXObject>();

            foreach (NXOpen.Assemblies.Component ct in AssmbliesUtils.GetPartComp(asm.PartTag, ele))
            {
                NXObject nt = null;
                try
                {
                    nt = AssmbliesUtils.GetOccOfInstance(ct.Tag);
                }
                catch
                {
                }
                if (nt != null)
                {
                    objs.Add(nt);
                }
            }
            return(objs);
        }
Beispiel #7
0
        /// <summary>
        /// 移动体
        /// </summary>
        /// <param name="eleAsmComp"></param>
        /// <returns></returns>
        private bool UpdateMoveComp(NXOpen.Assemblies.Component eleAsmComp)
        {
            ElectrodeAllInfo      all          = newAllInfo.Clone() as ElectrodeAllInfo;
            ElectrodeSetValueInfo setValueInfo = ElectrodeSetValueInfo.GetAttribute(eleAsmComp);
            Part                 workPt        = eleAsmComp.Parent.Prototype as Part;
            WorkModel            work          = new WorkModel(workPt);
            ElectrodePitchUpdate pitchUpdate   = new ElectrodePitchUpdate(oldAllInfo.Pitch, newAllInfo.Pitch);
            Vector3d             temp          = pitchUpdate.GetIncrement();

            double[] setValue = pitchUpdate.GetNewSetValue(setValueInfo.EleSetValue);
            setValueInfo.EleSetValue = setValue;
            all.SetValue             = setValueInfo;
            try
            {
                PartUtils.SetPartDisplay(asm);
                AssmbliesUtils.MoveCompPart(eleAsmComp, temp, work.Info.Matr);
                NXObject obj = AssmbliesUtils.GetOccOfInstance(eleAsmComp.Tag);
                foreach (NXOpen.Assemblies.Component ct in AssmbliesUtils.GetPartComp(work.PartTag, eleModel.PartTag))
                {
                    NXObject tem = AssmbliesUtils.GetOccOfInstance(ct.Tag);
                    if (tem.Equals(obj))
                    {
                        PartUtils.SetPartDisplay(work.PartTag);
                        AssmbliesUtils.MoveCompPart(ct, temp, work.Info.Matr);
                    }
                }
                PartUtils.SetPartDisplay(asm);
                all.SetAttribute(obj);
                return(true);
            }
            catch (NXException ex)
            {
                ClassItem.WriteLogFile("移动组件错误!" + ex.Message);
                return(false);
            }
        }