Beispiel #1
0
    void InitModelingView(EdmDraw.EdmConfig edmConfig, ElecManage.Electrode elec, bool isAutoMode = true)
    {
        if (IsInitModelingView && !isAutoMode)
        {
            return;
        }
        SnapEx.Create.ApplicationSwitchRequest(SnapEx.ApplicationType.MODELING);
        var wcsOrientation     = Electrode.GetStandardOrientation(Snap.Globals.WcsOrientation);
        var acsOrientation     = Snap.Orientation.Identity;
        var baseDirOrientation = Electrode.GetSidelongOrientation(new Snap.Orientation(-elec.BaseFace.GetFaceDirection()));
        var transR             = Snap.Geom.Transform.CreateRotation(acsOrientation, wcsOrientation);
        var transR1            = Snap.Geom.Transform.CreateRotation(baseDirOrientation, wcsOrientation);
        var draftViewLocations = edmConfig.DraftViewLocations ?? new List <EdmDraw.EdmConfig.DraftViewLocation>();

        foreach (var item in draftViewLocations)
        {
            var viewType = EdmDraw.DrawBusiness.GetEumnViewType(item.ViewType);
            var X        = new Snap.Vector(item.Xx, item.Xy, item.Xz).Copy(transR);
            var Y        = new Snap.Vector(item.Yx, item.Yy, item.Yz).Copy(transR);
            if (viewType == EdmDraw.ViewType.EACT_BOTTOM ||
                viewType == EdmDraw.ViewType.EACT_BOTTOM_FRONT ||
                viewType == EdmDraw.ViewType.EACT_BOTTOM_ISOMETRIC
                )
            {
                X = X.Copy(transR1);
                Y = Y.Copy(transR1);
            }
            EdmDraw.DrawBusiness.CreateCamera(viewType, new double[] { X.X, X.Y, X.Z, Y.X, Y.Y, Y.Z });
        }
        IsInitModelingView = true;
    }
Beispiel #2
0
        public static Electrode GetElectrode(Snap.NX.Body body)
        {
            Electrode result   = null;
            var       elecName = body.Name;
            var       faces    = body.Faces;
            //顶面
            var topFace = faces.FirstOrDefault(u => u.MatchAttrValue(UP_PART_MOLD_FACE_TYPE, BASE_BOT));
            //基准面
            var baseFace = faces.FirstOrDefault(u => u.MatchAttrValue(UP_PART_MOLD_FACE_TYPE, BASE_TOP));
            //基准台侧面
            var baseSideFaces = faces.Where(u =>
                                            u.MatchAttrValue(UP_PART_MOLD_FACE_TYPE, BASE_SIDE2) ||
                                            u.MatchAttrValue(UP_PART_MOLD_FACE_TYPE, BASE_SIDE3) ||
                                            u.MatchAttrValue(UP_PART_MOLD_FACE_TYPE, BASE_SIDE5) ||
                                            u.MatchAttrValue(UP_PART_MOLD_FACE_TYPE, BASE_SIDE6)
                                            ).ToList();
            //象限面
            var chamferFace = faces.FirstOrDefault(u => u.MatchAttrValue(UP_PART_MOLD_FACE_TYPE, BASE_CHAMFER));

            if (!string.IsNullOrEmpty(elecName) && topFace != null && baseFace != null && baseSideFaces.Count >= 4)
            {
                var model = new UPElectrode();
                model.BaseFace      = baseFace;
                model.TopFace       = topFace;
                model.BaseSideFaces = baseSideFaces.ToList();
                model.ElecBody      = body;
                model.ChamferFace   = chamferFace;
                //model.ElecHeadFaces = Electrode.GetElecHeadFaces(faces.ToList(), baseFace, out baseSideFaces);
                result = model;
                model.AllObject.Add(body);
            }
            return(result);
        }
