Example #1
0
        internal static Snap.NX.Note CreateNote(string[] text, Position origin, Snap.Orientation matrix, TextStyle textStyle)
        {
            PmiNoteBuilder builder = Globals.WorkPart.NXOpenPart.Annotations.CreatePmiNoteBuilder(null);

            builder.Style.LetteringStyle.GeneralTextColor     = Snap.Color.NXColor(textStyle.Color);
            builder.Style.LetteringStyle.GeneralTextFont      = textStyle.FontIndex;
            builder.Style.LetteringStyle.GeneralTextLineWidth = (LineWidth)(textStyle.StrokeWidth + 1);
            double num2 = textStyle.FontSize / 72.0;
            double num3 = num2 * Globals.InchesPerUnit;

            builder.Style.LetteringStyle.GeneralTextSize             = num3;
            builder.Style.LetteringStyle.GeneralTextCharSpaceFactor  = textStyle.CharSpaceFactor;
            builder.Style.LetteringStyle.GeneralTextAspectRatio      = textStyle.AspectRatio;
            builder.Style.LetteringStyle.GeneralTextLineSpaceFactor  = textStyle.LineSpaceFactor;
            builder.Style.LetteringStyle.HorizontalTextJustification = (NXOpen.Annotations.TextJustification)textStyle.HorizontalTextJustification;
            builder.Style.LetteringStyle.Angle = textStyle.LineAngle;
            builder.VerticalText = textStyle.IsVertical;
            builder.Text.SetEditorText(text);
            builder.Origin.Anchor            = (NXOpen.Annotations.OriginBuilder.AlignmentPosition)(textStyle.AlignmentPosition - 1);
            builder.Origin.OriginPoint       = (Point3d)origin;
            builder.Origin.Plane.PlaneMethod = PlaneBuilder.PlaneMethodType.UserDefined;
            Xform xform = Globals.NXOpenWorkPart.Xforms.CreateXform((Point3d)origin, (Matrix3x3)matrix, SmartObject.UpdateOption.DontUpdate, 1.0);

            builder.Origin.Plane.UserDefinedPlane = xform;
            NXOpen.NXObject obj2 = builder.Commit();
            builder.Destroy();
            return(new Snap.NX.Note((PmiNote)obj2));
        }
Example #2
0
    public override void Apply()
    {
        var face        = GetFace();
        var faceDirOri  = new Snap.Orientation(face.GetFaceDirection());
        var uBoxUV      = face.BoxUV;
        var centerPoint = face.Position((uBoxUV.MaxU + uBoxUV.MinU) / 2, (uBoxUV.MaxV + uBoxUV.MinV) / 2);
        var point       = face.Position(uBoxUV.MaxU, uBoxUV.MaxV);
        var point1      = face.Position(uBoxUV.MaxU, uBoxUV.MinV);

        var lstPoint  = new List <Snap.Position>();
        var rPoint_01 = centerPoint - (Snap.Position.Distance(point, centerPoint) * (Snap.Vector.Unit(centerPoint - point)));
        var rPoint_02 = centerPoint + (Snap.Position.Distance(point, centerPoint) * (Snap.Vector.Unit(centerPoint - point)));

        var rPoint1 = centerPoint - (Snap.Position.Distance(point1, centerPoint) * (Snap.Vector.Unit(centerPoint - point1)));
        var rPoint2 = centerPoint + (Snap.Position.Distance(point1, centerPoint) * (Snap.Vector.Unit(centerPoint - point1)));

        if (Snap.Compute.Distance(rPoint1, face) + Snap.Compute.Distance(rPoint2, face) < Snap.Compute.Distance(rPoint_01, face) + Snap.Compute.Distance(rPoint_02, face))
        {
            rPoint_01 = rPoint1;
            rPoint_02 = rPoint2;
        }
        var line = Snap.Create.Line(rPoint_01, rPoint_02);

        line.Layer = face.Layer;
        line.Color = System.Drawing.Color.Blue;
    }
