Esempio n. 1
0
 /// <summary>
 /// 进给参数设置
 /// </summary>
 /// <param name="oper">工序</param>
 /// <param name="engage"></param>
 /// <param name="first_cut">第一刀切削</param>
 /// <param name="traversal">横越</param>
 /// <param name="retract">退刀</param>
 public static void SetFeedParam(NXOpen.Tag oper, double engage, double first_cut, double traversal, double retract)
 {
     SnapEx.EactUF.SetFeedRate(oper, NXOpen.UF.UFConstants.UF_PARAM_FEED_ENGAGE, engage);
     SnapEx.EactUF.SetFeedRate(oper, NXOpen.UF.UFConstants.UF_PARAM_FEED_FIRST_CUT, first_cut);
     SnapEx.EactUF.SetFeedRate(oper, NXOpen.UF.UFConstants.UF_PARAM_FEED_TRAVERSAL, traversal);
     SnapEx.EactUF.SetFeedRate(oper, NXOpen.UF.UFConstants.UF_PARAM_FEED_RETRACT, retract);
 }
Esempio n. 2
0
        /// <summary>
        /// 创建标签
        /// </summary>
        public static NXOpen.Tag CreateLabel(string text, Snap.Position origin, Snap.Position pos, NXOpen.Tag view, NXOpen.Tag objectTag)
        {
            NXOpen.Tag result       = NXOpen.Tag.Null;
            var        theUFSession = NXOpen.UF.UFSession.GetUFSession();

            NXOpen.UF.UFDrf.Object object1 = new NXOpen.UF.UFDrf.Object();
            object1.object_tag            = objectTag;
            object1.object_view_tag       = view;
            object1.object_assoc_type     = NXOpen.UF.UFDrf.AssocType.EndPoint;
            object1.object_assoc_modifier = NXOpen.UF.UFConstants.UF_DRF_first_end_point;

            theUFSession.Drf.CreateLabel(1, new string[] { text }, origin.Array, NXOpen.UF.UFDrf.LeaderAttachType.LeaderAttachObject,
                                         ref object1,
                                         pos.Array,
                                         out result);
            var eData = new DraftingEnvironmentData();
            var mpi   = eData.mpi;
            var mpr   = eData.mpr;

            theUFSession.Drf.AskObjectPreferences(result, eData.mpi, eData.mpr, out eData.radiusValue, out eData.diameterValue);
            mpi[1]  = 1;
            mpi[9]  = 1;
            mpi[10] = 2;
            mpi[11] = 4;
            mpi[29] = 1;
            mpi[39] = 1;
            mpi[94] = 0;
            mpr[9]  = 3.0;
            mpr[10] = 0.001;
            theUFSession.Drf.SetObjectPreferences(result, eData.mpi, eData.mpr, eData.radiusValue, eData.diameterValue);
            return(result);
        }
Esempio n. 3
0
        /// <summary>
        /// 创建刀具
        /// </summary>
        /// <returns></returns>
        public static List <CAMCutter> CreateCutter(List <CAMCutter> cutters, NXOpen.Tag cutterGroupRootTag)
        {
            var result = new List <CAMCutter>();

            foreach (var item in cutters)
            {
                NXOpen.Tag cutterTag = NXOpen.Tag.Null;
                cutterTag = GetCutter(item.CutterName, cutterGroupRootTag);
                if (cutterTag == NXOpen.Tag.Null)
                {
                    ufSession.Cutter.Create(item.AUTOCAM_TYPE, item.AUTOCAM_SUBTYPE, out cutterTag);
                    ufSession.Ncgroup.AcceptMember(cutterGroupRootTag, cutterTag);
                    ufSession.Obj.SetName(cutterTag, item.CutterName);
                }
                ufSession.Param.SetDoubleValue(cutterTag, NXOpen.UF.UFConstants.UF_PARAM_TL_DIAMETER, item.TL_DIAMETER);
                ufSession.Param.SetDoubleValue(cutterTag, NXOpen.UF.UFConstants.UF_PARAM_TL_COR1_RAD, item.TL_COR1_RAD);
                ufSession.Param.SetDoubleValue(cutterTag, NXOpen.UF.UFConstants.UF_PARAM_TL_HEIGHT, item.TL_HEIGHT);
                ufSession.Param.SetDoubleValue(cutterTag, NXOpen.UF.UFConstants.UF_PARAM_TL_FLUTE_LN, item.TL_FLUTE_LN);
                ufSession.Param.SetIntValue(cutterTag, NXOpen.UF.UFConstants.UF_PARAM_TL_NUMBER, item.TL_NUMBER);
                ufSession.Param.SetIntValue(cutterTag, NXOpen.UF.UFConstants.UF_PARAM_TL_ADJ_REG, item.TL_ADJ_REG);
                item.CutterTag = cutterTag;
                result.Add(item);
            }
            return(result);
        }
