当前位置:网站首页>2021-07-17C#/CAD二次开发创建圆(5)
2021-07-17C#/CAD二次开发创建圆(5)
2022-07-02 06:23:00 【徐记荣】
Circle c1 = new Circle();
c1.Center = new Point3d(50, 50, 0);
c1.Radius = 50;
Circle c2 = new Circle(new Point3d(100, 100, 0), new Vector3d(0, 0, 1), 50);
创建圆的类Circle有如上两种方法:
先通过Circle创建一个对象,然后再给他的圆心、半径赋值
或者直接创建时赋值。
绘制圆和圆弧一样,封装到AddEnityTool.ca代码如下
/// <summary>
/// 绘制圆
/// </summary>
/// <param name="db">图形数据库</param>
/// <param name="center">圆心</param>
/// <param name="radius">半径</param>
/// <returns></returns>
public static ObjectId AddCircleModelSpace(Database db, Point3d center, double radius)
{
return AddEnityTool.AddEnityToModelSpace(db, new Circle(center, new Vector3d(0, 0, 1), radius));
}
/// <summary>
/// 两点绘制圆
/// </summary>
/// <param name="db">图形数据库</param>
/// <param name="point1">第一个点</param>
/// <param name="point2">第二个点</param>
/// <returns>ObjectId</returns>
public static ObjectId AddCircleModelSpace(Database db, Point3d point1, Point3d point2)
{
//获取中心点
Point3d center = BaseTool.GetCenterPointBetweenTwoPoint(point1, point2);
//获取半径
double radius = BaseTool.GetDistanceBetweenTwoPoint(point1, center);
return AddEnityTool.AddCircleModelSpace(db, center, radius);
}
/// <summary>
/// 三点绘制圆
/// </summary>
/// <param name="db">图形数据库</param>
/// <param name="point1">第一个点</param>
/// <param name="point2">第二个点</param>
/// <param name="point3">第三个点</param>
/// <returns>ObjectId</returns>
public static ObjectId AddCircleModelSpace(Database db, Point3d point1, Point3d point2, Point3d point3)
{
//先判断三点是否在同一直线上
if (BaseTool.IsOnOneLine(point1, point2, point3))
{
return ObjectId.Null;
}
//声明几何类的CircularArc3d对象
CircularArc3d cArc = new CircularArc3d(point1, point2, point3);
return AddEnityTool.AddCircleModelSpace(db, cArc.Center, cArc.Radius);
}
}
}
边栏推荐
- A preliminary study on ant group G6
- js判断对象是否为空
- Kotlin - verify whether the time format is yyyy MM DD hh:mm:ss
- Sentry搭建和使用
- [daily question 1] write a function to judge whether a string is the string after the rotation of another string.
- In depth study of JVM bottom layer (II): hotspot virtual machine object
- Latex warning: citation "*****" on page y undefined on input line*
- Linux MySQL 5.6.51 community generic installation tutorial
- PgSQL learning notes
- PHP Session原理简析
猜你喜欢
Build learning tensorflow
Latest CUDA environment configuration (win10 + CUDA 11.6 + vs2019)
Thread hierarchy in CUDA
Stack (linear structure)
Wechat applet Foundation
SQL注入闭合判断
There is no way to drag the win10 desktop icon (you can select it, open it, delete it, create it, etc., but you can't drag it)
Explanation and application of annotation and reflection
Cve-2015-1635 (ms15-034) Remote Code Execution Vulnerability recurrence
Présence d'une panne de courant anormale; Problème de gestion de la fsck d'exécution résolu
随机推荐
Sentry搭建和使用
Fe - weex uses a simple encapsulated data loading plug-in as the global loading method
The default Google browser cannot open the link (clicking the hyperlink does not respond)
Vscode installation, latex environment, parameter configuration, common problem solving
The win10 network icon disappears, and the network icon turns gray. Open the network and set the flash back to solve the problem
Apt command reports certificate error certificate verification failed: the certificate is not trusted
PgSQL learning notes
Underlying mechanism mvcc
[daily question 1] write a function to judge whether a string is the string after the rotation of another string.
selenium备忘录:selenium\webdriver\remote\remote_connection.py:374: ResourceWarning: unclosed<xxxx>解决办法
JS countdown case
默认google浏览器打不开链接(点击超链接没有反应)
After reading useful blogs
js中map和forEach的用法
Win10: add or delete boot items, and add user-defined boot files to boot items
Atcoder beginer contest 253 F - operations on a matrix / / tree array
Pytest (1) case collection rules
How to try catch statements that return promise objects in JS
CVE-2015-1635(MS15-034 )远程代码执行漏洞复现
js的防抖和节流