Example #3
0
        /// <summary>
        /// TODO PH ADD
        /// </summary>
        public static Transform CreateRotation(Snap.Orientation orientation1, Snap.Orientation orientation2)
        {
            int       num;
            UFSession uFSession = Globals.UFSession;

            double[] matrix    = new double[12];
            double[] numArray2 = Snap.Math.MatrixMath.MatrixToVector(orientation1.Array);
            numArray2[0] = orientation1.AxisZ.X;
            numArray2[1] = orientation1.AxisZ.Y;
            numArray2[2] = orientation1.AxisZ.Z;
            numArray2[3] = orientation1.AxisX.X;
            numArray2[4] = orientation1.AxisX.Y;
            numArray2[5] = orientation1.AxisX.Z;
            numArray2[6] = orientation1.AxisY.X;
            numArray2[7] = orientation1.AxisY.Y;
            numArray2[8] = orientation1.AxisY.Z;


            double[] numArray3 = Snap.Math.MatrixMath.MatrixToVector(orientation2.Array);
            numArray3[0] = orientation2.AxisZ.X;
            numArray3[1] = orientation2.AxisZ.Y;
            numArray3[2] = orientation2.AxisZ.Z;
            numArray3[3] = orientation2.AxisX.X;
            numArray3[4] = orientation2.AxisX.Y;
            numArray3[5] = orientation2.AxisX.Z;
            numArray3[6] = orientation2.AxisY.X;
            numArray3[7] = orientation2.AxisY.Y;
            numArray3[8] = orientation2.AxisY.Z;
            uFSession.Trns.CreateCsysMappingMatrix(numArray2, numArray3, matrix, out num);
            return(new Transform(matrix));
        }
Example #4
0
        /// <summary>
        /// 获取平面投影面积
        /// </summary>
        public static double GetPlaneProjectArea(this Snap.NX.Face face, Snap.Vector baseDir)
        {
            var topFaceDir         = -baseDir;
            var topFaceOrientation = new Snap.Orientation(topFaceDir);
            var box = SnapEx.Ex.AcsToWcsBox3d(face.BoxEx(), topFaceOrientation);

            return(System.Math.Abs(box.MinX - box.MaxX) * System.Math.Abs(box.MinY - box.MaxY));
        }
Example #5
0
        public static Vector MapAcsToWcs(Vector absVector, Snap.Orientation wcs)
        {
            Vector axisX = wcs.AxisX;
            Vector axisY = wcs.AxisY;
            Vector axisZ = wcs.AxisZ;

            return(new Vector((double)(absVector * axisX), (double)(absVector * axisY), (double)(absVector * axisZ)));
        }
Example #6
0
 internal static Snap.NX.Torus CreateTorus(Snap.Position axisPoint, Vector axisVector, double majorRadius, double minorRadius)
 {
     Snap.Orientation orientation = new Snap.Orientation(axisVector);
     Snap.Position    center      = axisPoint + ((Snap.Position)(majorRadius * orientation.AxisX));
     Snap.NX.Arc      arc         = Create.Circle(center, orientation.AxisY, minorRadius);
     Snap.NX.ICurve[] curves      = new Snap.NX.ICurve[] { arc };
     return(new Snap.NX.Torus(Create.Revolve(curves, axisPoint, axisVector).NXOpenRevolve));
 }
Example #7
0
        internal static Snap.NX.Arc CreateArc(Position center, Vector axisX, Vector axisY, double radius, double angle1, double angle2)
        {
            double num        = 0.017453292519943295;
            double startAngle = angle1 * num;
            double endAngle   = angle2 * num;

            Snap.Orientation rotation = new Snap.Orientation(axisX, axisY);
            Snap.NX.Matrix   matrix   = new Snap.NX.Matrix(rotation);
            return(new Snap.NX.Arc(Globals.NXOpenWorkPart.Curves.CreateArc((Point3d)center, (NXMatrix)matrix, radius, startAngle, endAngle)));
        }
