예제 #1
0
        /// <summary>
        /// 通过行获取数据
        /// </summary>
        /// <param name="row"></param>
        public static ElectrodeSetValueInfo GetInfoForDataRow(DataRow row)
        {
            ElectrodeSetValueInfo info = new ElectrodeSetValueInfo();

            for (int i = 0; i < row.Table.Columns.Count; i++)
            {
                try
                {
                    PropertyInfo propertyInfo = info.GetType().GetProperty(row.Table.Columns[i].ColumnName);
                    if (propertyInfo != null && row[i] != DBNull.Value)
                    {
                        propertyInfo.SetValue(info, row[i], null);
                    }
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            try
            {
                info.EleSetValue[0] = Convert.ToDouble(row["EleSetValueX"]);
                info.EleSetValue[1] = Convert.ToDouble(row["EleSetValueY"]);
                info.EleSetValue[2] = Convert.ToDouble(row["EleSetValueZ"]);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(info);
        }
예제 #2
0
        /// <summary>
        ///创建行
        /// </summary>
        /// <param name="row"></param>
        public void CreateDataRow(ref DataRow row)
        {
            ElectrodeSetValueInfo info = this.Clone() as ElectrodeSetValueInfo;

            foreach (PropertyInfo propertyInfo in typeof(ElectrodeSetValueInfo).GetProperties())
            {
                try
                {
                    row[propertyInfo.Name] = propertyInfo.GetValue(info, null);
                }
                catch (Exception ex)
                {
                    throw ex;
                }
            }
            try
            {
                row["EleSetValueX"] = info.EleSetValue[0];
                row["EleSetValueY"] = info.EleSetValue[1];
                row["EleSetValueZ"] = info.EleSetValue[2];
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #3
0
 /// <summary>
 /// 读取属性
 /// </summary>
 public static ElectrodeAllInfo GetAttribute(NXObject obj)
 {
     try
     {
         ElectrodeRemarksInfo     rem   = ElectrodeRemarksInfo.GetAttribute(obj);
         ElectrodeCAMInfo         cam   = ElectrodeCAMInfo.GetAttribute(obj);
         ElectrodeGapValueInfo    gap   = ElectrodeGapValueInfo.GetAttribute(obj);
         ElectrodePitchInfo       pitch = ElectrodePitchInfo.GetAttribute(obj);
         ElectrodePreparationInfo pre   = ElectrodePreparationInfo.GetAttribute(obj);
         ElectrodeSetValueInfo    sv    = ElectrodeSetValueInfo.GetAttribute(obj);
         ElectrodeNameInfo        name  = ElectrodeNameInfo.GetAttribute(obj);
         ElectrodeDatumInfo       da    = ElectrodeDatumInfo.GetAttribute(obj);
         return(new ElectrodeAllInfo()
         {
             Remarks = rem,
             CAM = cam,
             GapValue = gap,
             Pitch = pitch,
             Preparetion = pre,
             SetValue = sv,
             Name = name,
             Datum = da
         });
     }
     catch (NXException ex)
     {
         throw ex;
     }
 }
예제 #4
0
        /// <summary>
        /// 获取边
        /// </summary>
        /// <param name="xEdge"></param>
        /// <param name="yEdge"></param>
        public void GetEdge(out List <Edge> xEdge, out Point centerCom)
        {
            xEdge     = new List <Edge>();
            centerCom = null;
            string         str = "";
            ElectrodeModel ele = null;

            foreach (ElectrodeModel em in eleModels)
            {
                if (em.Info.AllInfo.SetValue.Positioning == "" || em.Info.AllInfo.SetValue.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    ele = em;
                }
            }
            if (ele == null)
            {
                return;
            }

            List <Face> faces = new List <Face>();

            faces.AddRange(ele.PartTag.Bodies.ToArray()[0].GetFaces());
            Point elePoint = ele.GetSetPoint();

            faces.Sort(delegate(Face a, Face b)
            {
                FaceData data1 = FaceUtils.AskFaceData(a);
                FaceData data2 = FaceUtils.AskFaceData(b);
                return(data1.Point.Z.CompareTo((data2.Point.Z)));
            });
            foreach (Component ct in AssmbliesUtils.GetPartComp(this.PartTag, ele.PartTag))
            {
                ElectrodeSetValueInfo value = ElectrodeSetValueInfo.GetAttribute(ct);
                if (value.Positioning == "" || value.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                {
                    centerCom = AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, elePoint.Tag) as Point;
                    foreach (Edge eg in faces[10].GetEdges())
                    {
                        NXOpen.UF.UFEval.Line lineData;
                        if (EdgeUtils.GetLineData(eg, out lineData, ref str))
                        {
                            if (UMathUtils.IsEqual(lineData.start[1], lineData.end[1]))
                            {
                                xEdge.Add(AssmbliesUtils.GetNXObjectOfOcc(ct.Tag, eg.Tag) as Edge);
                            }
                        }
                    }
                }
            }
        }
예제 #5
0
        /// <summary>
        /// 获取隐藏工件
        /// </summary>
        /// <param name="setValueHidden"></param>
        /// <param name="eleHidden"></param>
        public void GetHidden(out List <Component> setValueHidden, out List <Component> eleHidden)
        {
            List <Component> all = new List <Component>();

            setValueHidden = new List <Component>();
            eleHidden      = new List <Component>();
            foreach (NXOpen.Assemblies.Component ct in this.PartTag.ComponentAssembly.RootComponent.GetChildren())
            {
                //  all.Add(ct);
                ct.Blank();
                foreach (Component co in ct.GetChildren())
                {
                    co.Unblank();
                    Component[] coms = co.GetChildren();
                    if (coms.Length > 0)
                    {
                        all.AddRange(coms);
                        continue;
                    }
                    all.Add(co);
                }
            }
            setValueHidden.AddRange(all);
            eleHidden.AddRange(all);
            foreach (ElectrodeModel em in eleModels)
            {
                List <Component> elecom = AssmbliesUtils.GetPartComp(this.PartTag, em.PartTag);
                foreach (Component eleCt in elecom)
                {
                    eleCt.Unblank();
                    setValueHidden.Remove(eleCt);
                    if (em.Info.AllInfo.SetValue.Positioning == "" || em.Info.AllInfo.SetValue.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                    {
                        ElectrodeSetValueInfo value = ElectrodeSetValueInfo.GetAttribute(eleCt);
                        if (value.Positioning == "" || value.Positioning.Equals("A", StringComparison.CurrentCultureIgnoreCase))
                        {
                            eleHidden.Remove(eleCt);
                        }
                    }
                }
            }
            Part workpiecePart = this.work.GetHostWorkpiece();

            foreach (Component ct in AssmbliesUtils.GetPartComp(this.PartTag, workpiecePart))
            {
                setValueHidden.Remove(ct);
            }
        }
예제 #6
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);
            }
        }
예제 #7
0
        /// <summary>
        /// 读取属性
        /// </summary>
        public static ElectrodeSetValueInfo GetAttribute(NXObject obj)
        {
            ElectrodeSetValueInfo info = new ElectrodeSetValueInfo();

            try
            {
                info.ContactArea       = AttributeUtils.GetAttrForDouble(obj, "ContactArea");
                info.ProjectedArea     = AttributeUtils.GetAttrForDouble(obj, "ProjectedArea");
                info.Positioning       = AttributeUtils.GetAttrForString(obj, "Positioning");
                info.PositioningRemark = AttributeUtils.GetAttrForString(obj, "PositioningRemark");
                for (int i = 0; i < 3; i++)
                {
                    info.EleSetValue[i] = AttributeUtils.GetAttrForDouble(obj, "EleSetValue", i);
                }
                return(info);
            }
            catch (NXException ex)
            {
                throw ex;
            }
        }
예제 #8
0
        /// <summary>
        /// 创建表头
        /// </summary>
        /// <param name="table"></param>
        public static DataTable CreateDataTable()
        {
            try
            {
                DataTable table = new DataTable();
                ElectrodeCAMInfo.CreateDataTable(ref table);
                ElectrodeDatumInfo.CreateDataTable(ref table);
                ElectrodeGapValueInfo.CreateDataTable(ref table);
                ElectrodeNameInfo.CreateDataTable(ref table);

                ElectrodePitchInfo.CreateDataTable(ref table);
                ElectrodePreparationInfo.CreateDataTable(ref table);
                ElectrodeRemarksInfo.CreateDataTable(ref table);
                ElectrodeSetValueInfo.CreateDataTable(ref table);
                return(table);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
예제 #9
0
 /// <summary>
 /// 通过行获取数据
 /// </summary>
 /// <param name="row"></param>
 public static ElectrodeAllInfo GetInfoForDataRow(DataRow row)
 {
     try
     {
         ElectrodeAllInfo info = new ElectrodeAllInfo()
         {
             CAM         = ElectrodeCAMInfo.GetInfoForDataRow(row),
             Datum       = ElectrodeDatumInfo.GetInfoForDataRow(row),
             GapValue    = ElectrodeGapValueInfo.GetInfoForDataRow(row),
             Name        = ElectrodeNameInfo.GetInfoForDataRow(row),
             Pitch       = ElectrodePitchInfo.GetInfoForDataRow(row),
             Preparetion = ElectrodePreparationInfo.GetInfoForDataRow(row),
             Remarks     = ElectrodeRemarksInfo.GetInfoForDataRow(row),
             SetValue    = ElectrodeSetValueInfo.GetInfoForDataRow(row)
         };
         return(info);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }