C# CAD 二次开发 多边形角度
时间: 2023-10-19 11:58:02 浏览: 232
C# CAD二次开发中,获取多边形的角度可以使用尺寸标注类中的转角标注(rotateddimension)。通过选择多边形的边界线,然后使用代码中的GetSelection方法获取选中的尺寸标注对象。在循环中,可以通过RotatedDimension对象的Measurement属性获取每个角度的数值。以下是一个获取多边形角度的示例代码:
```
public void GetPolygonAngles()
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
var selectedDimensions = from dim in db.GetSelection<RotatedDimension>()
where dim.ColorIndex >= 0
select dim;
foreach (RotatedDimension dimension in selectedDimensions)
{
double angle = dimension.Measurement;
Application.ShowAlertDialog("角度: " + angle.ToString());
}
trans.Commit();
}
}
```
这段代码将获取选中的转角标注对象,并循环输出每个转角标注的角度。请注意,你需要在你的项目中引用相应的命名空间和CAD开发库。<em>1</em><em>2</em><em>3</em>
#### 引用[.reference_title]
- *1* *2* [cad二次开发c#学习记录4——导出图纸标注的尺寸](https://blog.csdn.net/weixin_48897477/article/details/127777400)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
- *3* [cad二次开发C#学习记录5——导出属性块信息](https://blog.csdn.net/weixin_48897477/article/details/128601490)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}} ] [.reference_item]
[ .reference_list ]
阅读全文