Example #8
0
        public static Transform CreateRotation(Snap.Orientation orientation)
        {
            int       num;
            UFSession uFSession = Globals.UFSession;

            double[] matrix    = new double[12];
            double[] numArray2 = Snap.Math.MatrixMath.MatrixToVector(Snap.Orientation.Identity.Array);
            double[] numArray3 = Snap.Math.MatrixMath.MatrixToVector(orientation.Array);
            uFSession.Trns.CreateCsysMappingMatrix(numArray2, numArray3, matrix, out num);
            return(new Transform(matrix));
        }
Example #9
0
        internal static Snap.NX.DatumCsys CreateDatumCsys(Position origin, Vector axisX, Vector axisY)
        {
            NXOpen.Part workPart = (NXOpen.Part)Globals.WorkPart;
            NXOpen.Features.DatumCsysBuilder featureBuilder = workPart.Features.CreateDatumCsysBuilder(null);
            Snap.Orientation          orientation           = new Snap.Orientation(axisX, axisY);
            Xform                     xform  = workPart.Xforms.CreateXform((Point3d)origin, (Matrix3x3)orientation, SmartObject.UpdateOption.WithinModeling, 1.0);
            CartesianCoordinateSystem system = workPart.CoordinateSystems.CreateCoordinateSystem(xform, SmartObject.UpdateOption.WithinModeling);

            featureBuilder.Csys = system;
            NXOpen.Features.DatumCsys datumCsys = (NXOpen.Features.DatumCsys)Snap.NX.Feature.CommitFeature(featureBuilder);
            featureBuilder.Destroy();
            return(new Snap.NX.DatumCsys(datumCsys));
        }
Example #10
0
        internal static Snap.NX.Torus CreateTorus(Snap.Position center, Snap.Orientation matrix, double majorRadius, double minorRadius, Box2d boxUV)
        {
            Vector axisX = matrix.AxisX;
            Vector axisZ = matrix.AxisZ;

            Snap.Orientation orientation = new Snap.Orientation(axisX, axisZ);
            Snap.Position    position    = center + ((Snap.Position)(majorRadius * matrix.AxisX));
            Snap.NX.Arc      arc         = Create.Arc(position, orientation, minorRadius, boxUV.MinV, boxUV.MaxV);
            Snap.NX.ICurve[] curves      = new Snap.NX.ICurve[] { arc };
            double           x           = matrix.AxisZ.X;
            double           y           = matrix.AxisZ.Y;
            double           z           = matrix.AxisZ.Z;
            string           str         = Snap.Number.ToString(boxUV.MinU);
            string           str2        = Snap.Number.ToString(boxUV.MaxU);

            Snap.Number[] angles = new Snap.Number[] { str, str2 };
            return(new Snap.NX.Torus(Create.RevolveSheet(curves, center, matrix.AxisZ, angles).NXOpenRevolve));
        }
Example #11
0
    void SetEactElec(Snap.NX.Body body, Snap.NX.Face baseFace = null, Snap.NX.Face topFace = null, Snap.NX.Point basePoint = null)
    {
        selectBaseFace.SelectedObjects = new Snap.NX.NXObject[] { };
        selectTopFace.SelectedObjects  = new Snap.NX.NXObject[] { };
        selectBaseFacePointEx.Position = new Snap.Position();
        var pos = new Snap.Position();

        ElecManage.Electrode.GetEactElectrode(body, ref topFace, ref baseFace, ref basePoint, ref pos);
        if (baseFace != null)
        {
            selectBaseFace.SelectedObjects = new Snap.NX.NXObject[] { baseFace };
        }
        if (topFace != null)
        {
            selectTopFace.SelectedObjects = new Snap.NX.NXObject[] { topFace };
        }
        selectBaseFacePointEx.Position = pos;
        if (baseFace != null && topFace != null)
        {
            //更新尺寸
            var info = GetElecInfo(body);
            if (info != null)
            {
                strElecSize.Value        = info.ElecSize;
                strElecCuttingSize.Value = info.ElecCuttingSize(_configData, EactConfig.MatchJiaju.GetMatchJiajuValue(_configData, cbbChuckType.SelectedIndex));
            }
            else if (groupSElec.Show) //异形电极
            {
                var tempInfo = new ElecManage.ElectrodeInfo(body);
                var tempOri  = new Snap.Orientation(-baseFace.GetFaceDirection());
                strElecSize.Value        = tempInfo.GetElecSize(tempOri);
                strElecCuttingSize.Value = tempInfo.ElecCuttingSize(_configData, EactConfig.MatchJiaju.GetMatchJiajuValue(_configData, cbbChuckType.SelectedIndex), tempOri);
            }
            else
            {
                strElecSize.Value        = string.Empty;
                strElecCuttingSize.Value = string.Empty;
            }
        }
    }
