/// <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="csys"></param>
        /// <param name="eleCt"></param>
        private void AskSetVaule(CartesianCoordinateSystem csys, ElectrodeSetValueInfo setValue, Component eleCt, ref List <string> err)
        {
            Part    elePart  = eleCt.Prototype as Part;
            Point3d setPoint = new Point3d(setValue.EleSetValue[0], setValue.EleSetValue[1], setValue.EleSetValue[2]);
            Point   pt       = GetSetPoint(elePart);

            if (pt == null)
            {
                err.Add(elePart.Name + "-" + setValue.Positioning + "               无法找到设定点!");
            }
            else if (!UMathUtils.IsEqual(setPoint, GetSetWorkPoint3d(pt, eleCt)))
            {
                err.Add(elePart.Name + "-" + setValue.Positioning + "                   设定值错误!");
            }
            Body     eleBody = GetOccsInBods(eleCt);
            BodyInfo info    = GetDischargeFace(csys, eleBody);

            if (info != null)
            {
                double newArea = info.GetProjectedArea(csys, work.Info.Matr);
                if (setValue.ProjectedArea >= 2 * newArea)
                {
                    setValue.ProjectedArea = newArea;
                    setValue.ContactArea   = info.ContactArea;
                    setValue.SetAttribute(eleCt);
                }
            }
        }
        /// <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);
            }
        }
Exemple #4
0
        /// <summary>
        /// 获取设定值
        /// </summary>
        /// <returns></returns>
        private ElectrodeSetValueInfo GetEleSetValue()
        {
            ElectrodeSetValueInfo setValue = new ElectrodeSetValueInfo();

            setValue.EleSetValue[0] = double.Parse(this.textBox_eleX.Text);
            setValue.EleSetValue[1] = double.Parse(this.textBox_eleY.Text);
            setValue.EleSetValue[2] = double.Parse(this.textBox_eleZ.Text);
            setValue.ContactArea    = condition.ToolhInfo[0].GetAllContactArea();
            setValue.ProjectedArea  = condition.ToolhInfo[0].GetProjectedArea(work.Info.Matr);
            setValue.Positioning    = condition.ToolhInfo[0].ToolhName;
            return(setValue);
        }
Exemple #5
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);
            }
        }
Exemple #6
0
        /// <summary>
        /// 反求单齿设置值
        /// </summary>
        /// <param name="setValue"></param>
        /// <param name="pitch"></param>
        /// <param name="pre"></param>
        /// <param name="zDatum"></param>
        /// <returns></returns>
        private Point3d GetSingleHeadSetValue(ElectrodeSetValueInfo setValue, ElectrodePitchInfo pitch, ElectrodePreparationInfo pre, bool zDatum)
        {
            Point3d temp = new Point3d(setValue.EleSetValue[0], setValue.EleSetValue[1], setValue.EleSetValue[2]);
            double  x1   = temp.X - (pitch.PitchXNum - 1) * pitch.PitchX / 2;
            double  y1   = temp.Y - (pitch.PitchYNum - 1) * pitch.PitchY / 2;

            if (zDatum)
            {
                if (pre.Preparation[0] > pre.Preparation[1])
                {
                    x1 = temp.X - (pitch.PitchXNum - 2) * pitch.PitchX / 2;
                }
                else
                {
                    y1 = temp.Y - (pitch.PitchYNum - 2) * pitch.PitchY / 2;
                }
            }
            return(new Point3d(x1, y1, temp.Z));
        }
        /// <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);
            }
        }
        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 #9
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);
            }
        }