Beispiel #3
0
        public static Electrode GetElectrode(Snap.NX.Body body)
        {
            Electrode result   = null;
            var       elecName = body.Name;
            var       faces    = body.Faces;
            //顶面
            var topFace = faces.FirstOrDefault(u => u.MatchAttrValue(ATTR_NAME_MARK, BASE_BOT));
            //基准面
            var baseFace = faces.FirstOrDefault(u => u.MatchAttrValue(ATTR_NAME_MARK, BASE_TOP));
            //基准台侧面
            var baseSideFaces = faces.Where(u => u.MatchAttrValue(ATTR_NAME_MARK, BASE_SIDE)).ToList();
            //基准点
            var elecBasePoint = Snap.Globals.WorkPart.Points.Where(u => u.MatchAttrValue(ATTR_NAME_MARK, elecName) && u.MatchAttrValue(DIM_PT, DIM_PT))
                                .OrderBy(u => Snap.Compute.Distance(u.Position, body)).FirstOrDefault();
            //象限面
            var chamferFace = faces.FirstOrDefault(u => u.MatchAttrValue(ATTR_NAME_MARK, BASE_CHAMFER));

            if (!string.IsNullOrEmpty(elecName) && topFace != null && baseFace != null && baseSideFaces.Count >= 4
                //&& elecBasePoint != null
                )
            {
                var model = new XKElectrode();
                model.BaseFace      = baseFace;
                model.TopFace       = topFace;
                model.BaseSideFaces = baseSideFaces.ToList();
                model.ElecBasePoint = elecBasePoint;
                model.ElecBody      = body;
                model.ChamferFace   = chamferFace;
                //model.ElecHeadFaces = Electrode.GetElecHeadFaces(faces.ToList(), baseFace, out baseSideFaces);
                result = model;
                model.AllObject.Add(body);
                model.AllObject.Add(elecBasePoint);
            }
            return(result);
        }
Beispiel #4
0
        public static Electrode GetElectrode(Snap.NX.Body body)
        {
            Electrode result   = null;
            var       elecName = body.Name;
            var       faces    = body.Faces;
            //顶面
            var topFace = faces.FirstOrDefault(u => u.MatchAttrValue(BASE_BOT, 1));
            //基准面
            var baseFaces = faces.Where(u => u.MatchAttrValue(BASE_TOP, 1)).ToList();
            var baseFace  = baseFaces.FirstOrDefault();

            if (baseFaces.Count > 1)
            {
                baseFace = baseFaces.OrderByDescending(u => Snap.Compute.Perimeter(u)).FirstOrDefault();
            }
            var attrValue = body.GetAttrValue(EACT_ELECT_GROUP);
            //基准点
            var elecBasePoint = Snap.Globals.WorkPart.Points.FirstOrDefault(u => !string.IsNullOrEmpty(attrValue) && u.MatchAttrValue(EACT_ELECT_GROUP, attrValue));

            if (!string.IsNullOrEmpty(elecName) && topFace != null && baseFace != null)
            {
                var model = new EactElectrode();
                model.BaseFace      = baseFace;
                model.TopFace       = topFace;
                model.ElecBasePoint = elecBasePoint;
                model.ElecBody      = body;
                result = model;
                model.AllObject.Add(body);
                if (elecBasePoint != null)
                {
                    model.AllObject.Add(elecBasePoint);
                }
            }
            return(result);
        }
Beispiel #5
0
 /// <summary>
 /// 初始化所有的面
 /// </summary>
 public virtual void InitAllFace()
 {
     if (!isInitAllFace)
     {
         GetTopFace();
         var allSideFaces = new List <Snap.NX.Face>();
         var faces        = ElecBody.Faces.ToList();
         ElecHeadFaces = Electrode.GetElecHeadFaces(faces, BaseFace, out allSideFaces);
         BaseSideFaces = Electrode.GetBaseSideFaces(BaseFace, allSideFaces);
         isInitAllFace = true;
     }
 }
Beispiel #6
0
    public override void Init()
    {
        toggle0.Value = false;
        var snapSelectCuprum = Snap.UI.Block.SelectObject.GetBlock(theDialog, selectCuprum.Name);

        snapSelectCuprum.SetFilter(Snap.NX.ObjectTypes.Type.Body);
        snapSelectCuprum.AllowMultiple = false;

        var snapSelectedPoint = Snap.UI.Block.SelectObject.GetBlock(theDialog, selectionPoint.Name);

        snapSelectedPoint.AllowMultiple = false;
        snapSelectedPoint.SetFilter(Snap.NX.ObjectTypes.Type.Face);

        tree_control0.SetOnSelectHandler(new NXOpen.BlockStyler.Tree.OnSelectCallback(OnSelectcallback));
        _electrode = null;
    }