Example #12
0
 internal static NXOpen.CoordinateSystem CreateCoordinateSystem(Snap.Position origin, Snap.Orientation matrix)
 {
     return((NXOpen.CoordinateSystem)CreateCoordinateSystem(origin, matrix.AxisX, matrix.AxisY, matrix.AxisZ));
 }
Example #13
0
 internal Matrix(Snap.Orientation rotation)
 {
     this.NXOpenMatrix = CreateMatrix(rotation.AxisX, rotation.AxisY, rotation.AxisZ);
 }
Example #14
0
        /// <summary>
        /// 析出体
        /// </summary>
        public static NXOpen.Assemblies.Component ExtractObject(List <NXOpen.NXObject> bodies, string fileName, bool isAddComponent, bool newPart = true, Snap.Geom.Transform trans = null, Snap.Position basePoint = new Snap.Position(), Snap.Orientation orientation = null)
        {
            NXOpen.Assemblies.Component component = null;
            Session theSession  = Session.GetSession();
            Part    workPart    = theSession.Parts.Work;
            Part    displayPart = theSession.Parts.Display;

            if (newPart)
            {
                if (System.IO.File.Exists(fileName))
                {
                    System.IO.File.Delete(fileName);
                }
            }
            var objs = bodies;
            var tags = new List <NXOpen.Tag>();

            objs.ForEach(u =>
            {
                tags.Add(u.Tag);
            });

            //TODO 后期需优化
            NXOpen.UF.UFPart.ExportOptions options = new NXOpen.UF.UFPart.ExportOptions();
            options.new_part        = newPart;
            options.params_mode     = NXOpen.UF.UFPart.ExportParamsMode.RemoveParams;
            options.expression_mode = NXOpen.UF.UFPart.ExportExpMode.CopyExpDeeply;
            NXOpen.UF.UFSession.GetUFSession().Part.ExportWithOptions(
                fileName,
                tags.Count, tags.ToArray(),
                ref options
                );

            if (trans != null)
            {
                PartLoadStatus partLoadStatus1;
                var            basePart = theSession.Parts.OpenBase(fileName, out partLoadStatus1) as Part;
                if (basePart != null)
                {
                    Snap.NX.Part snapBasePart = basePart;
                    var          partAllObjs  = new List <Snap.NX.NXObject>();
                    snapBasePart.Bodies.ToList().ForEach(u => {
                        partAllObjs.Add(u);
                    });

                    snapBasePart.Lines.ToList().ForEach(u => {
                        partAllObjs.Add(u);
                    });

                    snapBasePart.Points.ToList().ForEach(u => {
                        partAllObjs.Add(u);
                    });

                    partAllObjs.ForEach(u =>
                    {
                        u.Move(trans);
                    });
                    snapBasePart.Save();
                    snapBasePart.Close(false, true);
                }
            }

            if (isAddComponent)
            {
                PartLoadStatus partLoadStatus1;
                //后期需优化
                component = workPart.ComponentAssembly.AddComponent(fileName, SnapEx.ConstString.ReferenceSetName, System.IO.Path.GetFileNameWithoutExtension(fileName), basePoint, orientation ?? new Orientation(), -1, out partLoadStatus1, true);
            }

            return(component);
        }