Esempio n. 4
0
        /// <summary>
        /// 过切检查
        /// </summary>
        public static bool IsPathGouged(NXOpen.Tag oper)
        {
            var result = true;

            ufSession.Oper.IsPathGouged(oper, out result);
            return(result);
        }
Esempio n. 5
0
        /// <summary>
        /// 创建垂直尺寸
        /// </summary>
        public static NXOpen.Tag CreatePerpendicularDim(NXOpen.Tag draw_view_tag, NXOpen.Tag o1, NXOpen.Tag o2, Snap.Position origin)
        {
            var theUFSession = NXOpen.UF.UFSession.GetUFSession();

            NXOpen.UF.UFDrf.Object object1 = new NXOpen.UF.UFDrf.Object();

            object1.object_tag            = o1;
            object1.object_view_tag       = draw_view_tag;
            object1.object_assoc_type     = NXOpen.UF.UFDrf.AssocType.EndPoint;
            object1.object_assoc_modifier = NXOpen.UF.UFConstants.UF_DRF_first_end_point;

            NXOpen.UF.UFDrf.Object object2 = new NXOpen.UF.UFDrf.Object();
            object2.object_tag            = o2;
            object2.object_view_tag       = draw_view_tag;
            object2.object_assoc_type     = NXOpen.UF.UFDrf.AssocType.EndPoint;
            object2.object_assoc_modifier = NXOpen.UF.UFConstants.UF_DRF_first_end_point;

            NXOpen.UF.UFDrf.Text text = new NXOpen.UF.UFDrf.Text();

            NXOpen.Tag result;
            theUFSession.Drf.CreatePerpendicularDim(ref object1, ref object2, ref text, new double[] { origin.X, origin.Y, 0 }, out result);
            var environmentData = new DraftingEnvironmentData();

            theUFSession.Drf.AskObjectPreferences(result, environmentData.mpi, environmentData.mpr, out environmentData.radiusValue, out environmentData.diameterValue);
            environmentData.mpi[9] = 3;
            theUFSession.Drf.SetObjectPreferences(result, environmentData.mpi, environmentData.mpr, environmentData.radiusValue, environmentData.diameterValue);
            return(result);
        }
Esempio n. 6
0
        public static List <Snap.NX.Body> BodiesByName(this Snap.NX.Part part, string name)
        {
            var ufSession = NXOpen.UF.UFSession.GetUFSession();

            NXOpen.Tag tempTag = NXOpen.Tag.Null;
            var        list    = new List <Snap.NX.Body>();

            do
            {
                ufSession.Obj.CycleByNameAndType(part.NXOpenTag, name, NXOpen.UF.UFConstants.UF_solid_type, true, ref tempTag);
                if (tempTag != NXOpen.Tag.Null)
                {
                    try
                    {
                        Snap.NX.NXObject nxopenTaggedObject = GetObjectFromTag(tempTag);
                        if (nxopenTaggedObject != null && nxopenTaggedObject.ObjectType == Snap.NX.ObjectTypes.Type.Body)
                        {
                            list.Add(Snap.NX.Body.Wrap(tempTag));
                        }
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine("BodiesByName:" + ex.Message);
                    }
                    var dd = Snap.NX.NXObject.Wrap(tempTag);
                }
            }while (tempTag != NXOpen.Tag.Null);
            return(list);
        }
