/// <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);
            }
        }
        /// <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);
        }
Exemple #3
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);
            }
        }
        private string GetPositionName()
        {
            List <Component> eleComs = GetEleAllComponent();

            if (eleComs != null)
            {
                List <int> names = new List <int>();
                foreach (Component ct in eleComs)
                {
                    ElectrodeSetValueInfo setValue = ElectrodeSetValueInfo.GetAttribute(ct);
                    if (setValue.Positioning != "")
                    {
                        char temp = setValue.Positioning.ToCharArray()[0];
                        names.Add((int)temp);
                    }
                }
                names.Sort();
                return(((char)(names[names.Count - 1] + 1)).ToString());
            }
            return("B");
        }
Exemple #5
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);
            }
        }