Example #15
0
        /// <summary>
        /// 获取投影面积
        /// </summary>
        /// <param name="face"></param>
        /// <param name="max_facet_size"></param>
        /// <returns></returns>
        public static double GetProjectionArea(Snap.NX.Face face, Snap.Orientation dir = null, double max_facet_size = 1)
        {
            var area = 0.0;

            try
            {
                var positions = new List <Snap.Position>();
                #region old code
                var parameters = new NXOpen.UF.UFFacet.Parameters();

                var ufSession = NXOpen.UF.UFSession.GetUFSession();
                var facet     = ufSession.Facet;
                facet.AskDefaultParameters(out parameters);
                parameters.max_facet_edges        = 3;
                parameters.specify_max_facet_size = true;
                parameters.max_facet_size         = max_facet_size;

                NXOpen.Tag facet_model = NXOpen.Tag.Null;
                facet.FacetSolid(face.NXOpenTag, ref parameters, out facet_model);

                if (facet_model == NXOpen.Tag.Null)
                {
                    return(area);
                }
                NXOpen.Tag solid = NXOpen.Tag.Null;
                facet.AskSolidOfModel(facet_model, out solid);
                if (solid != face.NXOpenTag)
                {
                    return(area);
                }

                int  facet_id = NXOpen.UF.UFConstants.UF_FACET_NULL_FACET_ID;
                bool isWhile  = true;
                while (isWhile)
                {
                    facet.CycleFacets(facet_model, ref facet_id);
                    if (facet_id != NXOpen.UF.UFConstants.UF_FACET_NULL_FACET_ID)
                    {
                        int num_vertices = 0;
                        facet.AskNumVertsInFacet(facet_model, facet_id, out num_vertices);
                        if (num_vertices == 3)
                        {
                            var vertices = new double[num_vertices, 3];
                            facet.AskVerticesOfFacet(facet_model, facet_id, out num_vertices, vertices);
                            double[] vecZ           = (dir ?? new Snap.Orientation()).AxisZ.Array;
                            var      projectorZAxis = new List <double[]>();
                            projectorZAxis.Add(new double[] { 0, 0, 0 });
                            projectorZAxis.Add(new double[] { 0, 0, 0 });
                            projectorZAxis.Add(new double[] { 0, 0, 0 });
                            double[] projectorZLength = { 0, 0, 0 };
                            var      verticesList     = new List <double[]>();
                            for (int x = 0; x < 3; x++)
                            {
                                var dList = new List <double>();
                                for (int y = 0; y < 3; y++)
                                {
                                    dList.Add(vertices[x, y]);
                                }
                                verticesList.Add(dList.ToArray());
                            }
                            for (int i = 0; i < num_vertices; i++)
                            {
                                var vertice = verticesList[i];
                                var zAxis   = projectorZAxis[i];
                                ufSession.Vec3.Dot(vertice, vecZ, out projectorZLength[i]);
                                ufSession.Vec3.Scale(projectorZLength[i], vecZ, zAxis);
                                ufSession.Vec3.Sub(vertice, zAxis, vertice);
                            }
                            double[] vec1         = { 0, 0, 0 }, vec2 = { .0, .0, .0 }, cross_vec = { .0, .0, .0 };
                            var      tempFaceArea = 0.0;
                            ufSession.Vec3.Sub(verticesList[1], verticesList[0], vec1);
                            ufSession.Vec3.Sub(verticesList[2], verticesList[0], vec2);
                            ufSession.Vec3.Cross(vec1, vec2, cross_vec);
                            ufSession.Vec3.Mag(cross_vec, out tempFaceArea);
                            area += tempFaceArea;
                        }
                    }
                    else
                    {
                        isWhile = false;
                    }
                }

                ufSession.Obj.DeleteObject(facet_model);
                positions = positions.Distinct().ToList();
                #endregion
            }
            catch (Exception ex)
            {
                Console.Write(ex);
                area = 0;
            }
            return(area);
        }
Example #16
0
 public static Transform CreateRotation(Snap.Orientation orientation1, Snap.Orientation orientation2)
 {
     return(CreateRotation(orientation1, orientation2, true));
 }