Esempio n. 7
0
        /// <summary>
        /// 查询面上的边
        /// </summary>
        /// <param name="faceTag"></param>
        /// <returns></returns>
        public static LoopList[] AskFaceLoops(NXOpen.Tag faceTag)
        {
            System.IntPtr loopT;
            NXOpen.Utilities.JAM.StartUFCall();
            int errorCode = UF_MODL_ask_face_loops(faceTag, out loopT);

            NXOpen.Utilities.JAM.EndUFCall();
            if (errorCode != 0)
            {
                throw NXOpen.NXException.Create(errorCode);
            }
            System.IntPtr   ptr      = loopT;
            List <LoopList> loopList = new List <LoopList>();

            while (ptr != IntPtr.Zero)
            {
                _loop_list loopListT = (_loop_list)Marshal.PtrToStructure(ptr, typeof(_loop_list));
                int        count;
                errorCode = UF_MODL_ask_list_count(loopListT.edge_list, out count);
                NXOpen.Tag[] edgeArray = new NXOpen.Tag[count];
                for (int i = 0; i < count; i++)
                {
                    UF_MODL_ask_list_item(loopListT.edge_list, i, out edgeArray[i]);
                }
                //UF_MODL_delete_list(out loopListT.edge_list);
                loopList.Add(new LoopList {
                    Type = loopListT.type, EdgeList = edgeArray
                });
                ptr = loopListT.next;
            }
            UF_MODL_delete_loop_list(out loopT);
            return(loopList.ToArray());
        }
Esempio n. 8
0
        public static int Subtype(this NXOpen.Tag tag)
        {
            int type;
            int subtype;

            UFSession.GetUFSession().Obj.AskTypeAndSubtype(tag, out type, out subtype);
            return(subtype);
        }
Esempio n. 9
0
        new public static Element FromElementId(DB.Part doc, DB.Tag Id)
        {
            if (doc?.GetElement(Id ?? DB.Tag.Null) is DB.TaggedObject value)
            {
                return(FromElement(value));
            }

            return(null);
        }
Esempio n. 10
0
        public static bool IsLine(NXOpen.Tag tag)
        {
            int type;
            int subtype;

            UFSession.GetUFSession().Obj.AskTypeAndSubtype(tag, out type, out subtype);

            return(type == UFConstants.UF_line_type);
        }
Esempio n. 11
0
        /// <summary>
        /// 设置进给率
        /// </summary>
        public static void SetFeedRate(NXOpen.Tag operTag, double value)
        {
            var oper          = NXOpen.Utilities.NXObjectManager.Get(operTag) as NXOpen.CAM.Operation;
            var feedsBuilder1 = NXOpen.Session.GetSession().Parts.Work.CAMSetup.CreateFeedsBuilder(new NXOpen.CAM.CAMObject[] { oper });

            feedsBuilder1.FeedsBuilder.FeedCutBuilder.Value = value;
            feedsBuilder1.Commit();
            feedsBuilder1.Destroy();
        }
Esempio n. 12
0
        public static Snap.Position MapModelToDrawing(NXOpen.Tag viewTag, Snap.Position pos)
        {
            var tempMap   = new double[] { 0, 0 };
            var ufSession = NXOpen.UF.UFSession.GetUFSession();

            ufSession.View.MapModelToDrawing(viewTag, pos.Array, tempMap);
            var originPointMTD = tempMap.ToArray();

            return(new Snap.Position(originPointMTD[0], originPointMTD[1]));
        }
Esempio n. 13
0
        /// <summary>
        ///  获取边界尺寸
        /// </summary>
        public static NXOpen.Point2d GetBorderSize(NXOpen.Tag tag)
        {
            var view_borders = new double[4];

            NXOpen.UF.UFSession.GetUFSession().Draw.AskViewBorders(tag, view_borders);
            var size = new NXOpen.Point2d();

            size.Y = Math.Abs(view_borders[3] - view_borders[1]);
            size.X = Math.Abs(view_borders[2] - view_borders[0]);
            return(size);
        }