Beispiel #7
0
        public static Electrode GetElectrode(Snap.NX.Body body)
        {
            Electrode result = null;

            Snap.NX.Face baseFace     = null;
            var          diagonalLine = GetDiagonalLine(body, out baseFace);

            if (diagonalLine != null)
            {
                var faceDirection = baseFace.GetFaceDirection();
                var model         = new JYElectrode();
                model.DiagonalLine = diagonalLine;
                model.BaseFace     = baseFace;
                model.ElecBody     = body;
                result             = model;
            }
            return(result);
        }
Beispiel #8
0
        /// <summary>
        /// 获取摄像机视角
        /// </summary>
        public static Snap.Orientation GetCameraOrientation(Snap.Orientation ori, Electrode elec = null)
        {
            var wcsOrientation = Electrode.GetStandardOrientation(Snap.Globals.WcsOrientation);
            var acsOrientation = Snap.Orientation.Identity;
            var transR         = Snap.Geom.Transform.CreateRotation(acsOrientation, wcsOrientation);

            var X = new Snap.Vector(ori.AxisX.X, ori.AxisX.Y, ori.AxisX.Z).Copy(transR);
            var Y = new Snap.Vector(ori.AxisY.X, ori.AxisY.Y, ori.AxisY.Z).Copy(transR);

            if (elec != null)
            {
                var baseDirOrientation = Electrode.GetSidelongOrientation(new Snap.Orientation(-elec.BaseFace.GetFaceDirection()));
                var transR1            = Snap.Geom.Transform.CreateRotation(baseDirOrientation, wcsOrientation);
                X = X.Copy(transR1);
                Y = Y.Copy(transR1);
            }

            return(new Snap.Orientation(X, Y));
        }
Beispiel #9
0
        public static Electrode GetElectrode(Snap.NX.Body body)
        {
            Electrode result = null;

            result = XKElectrode.GetElectrode(body);
            if (result == null)
            {
                result = UPElectrode.GetElectrode(body);
            }
            if (result == null)
            {
                result = JYElectrode.GetElectrode(body);
            }
            if (result == null)
            {
                result = EactElectrode.GetElectrode(body);
            }
            return(result);
        }
Beispiel #10
0
    void AutoSelectPoint()
    {
        DeleteNodes();
        var body       = selectCuprum.SelectedObjects.FirstOrDefault() as Snap.NX.Body;
        var pointDatas = new List <PointData>();
        var mark       = Snap.Globals.SetUndoMark(Snap.Globals.MarkVisibility.Invisible, "ComponentHelperAutoSelectPoint");

        try
        {
            pointDatas = CMMBusiness.AutoSelPoint(_electrode, _config, false);
        }
        catch (Exception ex)
        {
            pointDatas = new List <PointData>();
            selectCuprum.SelectedObjects = new Snap.NX.NXObject[] { };
            _electrode = null;
            NXOpen.UF.UFSession.GetUFSession().Ui.DisplayMessage(ex.Message, 1);
        }

        Snap.Globals.UndoToMark(mark, "ComponentHelperAutoSelectPoint");
        UFDisp(pointDatas);
    }
Beispiel #11
0
 public override void Update(UIBlock block)
 {
     if (bodySelect0.NXOpenBlock == block)
     {
         _electrode = null;
         dic.Clear();
         var body = bodySelect0.SelectedObjects.FirstOrDefault() as Snap.NX.Body;
         if (body != null)
         {
             var faces = body.Faces.ToList();
             faces.ForEach(u =>
             {
                 dic.Add(u.NXOpenTag, u.GetDraftAngle(vector0.Direction));
             });
             _electrode = ElecManage.Electrode.GetElectrode(body);
             if (_electrode != null)
             {
                 _electrode.InitAllFace();
             }
         }
     }
     RefreshData();
 }