Example #17
0
    public static NXOpen.Body CreateElecBase(List <Snap.NX.Face> snapFaces, string partName, double qingGenValue, double distanceValue, double jizhutaiValue, double daojiaoValue, double daoyuanValue, QuadrantType type, System.Drawing.Color bodyColor, bool isExtract = true)
    {
        var bodys     = new List <Snap.NX.Body>();
        var firstFace = snapFaces.FirstOrDefault();

        //Z轴方向(决定坐标系)  TODO后期需修改
        var normal = Snap.Vector.Unit(firstFace.Normal(firstFace.BoxUV.MinU, firstFace.BoxUV.MinV));

        snapFaces.ForEach(u =>
        {
            bodys.Add(u.Body);
        });

        //清根深度
        snapFaces.ForEach(u =>
        {
            if (qingGenValue > 0)
            {
                var tempOrigin = u.Position(u.BoxUV.MinU, u.BoxUV.MinV);
                var tempCorner = u.Position(u.BoxUV.MaxU, u.BoxUV.MaxV);
                var extrude    = Snap.Create.Extrude(u.EdgeCurves, normal, qingGenValue);
                bodys.Add(extrude.Body);
            }
        });

        //创建基准台
        var positions = GetBox2dPosition(snapFaces);
        var minUV     = positions.First();
        var maxUV     = positions.Last();

        var origin = minUV + (distanceValue * Snap.Vector.Unit(minUV - maxUV));

        origin += qingGenValue * Snap.Vector.Unit(normal);

        var corner = maxUV + (distanceValue * Snap.Vector.Unit(maxUV - minUV));

        corner += qingGenValue * Snap.Vector.Unit(normal);

        var orientation = new Snap.Orientation(normal);
        var block       = Snap.Create.Block(orientation, origin, corner, jizhutaiValue);

        //设置基准面
        var             baseFace = SetBaseFace(block, normal);
        List <Position> d        = new List <Position>();

        baseFace.Edges.ToList().ForEach(u => {
            if (!d.Contains(u.StartPoint))
            {
                d.Add(u.StartPoint);
            }
            if (!d.Contains(u.EndPoint))
            {
                d.Add(u.EndPoint);
            }
        });

        //获取中心点、倒角点
        var centerPosition   = baseFace.Position((baseFace.BoxUV.MinU + baseFace.BoxUV.MaxU) / 2, (baseFace.BoxUV.MinV + baseFace.BoxUV.MaxV) / 2);
        var quadrantType     = type;
        var quadrantPosition = d.FirstOrDefault(u => SnapEx.Helper.GetQuadrantType(u, centerPosition, orientation) == quadrantType);

        var edges = block.Edges.ToList();

        baseFace.Edges.ToList().ForEach(u =>
        {
            edges.RemoveAll(e => e.StartPoint.Equals(u.StartPoint) && e.EndPoint.Equals(u.EndPoint));
        });

        foreach (var e in edges)
        {
            if (d.Contains(e.StartPoint) || d.Contains(e.EndPoint))
            {
                if (e.StartPoint.Equals(quadrantPosition) || e.EndPoint.Equals(quadrantPosition))
                {
                    //倒角
                    Create.Chamfer(e, daojiaoValue, true);
                }
                else
                {
                    //倒圆
                    Create.EdgeBlend(daoyuanValue, e);
                }
            }
        }

        //设置颜色
        block.Body.Color = bodyColor;
        bodys.ForEach(u => {
            u.Color = bodyColor;
        });

        var body = block.Body;

        var path = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Snap.Globals.WorkPart.FullPath), partName);

        if (System.IO.Directory.Exists(path))
        {
            System.IO.Directory.Delete(path, true);
        }
        System.IO.Directory.CreateDirectory(path);

        if (isExtract)
        {
            for (int i = 0; i < snapFaces.Count; i++)
            {
                var snapFace = snapFaces[i];
                snapFace.Name = SnapEx.ConstString.SelectFace;
                var tempBody     = snapFace.Body;
                var tempFileName = System.IO.Path.Combine(path, string.Format("{0}-{1}", SnapEx.ConstString.AutoElec, i + 1));
                tempBody.Name = System.IO.Path.GetFileNameWithoutExtension(tempFileName);
                SnapEx.Create.ExtractBody(new List <NXOpen.Body>()
                {
                    tempBody
                }, tempFileName, false);
                //赋属性
                var info = new SnapEx.ElecInfo();
                info.QingGenValue  = qingGenValue;
                info.DistanceValue = distanceValue;
                info.JizhutaiValue = jizhutaiValue;
                info.DaojiaoValue  = daojiaoValue;
                info.DaoyuanValue  = daoyuanValue;
                info.QuadrantType  = (int)type;
                info.BodyColor     = bodyColor.ToArgb();
                info.ElectName     = partName;
                info.Serialize(path);
            }
        }

        //求和
        var result = Create.Unite(block.Body, bodys.ToArray());

        result.Orphan();

        if (isExtract)
        {
            var fileName = System.IO.Path.Combine(path, string.Format("{0}", partName));
            SnapEx.Create.ExtractBody(new List <NXOpen.Body>()
            {
                body
            }, fileName, true);
            body.Delete();
        }

        return(body);
    }