Esempio n. 14
0
        /// <summary>
        /// 设置非切削移动区域起点
        /// </summary>
        public static void SetRegionStartPoints(NXOpen.Tag operTag, Snap.Position pos)
        {
            var oper     = NXOpen.Utilities.NXObjectManager.Get(operTag) as NXOpen.CAM.Operation;
            var workPart = NXOpen.Session.GetSession().Parts.Work;
            var cavityMillingBuilder1 = workPart.CAMSetup.CAMOperationCollection.CreatePlanarMillingBuilder(oper);
            var point = workPart.Points.CreatePoint(pos);

            cavityMillingBuilder1.NonCuttingBuilder.SetRegionStartPoints(new Point[] { point });
            cavityMillingBuilder1.Commit();
            cavityMillingBuilder1.Destroy();
        }
Esempio n. 15
0
        /// <summary>
        /// 设置面边界
        /// </summary>
        public static void SetBoundaryByFace(NXOpen.Tag faceTag, NXOpen.UF.CamGeomType camGeomType, NXOpen.Tag operTag, NXOpen.UF.CamMaterialSide materialSide)
        {
            var boundary_data = new NXOpen.UF.UFCambnd.BoundaryData();

            boundary_data.boundary_type   = NXOpen.UF.CamBoundaryType.CamBoundaryTypeClosed;
            boundary_data.plane_type      = 1;
            boundary_data.material_side   = materialSide;
            boundary_data.ignore_holes    = 0;
            boundary_data.ignore_islands  = 0;
            boundary_data.ignore_chamfers = 0;
            boundary_data.app_data        = new NXOpen.UF.UFCambnd.AppData[] { };
            ufSession.Cambnd.AppendBndFromFace(operTag, camGeomType, faceTag, ref boundary_data);
        }
Esempio n. 16
0
        /// <summary>
        /// 显示编辑的对话框
        /// </summary>
        public static void ShowEditDialog(NXOpen.Tag tag, Action action = null)
        {
            int dialogResponse;

            ufSession.UiParam.EditObject(tag, out dialogResponse);
            if (dialogResponse == NXOpen.UF.UFConstants.UF_UI_APPLY || dialogResponse == NXOpen.UF.UFConstants.UF_UI_OK)
            {
                if (action != null)
                {
                    action();
                }
            }
        }
Esempio n. 17
0
 /// <summary>
 /// 设置部件余量和底部余量
 /// </summary>
 public static void SetPartStockAndFloorStock(NXOpen.Tag operTag, double sideStock, double floorStock)
 {
     ufSession.Param.SetDoubleValue(operTag, NXOpen.UF.UFConstants.UF_PARAM_STOCK_PART, sideStock);
     if (Math.Abs(sideStock - floorStock) < SnapEx.Helper.Tolerance)
     {
         ufSession.Param.SetIntValue(operTag, NXOpen.UF.UFConstants.UF_PARAM_STOCK_PART_USE, 1);
     }
     else
     {
         ufSession.Param.SetIntValue(operTag, NXOpen.UF.UFConstants.UF_PARAM_STOCK_PART_USE, 0);
         ufSession.Param.SetDoubleValue(operTag, NXOpen.UF.UFConstants.UF_PARAM_STOCK_FLOOR, floorStock);
     }
 }
