UG/NX 二次开发(C#) 自动刻字三部曲1-打印文本

自动刻字功能是建模过程中必须用到的,但是网上没有找到完整的刻字功能实现,所以我花了一些时间写了一套简易程序,希望能给初学者带来一点帮助

先介绍一下建模环境下刻字功能的实现,分三步走(本节主要介绍打印文本):

第一步:打印文本

第二步:拉伸

第三步:布尔求差

        /// <summary>
        /// 创建文本
        /// </summary>
        /// <param name="p"></param>
        /// <param name="faceTag"></param>
        /// <param name="content"></param>
        /// <returns></returns>
        public static string TextBuilderByPoint(Point3d p, Tag faceTag , string content)
        {
            Session theSession = Session.GetSession();
            Part workPart = theSession.Parts.Work;
            Part displayPart = theSession.Parts.Display;
            theUFSession = UFSession.GetUFSession();

            int type;
            double[] point = new double[3];  //面的中心点
            double[] dir = new double[3];    //面的法向量
            double[] box = new double[6]; ;
            double radius;
            double rad_data;
            int norm_dir;
            theUFSession.Modl.AskFaceData(faceTag, out type, point, dir, box, out radius, out rad_data, out norm_dir);

            NXOpen.Features.Text nullFeatures_Text = null;
            NXOpen.Features.TextBuilder textBuilder1;
            textBuilder1 = workPart.Features.CreateTextBuilder(nullFeatures_Text);
            Point3d origin1 = new Point3d(0.0, 0.0, 0.0);
            Vector3d normal1 = new Vector3d(0.0, 0.0, 1.0);
            Plane plane1;
            plane1 = workPart.Planes.CreatePlane(origin1, normal1, NXOpen.SmartObject.UpdateOption.WithinModeling);
            textBuilder1.SectionPlane = plane1;
            Unit unit1;
            unit1 = textBuilder1.PlanarFrame.Length.Units;

            textBuilder1.FrameOnPath.AnchorPosition.Expression.RightHandSide = "50";
            textBuilder1.Type = NXOpen.Features.TextBui
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

MarcoPro

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值