Beispiel #12
0
    void CreateEACT_BOTTOMView(NXOpen.Drawings.DrawingSheet ds, List <NXOpen.TaggedObject> selections, Snap.Position pos, Snap.Position size, ElecManage.Electrode electrode, EdmDraw.EdmConfig edmConfig)
    {
        var bottomView             = EdmDraw.DrawBusiness.CreateBaseView(ds, GetModelingView(EdmDraw.ViewType.EACT_BOTTOM).Tag, selections, pos, size, edmConfig);
        var bottomViewBorderPoints = EdmDraw.DrawBusiness.GetBorderPoint(bottomView, electrode.ElecBody);

        var yPlusSideFace  = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Point(bottomViewBorderPoints[1])); }, bottomView.Tag);
        var yMinusSideFace = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Point(bottomViewBorderPoints[0])); }, bottomView.Tag);
        var xPlusSideFace  = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Line(bottomViewBorderPoints[0], bottomViewBorderPoints[1])); }, bottomView.Tag);
        var xMinusSideFace = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Line(bottomViewBorderPoints[2], bottomViewBorderPoints[3])); }, bottomView.Tag);

        //电极仰视图
        EdmDraw.DrawBusiness.CreateVerticalDim(bottomView.Tag, yPlusSideFace.NXOpenTag, yMinusSideFace.NXOpenTag,
                                               new Snap.Position(bottomView.GetDrawingReferencePoint().X + (EdmDraw.DrawBusiness.GetBorderSize(bottomView.Tag).X / 2), bottomView.GetDrawingReferencePoint().Y, 0));
        EdmDraw.DrawBusiness.CreatePerpendicularDim(bottomView.Tag, xPlusSideFace.NXOpenTag, xMinusSideFace.NXOpenTag,
                                                    new Snap.Position(bottomView.GetDrawingReferencePoint().X, bottomView.GetDrawingReferencePoint().Y + (EdmDraw.DrawBusiness.GetBorderSize(bottomView.Tag).Y / 2), 0));

        var bottomViewElecHeadBorderPoints = EdmDraw.DrawBusiness.GetBorderPoint(bottomView, electrode.ElecHeadFaces);

        var yPlusElectrodeEdge  = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Point(bottomViewElecHeadBorderPoints[1])); }, bottomView.Tag);
        var yMinusElectrodeEdge = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Point(bottomViewElecHeadBorderPoints[0])); }, bottomView.Tag);
        var xPlusElectrodeEdge  = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Line(bottomViewElecHeadBorderPoints[0], bottomViewElecHeadBorderPoints[1])); }, bottomView.Tag);
        var xMinusElectrodeEdge = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Line(bottomViewElecHeadBorderPoints[2], bottomViewElecHeadBorderPoints[3])); }, bottomView.Tag);

        EdmDraw.DrawBusiness.CreateVerticalDim(bottomView.Tag, yPlusElectrodeEdge.NXOpenTag, yMinusElectrodeEdge.NXOpenTag,
                                               new Snap.Position(bottomView.GetDrawingReferencePoint().X - (EdmDraw.DrawBusiness.GetBorderSize(bottomView.Tag).X / 2), bottomView.GetDrawingReferencePoint().Y, 0));
        EdmDraw.DrawBusiness.CreatePerpendicularDim(bottomView.Tag, xPlusElectrodeEdge.NXOpenTag, xMinusElectrodeEdge.NXOpenTag,
                                                    new Snap.Position(bottomView.GetDrawingReferencePoint().X, bottomView.GetDrawingReferencePoint().Y - (EdmDraw.DrawBusiness.GetBorderSize(bottomView.Tag).Y / 2), 0));
    }
Beispiel #13
0
    void CreateEACT_BOTTOM_FRONTView(NXOpen.Drawings.DrawingSheet ds, List <NXOpen.TaggedObject> selections, Snap.Position pos, Snap.Position size, ElecManage.Electrode electrode, EdmDraw.EdmConfig edmConfig)
    {
        var bottomFrontView             = EdmDraw.DrawBusiness.CreateBaseView(ds, GetModelingView(EdmDraw.ViewType.EACT_BOTTOM_FRONT).Tag, selections, pos, size, edmConfig);
        var baseFace                    = electrode.BaseFace;
        var bottomFrontViewBorderPoints = EdmDraw.DrawBusiness.GetBorderPoint(bottomFrontView, electrode.ElecBody);

        var bottomFrontViewTopPoint    = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Point(bottomFrontViewBorderPoints[3])); }, bottomFrontView.Tag);
        var bottomFrontViewBottomPoint = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Point(bottomFrontViewBorderPoints[2])); }, bottomFrontView.Tag);

        //电极前视图
        EdmDraw.DrawBusiness.CreateVerticalDim(
            bottomFrontView.Tag,
            bottomFrontViewTopPoint.NXOpenTag,
            bottomFrontViewBottomPoint.NXOpenTag,
            new Snap.Position(bottomFrontView.GetDrawingReferencePoint().X + (EdmDraw.DrawBusiness.GetBorderSize(bottomFrontView.Tag).X / 2), bottomFrontView.GetDrawingReferencePoint().Y));

        EdmDraw.DrawBusiness.CreateVerticalDim(bottomFrontView.Tag, baseFace.NXOpenTag, bottomFrontViewBottomPoint.NXOpenTag,
                                               new Snap.Position(bottomFrontView.GetDrawingReferencePoint().X - (EdmDraw.DrawBusiness.GetBorderSize(bottomFrontView.Tag).X / 2), bottomFrontView.GetDrawingReferencePoint().Y));
    }