Esempio n. 18
0
        //public static void AutoCAM(ElecManage.Electrode ele)
        //{
        //    camOpers.ForEach(u => {
        //        if (u.OperIsValid)
        //        {
        //            string name;
        //            ufSession.Obj.AskName(u.OperTag, out name);
        //            ShowInfoWindow(string.Format("{0}:{1}", name, u.IsPathGouged() ? "过切" : "未过切"));
        //        }
        //    });

        //    //获取后处理器列表
        //    string[] names;
        //    int count;
        //    ufSession.Cam.OptAskPostNames(out count, out names);
        //    var postName = "铜电极-自动换刀";
        //    var extension = "nc";

        //    var path = System.AppDomain.CurrentDomain.BaseDirectory;
        //    path = System.IO.Path.Combine(path, "Temp");
        //    path = System.IO.Path.Combine(path, "EACTCNCFILE");
        //    if (System.IO.Directory.Exists(path))
        //    {
        //        System.IO.Directory.Delete(path,true);
        //    }

        //    System.IO.Directory.CreateDirectory(path);

        //    camOpers.ForEach(u => {
        //        u.GenerateProgram(postName, path, extension);
        //    });

        //    //生成nc程式
        //    ufSession.Setup.GenerateProgram(
        //        Snap.Globals.WorkPart.NXOpenPart.CAMSetup.Tag,
        //        programGroupTag
        //        , postName
        //        , System.IO.Path.Combine(path, string.Format(@"{0}.{1}", ele.ElecBody.Name, extension))
        //        , NXOpen.UF.UFSetup.OutputUnits.OutputUnitsOutputDefined
        //        );
        //}

        /// <summary>
        /// 设置Z偏置(骗刀Z)
        /// </summary>
        public static void SetZoffset(NXOpen.Tag operTag, double value)
        {
            Session theSession            = Session.GetSession();
            Part    workPart              = theSession.Parts.Work;
            Part    displayPart           = theSession.Parts.Display;
            var     oper                  = NXOpen.Utilities.NXObjectManager.Get(operTag) as NXOpen.CAM.Operation;
            var     zLevelMillingBuilder1 = workPart.CAMSetup.CAMOperationCollection.CreatePlanarMillingBuilder(oper);

            zLevelMillingBuilder1.ToolChangeSetting.Zoffset.Value = value;
            NXObject nXObject1;

            nXObject1 = zLevelMillingBuilder1.Commit();
            zLevelMillingBuilder1.Destroy();
        }
Esempio n. 19
0
        /// <summary>
        /// 创建投影视图(AddOrthographicView)
        /// </summary>
        public static NXOpen.Drawings.ProjectedView CreateProjectedView(NXOpen.Tag ds, NXOpen.Tag parentView, Snap.Position pos)
        {
            var ufSession = NXOpen.UF.UFSession.GetUFSession();

            NXOpen.Tag orthographicView;
            ufSession.Draw.AddOrthographicView(
                ds,
                parentView,
                NXOpen.UF.UFDraw.ProjDir.ProjectAbove,
                new double[] { pos.X, pos.Y },
                out orthographicView
                );

            return(NXOpen.Utilities.NXObjectManager.Get(orthographicView) as NXOpen.Drawings.ProjectedView);
        }
Esempio n. 20
0
    private static int select_point(string cue, ref double[] base_pt)
    {
        NXOpen.Tag point_tag = NXOpen.Tag.Null;
        int        response  = 0;

        UFUi.PointBaseMethod base_method = UFUi.PointBaseMethod.PointInferred;

        theUfSession.Ui.LockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM);
        theUfSession.Ui.PointConstruct(
            cue,
            ref base_method,
            out point_tag,
            base_pt,
            out response);
        theUfSession.Ui.UnlockUgAccess(NXOpen.UF.UFConstants.UF_UI_FROM_CUSTOM);
        return(response);
    }
Esempio n. 21
0
        /// <summary>
        /// 设置边界
        /// </summary>
        public static void SetBoundary(Snap.Position origin, NXOpen.Tag faceTag, NXOpen.UF.CamGeomType camGeomType, NXOpen.Tag operTag, NXOpen.UF.CamMaterialSide materialSide)
        {
            SetBoundaryByFace(faceTag, camGeomType, operTag, materialSide);
            IntPtr[] Boundaries;
            int      count;

            ufSession.Cambnd.AskBoundaries(operTag, camGeomType, out count, out Boundaries);
            for (int i = 0; i < count; i++)
            {
                NXOpen.Matrix3x3 identity = Snap.Orientation.Identity;
                ufSession.Cambnd.SetBoundaryPlane(Boundaries[i], origin.Array, new double[] {
                    identity.Xx, identity.Xy, identity.Xz
                    , identity.Yx, identity.Yy, identity.Yz
                    , identity.Zx, identity.Zy, identity.Zz
                });
            }
        }
Esempio n. 22
0
        public static EACT_Feedrate AskFeedRate(NXOpen.Tag operTag, int param_index)
        {
            NXOpen.Utilities.JAM.StartUFCall();
            EACT_Feedrate result;
            int           errorCode;

            if (NxVersion >= 10)
            {
                errorCode = _AskFeedRate_libufun_cam(operTag, param_index, out result);
            }
            else
            {
                errorCode = _AskFeedRate(operTag, param_index, out result);
            }
            NXOpen.Utilities.JAM.EndUFCall();
            return(result);
        }
