自动刻字功能是建模过程中必须用到的,但是网上没有找到完整的刻字功能实现,所以我花了一些时间写了一套简易程序,希望能给初学者带来一点帮助
先介绍一下建模环境下刻字功能的实现,分三步走(本节主要介绍打印文本):
第一步:打印文本
第二步:拉伸
第三步:布尔求差
/// <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

最低0.47元/天 解锁文章
1383

被折叠的 条评论
为什么被折叠?



