C#:通用方法总结—第16集

大家好,今天继续介绍我们的通用方法系列。

下面是今天要介绍的通用方法:

(1)这个通用方法为将TaggedObject转换为Face

Public void ConvertTag()

{

TaggedObject[] GetSelectedObjects = face_select0.GetSelectedObjects();

Face[] faces = new Face[0];

foreach (var to in GetSelectedObjects)

{

Array.Resize(ref faces, faces.Length + 1);

faces[faces.Length - 1] = (Face)to;

}

}

(2)这个通用方法为UG获取面属性

Public void GetFaceAttr(Face faces)

{

for (int a = 0; a < faces.Length; a++)

{

NXObject.AttributeInformation[] attributeInformation1 = faces[a].GetUserAttributes();

foreach (var ai in attributeInformation1)//遍历面属性

{

if (ai.Type == NXObject.AttributeType.String)//属性是string类型

{

if (ai.Title == "A")//属性名

{

string value= (ai.StringValue);

}

}

}

}

}

(3)这个通用方法为 判断圆形边是不是封闭的

/// <summary>

/// 判断圆形边是不是封闭的,返回的是bool值

/// </summary>

/// <param name="edgetag"></param>

/// <returns></returns>

bool judgecircle(Tag edgetag)//判断圆形边是不是封闭的,返回的是bool值

{

IntPtr uFEval1;

theUfSession.Eval.Initialize(edgetag, out uFEval1);

UFEval.Arc arc1;

theUfSession.Eval.AskArc(uFEval1, out arc1);

bool boolvar = false;

if (arc1.is_periodic)//判断是否为整圆

{

double[] arccenter = new double[100];

arccenter[0] = arc1.center[0];

arccenter[1] = arc1.center[1];

arccenter[2] = arc1.center[2];

double[] arcxaxis = new double[100];

arcxaxis[0] = arc1.x_axis[0];

arcxaxis[1] = arc1.x_axis[1];

arcxaxis[2] = arc1.x_axis[2];

double[] arcyaxis = new double[100];

arcyaxis[0] = arc1.y_axis[0];

arcyaxis[1] = arc1.y_axis[1];

arcyaxis[2] = arc1.y_axis[2];

double[] arcR = new double[100];

arcR[0] = arc1.radius;

bool boolisarc;

theUfSession.Eval.IsArc(uFEval1, out boolisarc);

if (Math.Abs(arc1.limits[0]) < 0.001 && Math.Abs(arc1.limits[1] - 2 * Math.PI) < 0.001)

{

boolvar = true;

}

theUfSession.Eval.Free(uFEval1);

}

return boolvar;

}

今天要介绍的就是这么多,我们下篇文章再见。

相关推荐
时光追逐者1 分钟前
排查 EF 保存数据时提示:Validation failed for one or more entities 的问题
数据库·c#·.net·ef
nono牛1 分钟前
bash语法与init.rc语法对比
开发语言·chrome·bash
9ilk1 分钟前
【C++】--- 类型转换
开发语言·c++
悟能不能悟4 分钟前
目前流行的前端框架
开发语言·javascript·ecmascript
时光追逐者6 分钟前
在 .NET 中将 EF Core 升级到 9.0.5 MySQL 连接提示 get_LockReleaseBehavior
数据库·mysql·c#·.net·ef core
计算机学姐7 分钟前
基于Python的智能点餐系统【2026最新】
开发语言·vue.js·后端·python·mysql·django·flask
risc1234568 分钟前
【备忘录】java.lang.Throwable#addSuppressed这个是干嘛的?
java·开发语言
宵时待雨8 分钟前
C语言笔记归纳17:数据的存储
c语言·开发语言·笔记
7ioik12 分钟前
什么是双亲委派?
开发语言·python
傻啦嘿哟16 分钟前
Python高效实现Excel与TXT文本文件数据转换指南
开发语言·python·excel