Esempio n. 23
0
        public static void SetToleranceType(NXOpen.Tag tag)
        {
            Session theSession  = Session.GetSession();
            Part    workPart    = theSession.Parts.Work;
            Part    displayPart = theSession.Parts.Display;
            var     obj         = NXOpen.Utilities.NXObjectManager.Get(tag) as NXOpen.Annotations.OrdinateDimension;

            if (obj != null)
            {
                var ordinateDimensionBuilder1 = workPart.Dimensions.CreateOrdinateDimensionBuilder(obj);
                //尺寸样式
                ordinateDimensionBuilder1.Style.DimensionStyle.ToleranceType = NXOpen.Annotations.ToleranceType.Basic;

                ordinateDimensionBuilder1.Commit();
                ordinateDimensionBuilder1.Destroy();
            }
        }
Esempio n. 24
0
        /// <summary>
        /// 设置加工底面
        /// </summary>
        public static void SetCutFloor(NXOpen.Tag operTag, Snap.Position origin, NXOpen.Tag faceTag = NXOpen.Tag.Null)
        {
            NXOpen.Tag result;
            if (NXOpen.Tag.Null == faceTag)
            {
                var        identity = Snap.Orientation.Identity;
                NXOpen.Tag xforms;
                ufSession.So.CreateXformDoubles(Snap.Globals.WorkPart.NXOpenTag, NXOpen.UF.UFSo.UpdateOption.UpdateWithinModeling, origin.Array, identity.AxisX.Array, identity.AxisY.Array, 1, out xforms);
                result = xforms;
            }
            else
            {
                result = faceTag;
            }

            ufSession.Param.SetTagValue(operTag, NXOpen.UF.UFConstants.UF_PARAM_FLOOR, result);
        }
Esempio n. 25
0
        public static void SetViewDisplay(NXOpen.Tag ds, NXOpen.Tag view)
        {
            var ufSession = NXOpen.UF.UFSession.GetUFSession();

            NXOpen.UF.UFDraw.ViewPrfs stViewDispParam;
            ufSession.Draw.AskViewDisplay(view, out stViewDispParam);
            stViewDispParam.hidden_line               = NXOpen.UF.UFDraw.HiddenLine.HiddenLineRemovalOn;// UF_DRAW_hidden_line_removal_on;//只有设置这项后才能设置hidden_line_font
            stViewDispParam.hidden_line_font          = NXOpen.UF.UFConstants.UF_OBJ_FONT_DASHED;
            stViewDispParam.visible_line_font         = NXOpen.UF.UFConstants.UF_OBJ_FONT_SOLID;
            stViewDispParam.visible_line_width        = NXOpen.UF.UFConstants.UF_OBJ_WIDTH_THIN;
            stViewDispParam.hidden_line_width         = NXOpen.UF.UFConstants.UF_OBJ_WIDTH_THIN;
            stViewDispParam.edges_hidden_by_own_solid = false;
            stViewDispParam.smooth            = NXOpen.UF.UFDraw.Smooth.SmoothOn;                      // UF_DRAW_smooth_on;
            stViewDispParam.smooth_edge_gap   = NXOpen.UF.UFDraw.Gap.GapOff;                           //UF_DRAW_gap_off;
            stViewDispParam.virtual_intersect = NXOpen.UF.UFDraw.VirtualIntersect.VirtualIntersectOff; //UF_DRAW_virtual_intersect_off;
            ufSession.Draw.SetViewDisplay(view, ref stViewDispParam);
            //ufSession.Draw.UpdateOneView(ds, view);
        }