Beispiel #14
0
    BaseView CreateEACT_FRONTView(NXOpen.Drawings.DrawingSheet ds, List <NXOpen.TaggedObject> selections, Snap.Position pos, Snap.Position size, ElecManage.Electrode electrode, EdmDraw.EdmConfig edmConfig)
    {
        var frontView            = EdmDraw.DrawBusiness.CreateBaseView(ds, GetModelingView(EdmDraw.ViewType.EACT_FRONT).Tag, selections, pos, size, edmConfig);
        var frontViewRightMargin = EdmDraw.DrawBusiness.GetViewBorder(EdmDraw.ViewBorderType.Right, frontView);
        var frontViewLeftMargin  = EdmDraw.DrawBusiness.GetViewBorder(EdmDraw.ViewBorderType.Left, frontView);


        var ufSession     = NXOpen.UF.UFSession.GetUFSession();
        var originPoint   = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Point(Snap.Globals.Wcs.Origin)); }, frontView.Tag);
        var elecBasePoint = EdmDraw.DrawBusiness.CreateNxObject(() => { return(Snap.Create.Point(electrode.GetElecBasePos())); }, frontView.Tag);

        var drawBorderPoints = EdmDraw.DrawBusiness.GetDrawBorderPoint(frontView, Snap.NX.Body.Wrap(selections.First().Tag));
        var listY            = Enumerable.Select(drawBorderPoints, u => u.Y).ToList();
        var listX            = Enumerable.Select(drawBorderPoints, u => u.X).ToList();

        listY.Add(EdmDraw.DrawBusiness.MapModelToDrawing(frontView.Tag, originPoint.Position).Y);
        listY.Distinct().ToList().ForEach(u => {
            var tempModel = new double[] { 0, 0, 0 };
            ufSession.View.MapDrawingToModel(frontView.Tag, new double[] { listX.Min(), u }, tempModel);
            var tempU = EdmDraw.DrawBusiness.CreateNxObject <Snap.NX.Point>(() => { return(Snap.Create.Point(tempModel)); }, frontView.Tag);
            EdmDraw.DrawBusiness.CreatePerpendicularOrddimension(
                frontView.Tag,
                originPoint.NXOpenTag,
                frontViewLeftMargin.NXOpenTag,
                tempU.NXOpenTag
                );
        });

        var frontViewOrddimension = EdmDraw.DrawBusiness.CreatePerpendicularOrddimension(
            frontView.Tag,
            originPoint.NXOpenTag,
            frontViewRightMargin.NXOpenTag,
            elecBasePoint.NXOpenTag
            );

        EdmDraw.DrawBusiness.SetToleranceType(frontViewOrddimension);

        return(frontView);
    }