Example #18
0
    public override void Update(NXOpen.BlockStyler.UIBlock block)
    {
        if (block == selectCuprum.NXOpenBlock)
        {
            var cuprums = Enumerable.Select(selectCuprum.SelectedObjects, u => Snap.NX.Body.Wrap(u.NXOpenTag)).ToList();
            var unNameC = cuprums.Where(u => string.IsNullOrEmpty(u.Name)).ToList();
            var nameC   = cuprums.Where(u => !string.IsNullOrEmpty(u.Name)).ToList();

            groupSElec.Show = false;
            var groupSElecShow = false;
            if (nameC.Count == 1)
            {
                var body = nameC.First();
                var info = GetElecInfo(body);
                groupSElecShow = info == null || info.IsSpecialShapeElec == "1";
                if (info == null)
                {
                    info = new ElecManage.EactElectrodeInfo(body);
                }

                if (_configData.Edition == 1)
                {
                    if ((info.KL_SIZE_HEIGHT == 0 || info.KL_SIZE_LEN == 0 || info.KL_SIZE_WIDTH == 0))
                    {
                        theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Error, "该电极未设置开料尺寸!");
                        selectCuprum.SelectedObjects = new Snap.NX.NXObject[] { };
                        return;
                    }

                    if (string.IsNullOrEmpty(info.ELEC_CLAMP_GENERAL_TYPE))
                    {
                        theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Error, "该电极未设置夹具!");
                        selectCuprum.SelectedObjects = new Snap.NX.NXObject[] { };
                        return;
                    }
                }

                SetDefaultValue(info);
                Action <bool> action = (b) =>
                {
                    groupSElec.Show = b;
                    if (b)
                    {
                        theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "异形电极,请设置相关参数!");
                        SetEactElec(body);
                    }
                };

                if (SpecialshapedElec)
                {
                    action(groupSElecShow);
                }
            }
            else if (SpecialshapedElec && unNameC.Count > 0)
            {
                theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "电极名称不能为空");
                selectCuprum.SelectedObjects = cuprums.Where(u => !string.IsNullOrEmpty(u.Name)).ToArray();
            }
            else if (SpecialshapedElec && nameC.Count > 1)
            {
                var lstMsg    = new List <string>();
                var tempNameC = nameC.Where(u => !_elecNameLst.Contains(u.Name));
                foreach (var item in tempNameC.GroupBy(u => u.Name))
                {
                    var body = item.First();
                    var info = GetElecInfo(body);
                    if (info == null)
                    {
                        lstMsg.Add(string.Format("{0}:{1}", body.Name, "异形电极"));
                        selectCuprum.SelectedObjects = cuprums.Where(u => u.Name != body.Name).ToArray();
                    }
                }
                if (lstMsg.Count > 0)
                {
                    Snap.InfoWindow.Clear();
                    lstMsg.ForEach(u => { Snap.InfoWindow.WriteLine(u); });
                }
            }

            if (_isAllowMultiple)
            {
                if (nameC.Count > 1)
                {
                    strElecName.Show = false;
                }
                else
                {
                    strElecName.Show = true;
                }

                if (cuprums.Count != 1)
                {
                    selectCuprum.AllowMultiple = true;

                    if (unNameC.Count > 0)
                    {
                        theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "电极名称不能为空");
                        selectCuprum.SelectedObjects = cuprums.Where(u => !string.IsNullOrEmpty(u.Name)).ToArray();
                    }
                }
                else
                {
                    if (string.IsNullOrEmpty(cuprums.First().Name))
                    {
                        selectCuprum.AllowMultiple = false;
                    }
                    else if (groupSElecShow)
                    {
                        selectCuprum.AllowMultiple = false;
                    }
                    else
                    {
                        selectCuprum.AllowMultiple = true;
                    }
                }
            }

            strElecSize.Show        = strElecName.Show;
            strElecCuttingSize.Show = strElecName.Show;
        }
        else if (block == cbbChuckType.NXOpenBlock ||
                 block == selectBaseFace.NXOpenBlock
                 //|| block == selectBaseFacePointEx.NXOpenBlock
                 || block == selectTopFace.NXOpenBlock
                 )
        {
            var cuprums = Enumerable.Select(selectCuprum.SelectedObjects, u => Snap.NX.Body.Wrap(u.NXOpenTag)).ToList();
            if (cuprums.Count == 1)
            {
                var info = GetElecInfo(cuprums.First());
                if (info != null)
                {
                    strElecSize.Value        = info.ElecSize;
                    strElecCuttingSize.Value = info.ElecCuttingSize(_configData, EactConfig.MatchJiaju.GetMatchJiajuValue(_configData, cbbChuckType.SelectedIndex));
                }
                else if (groupSElec.Show) //异形电极
                {
                    var tempInfo    = new ElecManage.ElectrodeInfo(cuprums.First());
                    var tempFaceDir = -Snap.Orientation.Identity.AxisZ;
                    var baseFace    = selectBaseFace.SelectedObjects.FirstOrDefault() as Snap.NX.Face;
                    if (baseFace != null)
                    {
                        tempFaceDir = -baseFace.GetFaceDirection();
                    }
                    var tempOri = new Snap.Orientation(tempFaceDir);
                    strElecSize.Value        = tempInfo.GetElecSize(tempOri);
                    strElecCuttingSize.Value = tempInfo.ElecCuttingSize(_configData, EactConfig.MatchJiaju.GetMatchJiajuValue(_configData, cbbChuckType.SelectedIndex), tempOri);
                }
                else
                {
                    strElecSize.Value        = string.Empty;
                    strElecCuttingSize.Value = string.Empty;
                }
            }
        }
        else if (block == selectBaseFace.NXOpenBlock ||
                 block == selectBaseFacePointEx.NXOpenBlock ||
                 block == selectTopFace.NXOpenBlock
                 )
        {
            //var cuprums = Enumerable.Select(selectCuprum.SelectedObjects, u => Snap.NX.Body.Wrap(u.NXOpenTag)).ToList();
            //if (cuprums.Count == 1)
            //{
            //    var basePoint = Enumerable.Select(selectBaseFacePoint.SelectedObjects, u => Snap.NX.Point.Wrap(u.NXOpenTag)).FirstOrDefault();
            //    var baseFace = Enumerable.Select(selectBaseFace.SelectedObjects, u => Snap.NX.Face.Wrap(u.NXOpenTag)).FirstOrDefault();
            //    var topFace = Enumerable.Select(selectTopFace.SelectedObjects, u => Snap.NX.Face.Wrap(u.NXOpenTag)).FirstOrDefault();
            //    SetEactElec(cuprums.FirstOrDefault(),baseFace,topFace, basePoint);
            //}
        }
    }