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

大家好,今天继续讲我们的通用方法分享系列。

下面开始今天的通用方法分享:

(1)这个通用方法为切换制图模块

/// <summary>

/// 切换到制图模块

/// </summary>

public void DrawingModule()

{

//切换到制图模块

int s = 0;

theUfSession.UF.AskApplicationModule(out s);

if (s != 1)

{

theSession.ApplicationSwitchImmediate("UG_APP_DRAFTING");

}

//切换到制图模块

}

(2)这个通用方法为SW创建新零件:

/// <summary>

/// 创建新零件

/// </summary>

/// <param name="swAss"></param>

/// <returns></returns>

public static Component2 CreateNewPart(AssemblyDoc swAss,string filePath)

{

Component2 swcomp2 = null;

int longstatus1 = 0;

object swFaceOrPlane1 = null;

longstatus1 = swAss.InsertNewVirtualPart(swFaceOrPlane1, out swcomp2);

if (swcomp2 == null)

{

MessageBox.Show("未能创建虚拟零件!!!", "提示:");

}

else

{

swcomp2.Name2 = "example";

}

return swcomp2;

}

(3)这个通用方法为获得两点之间的距离

/// <summary>

/// 获取两点之间的距离

/// </summary>

/// <param name="startPoint"></param>

/// <param name="endPoint"></param>

/// <returns></returns>

public static double GetDistance(double[] startPoint, double[] endPoint)

{

double distance = 0.0;

if (startPoint.Length == 3 && endPoint.Length == 3)

{

double dx = (endPoint[0] - startPoint[0])*1000;

double dy = (endPoint[1] - startPoint[1]) * 1000;

double dz = (endPoint[2] - startPoint[2]) * 1000;

distance = Math.Sqrt(dx * dx + dy * dy + dz * dz);

}

distance = distance / 1000;

return distance;

}

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

相关推荐
yaoxin5211231 天前
229. Java 集合 - 操作集合中的多个元素(批量操作)
java·开发语言·python
C++chaofan1 天前
MyBatis - Plus学习笔记
java·spring boot·笔记·后端·mysql·架构·mybatis
HSJ01701 天前
Aviator中使用BigDecimal进行高精度计算
java·开发语言·bigdecimal·aviator
weixin_307779131 天前
利用 AWS Lambda 与 EventBridge 优化低频 Java 作业的云计算成本
java·开发语言·云原生·云计算·aws
一缕南风1 天前
Spring Boot 响应拦截器(Jackson)实现时间戳自动添加
java·spring boot·后端·拦截器
布列瑟农的星空1 天前
后台类项目如何挖掘前端技术亮点
前端·面试
期待のcode1 天前
Docker容器
java·docker·容器
Homeey1 天前
深入理解 synchronized:从硬件原子性到并发架构设计
java·后端
ZhangBlossom1 天前
【Java】EasyExcel实现导入导出数据库中的数据为Excel
java·数据库·excel
wangbing11251 天前
layui窗口标题
前端·javascript·layui