Beispiel #15
0
    /// <summary>
    /// 创建注释
    /// </summary>
    void CreateNodeInfo(ElecManage.Electrode elec, EdmDraw.EdmConfig edmConfig)
    {
        var properties    = edmConfig.PropertyInfos ?? new List <EdmDraw.EdmConfig.PropertyInfo>();
        var propertiesDic = new Dictionary <string, List <EdmDraw.EdmConfig.PropertyInfo> >();

        properties.ForEach(u => {
            var displayName = u.DisplayName;
            var dValue      = string.Empty;
            if (displayName.Contains("-"))
            {
                var splits  = displayName.Split('-');
                displayName = splits.FirstOrDefault();
                dValue      = splits.LastOrDefault();
            }
            if (!propertiesDic.ContainsKey(displayName))
            {
                propertiesDic.Add(displayName, new List <EdmDraw.EdmConfig.PropertyInfo> {
                    u
                });
            }
            else
            {
                propertiesDic[displayName].Add(u);
            }
        });

        var elecInfo    = elec.GetElectrodeInfo();
        var edmNodeInfo = new EdmDraw.EDMNodeInfo();

        edmNodeInfo.电极材质 = elecInfo.MAT_NAME;
        edmNodeInfo.电极类型 = elecInfo.UNIT;
        edmNodeInfo.电极层  = elec.ElecBody.Layer.ToString();
        edmNodeInfo.电极名称 = elecInfo.Elec_Name;
        edmNodeInfo.模号   = elecInfo.EACT_MODELNO;
        edmNodeInfo.工件名称 = elecInfo.EACT_PARTNO;

        edmNodeInfo.精公数量  = elecInfo.FINISH_NUMBER.ToString();
        edmNodeInfo.中公数量  = elecInfo.MIDDLE_NUMBER.ToString();
        edmNodeInfo.粗公数量  = elecInfo.ROUGH_NUMBER.ToString();
        edmNodeInfo.精公火花位 = elecInfo.FINISH_SPACE.ToString();
        edmNodeInfo.中公火花位 = elecInfo.MIDDLE_SPACE.ToString();
        edmNodeInfo.粗公火花位 = elecInfo.ROUGH_SPACE.ToString();
        edmNodeInfo.摇摆方式  = elecInfo.EDMROCK;
        edmNodeInfo.制图    = "EACT";
        edmNodeInfo.日期    = DateTime.Now.ToShortDateString();

        foreach (var item in propertiesDic)
        {
            var displayName = item.Key;
            var pValue      = EdmDraw.Helper.GetPropertyValue(edmNodeInfo, displayName) ?? string.Empty;
            var u           = item.Value.FirstOrDefault(p => (p.DisplayName.Contains(displayName) && p.DisplayName.Contains(pValue.ToString())) || p.DisplayName.Contains(displayName));
            if (u.Ex == "1")
            {
                EdmDraw.DrawBusiness.CreateTick(new Snap.Position(u.LocationX, u.LocationY));
            }
            else
            {
                EdmDraw.DrawBusiness.CreateNode(pValue.ToString(), new Snap.Position(u.LocationX, u.LocationY));
            }
        }
    }