Esempio n. 26
0
    public static NXOpen.Tag CreateView(DrawingSheet ds, Snap.NX.Body body, NXOpen.Tag modelViewTag, Snap.Position point)
    {
        //UFUN创建基本视图函数
        var workPart = NXOpen.Session.GetSession().Parts.Work;

        Snap.NX.Part snapWorkPart = workPart;
        var          theUFSession = NXOpen.UF.UFSession.GetUFSession();

        NXOpen.UF.UFDraw.ViewInfo view_info;
        theUFSession.Draw.InitializeViewInfo(out view_info);
        double[] dwg_point = { point.X, point.Y };
        Tag      draw_view_tag;

        theUFSession.Draw.ImportView(ds.Tag, modelViewTag, dwg_point, ref view_info, out draw_view_tag);
        string viewName;

        theUFSession.Obj.AskName(draw_view_tag, out viewName);

        workPart.Bodies.ToArray().ToList().ForEach(u =>
        {
            if (u.Tag != body.NXOpenTag)
            {
                SnapEx.Ex.UC6400(viewName, u.Tag);
            }
        });

        workPart.Points.ToArray().ToList().ForEach(u =>
        {
            if (u.Tag != body.NXOpenTag)
            {
                SnapEx.Ex.UC6400(viewName, u.Tag);
            }
        });

        SnapEx.Ex.UC6400(viewName, workPart.WCS.Tag);

        //更新视图
        theUFSession.Draw.UpdateOneView(ds.Tag, draw_view_tag);

        theUFSession.Draw.MoveView(draw_view_tag, dwg_point);
        //更新视图
        theUFSession.Draw.UpdateOneView(ds.Tag, draw_view_tag);
        return(draw_view_tag);
    }
Esempio n. 27
0
        /// <summary>
        /// 路径生成
        /// </summary>
        public static string PathGenerate(NXOpen.Tag operTag)
        {
            string generated = string.Empty;
            var    mark      = Snap.Globals.SetUndoMark(Snap.Globals.MarkVisibility.Invisible, "PathGenerate");

            try
            {
                PathGenerate(new List <NXOpen.Tag> {
                    operTag
                });
            }
            catch (Exception ex)
            {
                ufSession.Obj.AskName(operTag, out generated);
                generated = string.Format("{0}:{1}", generated, ex.Message);
            }
            Snap.Globals.DeleteUndoMark(mark, "PathGenerate");
            return(generated);
        }
Esempio n. 28
0
        public static int SetFeedRate(NXOpen.Tag operTag, int param_index, double value)
        {
            var feedRate = AskFeedRate(operTag, param_index);

            feedRate.value = value;
            NXOpen.Utilities.JAM.StartUFCall();
            int errorCode;

            if (NxVersion >= 10)
            {
                errorCode = _SetFeedRate_libufun_cam(operTag, param_index, feedRate);
            }
            else
            {
                errorCode = _SetFeedRate(operTag, param_index, feedRate);
            }
            NXOpen.Utilities.JAM.EndUFCall();
            return(errorCode);
        }
Esempio n. 29
0
        /// <summary>
        /// 设置区域
        /// </summary>
        public static void SetMillArea(NXOpen.UF.CamGeomType camGeomType, NXOpen.Tag operTag, List <NXOpen.Tag> cutAreaGeometryTags)
        {
            var appDatas = new List <NXOpen.UF.UFCamgeom.AppData>();

            cutAreaGeometryTags.ForEach(u =>
            {
                var appData                = new NXOpen.UF.UFCamgeom.AppData();
                appData.has_stock          = 0;
                appData.has_cut_stock      = 0;
                appData.has_tolerances     = 0;
                appData.has_feedrate       = 0;
                appData.has_offset         = 0;
                appData.has_avoidance_type = 0;
                appData.offset             = 0.1;
                appDatas.Add(appData);
            });
            _ufSession.Camgeom.DeleteGeometry(operTag, camGeomType);
            _ufSession.Camgeom.AppendItems(operTag, camGeomType, cutAreaGeometryTags.Count, cutAreaGeometryTags.ToArray(), appDatas.ToArray());
        }
Esempio n. 30
0
        public static T CreateNxObject <T>(Func <T> action, NXOpen.Tag viewTag, bool isExpandView = true) where T : Snap.NX.NXObject
        {
            var ufSession = NXOpen.UF.UFSession.GetUFSession();

            if (isExpandView)
            {
                ufSession.View.ExpandView(viewTag);
            }

            var result = action();

            result.IsHidden = true;

            if (isExpandView)
            {
                ufSession.View.UnexpandWorkView();
            }
            return(result);
        }