Beispiel #16
0
    public void CreateDrawingSheet(List <PositioningInfo> positionings, Snap.NX.Body steel, bool isAutoMode)
    {
        var edmConfig    = EdmDraw.UCEdmConfig.GetInstance();
        var templateName = edmConfig.GetEdmTemplate();

        if (string.IsNullOrEmpty(templateName))
        {
            return;
        }

        ElecManage.Electrode electrode = positionings.FirstOrDefault().Electrode;
        var selectedObj = electrode.ElecBody;

        electrode.InitAllFace();
        InitModelingView(edmConfig, electrode, isAutoMode);
        SetIsHidden(positionings, steel);
        EdmDraw.DrawBusiness.InitPreferences(edmConfig);
        var workPart = Snap.Globals.WorkPart;
        var dsName   = selectedObj.Name;
        var list     = new List <NXOpen.TaggedObject>();

        list.Add(steel);
        list.Add(selectedObj);

        workPart.NXOpenPart.DrawingSheets.ToArray().Where(u => u.Name == dsName).ToList().ForEach(u =>
        {
            Snap.NX.NXObject.Delete(u);
        });

        //图纸显示
        EdmDraw.DrawBusiness.SetShowLayers(new List <int> {
            1
        }, edmConfig.EdmDrfLayer);

        //新建图纸页
        var ds = SnapEx.Create.DrawingSheet(selectedObj.Name, templateName);

        EdmDraw.DrawBusiness.SetDrawSheetLayer(ds, edmConfig.EdmDrfLayer);

        var draftViewLocations = edmConfig.DraftViewLocations ?? new List <EdmDraw.EdmConfig.DraftViewLocation>();

        EdmDraw.EdmConfig.DraftViewLocation ViewTypeEACT_TOP   = null;
        EdmDraw.EdmConfig.DraftViewLocation ViewTypeEACT_FRONT = null;
        foreach (var item in draftViewLocations)
        {
            var viewType = EdmDraw.DrawBusiness.GetEumnViewType(item.ViewType);
            switch (viewType)
            {
            case EdmDraw.ViewType.EACT_TOP:
            {
                ViewTypeEACT_TOP = item;
            }
            break;

            case EdmDraw.ViewType.EACT_FRONT:
            {
                ViewTypeEACT_FRONT = item;
            }
            break;

            case EdmDraw.ViewType.EACT_BOTTOM_FRONT:
            {
                CreateEACT_BOTTOM_FRONTView(
                    ds,
                    new List <TaggedObject> {
                        selectedObj
                    },
                    new Snap.Position(item.LocationX, item.LocationY),
                    new Snap.Position(item.SizeX, item.SizeY),
                    electrode,
                    edmConfig
                    );
            }
            break;

            case EdmDraw.ViewType.EACT_BOTTOM:
            {
                CreateEACT_BOTTOMView(
                    ds,
                    new List <TaggedObject> {
                        selectedObj
                    },
                    new Snap.Position(item.LocationX, item.LocationY),
                    new Snap.Position(item.SizeX, item.SizeY),
                    electrode, edmConfig
                    );
            }
            break;

            case EdmDraw.ViewType.EACT_BOTTOM_ISOMETRIC:
            {
                CreateEACT_BOTTOM_ISOMETRICView(
                    ds,
                    new List <TaggedObject> {
                        selectedObj
                    },
                    new Snap.Position(item.LocationX, item.LocationY),
                    new Snap.Position(item.SizeX, item.SizeY)
                    , edmConfig
                    );
            }
            break;

            case EdmDraw.ViewType.EACT_ISOMETRIC:
            {
                CreateEACT_ISOMETRICView(
                    ds,
                    new List <TaggedObject> {
                        steel
                    },
                    new Snap.Position(item.LocationX, item.LocationY),
                    new Snap.Position(item.SizeX, item.SizeY)
                    , edmConfig
                    );
            }
            break;
            }
        }

        CreateNodeInfo(electrode, edmConfig);

        var ps = new List <List <PositioningInfo> >();

        if (edmConfig.PageCount <= 0)
        {
            ps.Add(positionings);
        }
        else
        {
            var ceiling = Math.Ceiling((double)(positionings.Count * 1.0 / edmConfig.PageCount));
            var tempV   = positionings.Count % edmConfig.PageCount;
            for (int i = 0; i < ceiling; i++)
            {
                ps.Add(positionings.Skip(i * edmConfig.PageCount).Take(
                           i == ceiling - 1 && tempV != 0 ? tempV : edmConfig.PageCount
                           ).ToList());
            }
        }

        foreach (var item in ps)
        {
            SetIsHidden(positionings, steel);
            var pdfName = ds.Name;
            if (ps.Count > 1)
            {
                pdfName += "_" + (ps.IndexOf(item) + 1);
            }
            var deleteObj = new List <NXOpen.Tag>();
            if (ViewTypeEACT_TOP != null)
            {
                var topView = CreateEACT_TOPView(
                    ds,
                    steel,
                    new Snap.Position(ViewTypeEACT_TOP.LocationX, ViewTypeEACT_TOP.LocationY),
                    new Snap.Position(ViewTypeEACT_TOP.SizeX, ViewTypeEACT_TOP.SizeY),
                    item,
                    edmConfig
                    );

                deleteObj.Add(topView.Tag);
            }

            if (ViewTypeEACT_FRONT != null)
            {
                var itemE     = item.First().Electrode;
                var frontView = CreateEACT_FRONTView(
                    ds,
                    new List <NXOpen.TaggedObject> {
                    steel, itemE.ElecBody
                },
                    new Snap.Position(ViewTypeEACT_FRONT.LocationX, ViewTypeEACT_FRONT.LocationY),
                    new Snap.Position(ViewTypeEACT_FRONT.SizeX, ViewTypeEACT_FRONT.SizeY),
                    itemE,
                    edmConfig
                    );

                deleteObj.Add(frontView.Tag);
            }

            deleteObj.AddRange(CreateTable(edmConfig, item));
            SetIsHidden(positionings, steel, false);

            ds.GetDraftingViews().ToList().ForEach(u => {
                var ufSession = NXOpen.UF.UFSession.GetUFSession();
                ufSession.Draw.UpdateOneView(ds.Tag, u.Tag);
            });
            var result = EdmDraw.Helper.ExportPDF(ds, pdfName);
            var info   = electrode.GetElectrodeInfo();
            CommonInterface.FtpHelper.FtpUpload("EDM2D", new ElecManage.MouldInfo {
                MODEL_NUMBER = string.IsNullOrEmpty(info.EACT_MODELNO)? "UNKOWN_MODELNO" : info.EACT_MODELNO
            }, result, info.Elec_Name, _ConfigData);

            if (ps.Count > 1)
            {
                deleteObj.ForEach(u => {
                    Snap.NX.NXObject.Wrap(u).Delete();
                });
            }
        }

        //if (isAutoMode)
        //{
        //    Snap.NX.NXObject.Wrap(ds.Tag).Delete();
        //}
    }
Beispiel #17
0
    public override void Update(NXOpen.BlockStyler.UIBlock block)
    {
        RefreshUI();
        var body = selectCuprum.SelectedObjects.FirstOrDefault() as Snap.NX.Body;

        if (block == btnAutoSelectPoint.NXOpenBlock)
        {
            if (body != null)
            {
                AutoSelectPoint();
                RefreshUI();
            }
        }
        else if (block == selectCuprum.NXOpenBlock)
        {
            _electrode = null;
            if (body != null)
            {
                var elec = ElecManage.Electrode.GetElectrode(body);
                if (elec != null)
                {
                    elec.InitAllFace();
                    _electrode = elec;
                }
                else
                {
                    selectCuprum.SelectedObjects = new Snap.NX.NXObject[] { };
                    NXOpen.UF.UFSession.GetUFSession().Ui.DisplayMessage("该电极无法识别", 1);
                }
            }
        }
        else if (block == toggle0.NXOpenBlock)
        {
            UFDisp();
            DeleteNodes();
        }
        else if (block == btnDown.NXOpenBlock)
        {
            var node = GetSelectNode();
            if (node != null)
            {
                var list  = GetNodes();
                var index = list.IndexOf(node) + 1;
                index = index > list.Count - 1 ? list.Count - 1 : index;
                list.Remove(node);
                list.Insert(index, node);
                UFDisp(GetPointDatasFromTree(list));
            }
        }
        else if (block == btnUP.NXOpenBlock)
        {
            var node = GetSelectNode();
            if (node != null)
            {
                var list  = GetNodes();
                var index = list.IndexOf(node) - 1;
                index = index < 0 ? 0 : index;
                list.Remove(node);
                list.Insert(index, node);
                UFDisp(GetPointDatasFromTree(list));
            }
        }
        else if (block == btnRemove.NXOpenBlock)
        {
            var node = GetSelectNode();
            if (node != null)
            {
                var pd = GetPointData(node);
                if (pd != null && pd.PointType == PointType.HeadFace)
                {
                    var list = GetNodes();
                    list.Remove(node);
                    UFDisp(GetPointDatasFromTree(list));
                    theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "删除成功!");
                }
                else
                {
                    theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "无法删除该点!");
                }
            }
        }
        else if (block == selectionPoint.NXOpenBlock)
        {
            if (body != null && selectionPoint.SelectedObjects.Count() > 0)
            {
                PointData data = null;
                ComponentHelper(() =>
                {
                    data = CMMBusiness.IsInterveneBySelPoint(_electrode, selectionPoint.PickPoint, _config);
                });

                if (data != null)
                {
                    var points = GetPointDatasFromTree();
                    points.Add(data);
                    UFDisp(points);
                }
                else
                {
                    theUI.NXMessageBox.Show("提示", NXOpen.NXMessageBox.DialogType.Information, "无法取该点,请重新选点!");
                }
            }

            selectionPoint.SelectedObjects = new Snap.NX.NXObject[] { };
        }
        else if (block == btnExport.NXOpenBlock)
        {
            if (body != null)
            {
                var list = new List <PointData>();
                GetNodes().ForEach(u =>
                {
                    list.Add(Newtonsoft.Json.JsonConvert.DeserializeObject <PointData>(u.GetNodeData().GetString(_propertyName)));
                });
                if (list.Count > 0)
                {
                    //导出
                    CMMBusiness.WriteCMMFileByPointData(_electrode, list, _config);
                    NXOpen.UF.UFSession.GetUFSession().Ui.DisplayMessage("导出成功", 1);
                }
            }
            else
            {
                //ImportPart(  Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "CMM_INSPECTION", enumSelectTool.ValueAsString));
            }
        }
    }