|
大家好。
我只是在学习如何在AutoCAD中使用WPF,希望有人能帮助我学习如何完成这个过程,以便我以后能够自己编写未来的程序。
这是一个简单的对话框,其中有一个按钮名为“绘制线”
。我需要按下按钮,然后程序应该绘制从0,0,0到10,10,0的线。
是否能够在Autocad中运行它
非常感谢
xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation“
xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml“
Title=“MainWindow”Height=“100”Width=“250”HorizontalAlignment=“Left”verticalignment=“Top”>
这是我用来通过dll文件画线的C#代码。
使用System
使用System.Collections.Generic
使用System.Linq
使用System.Threading.Tasks
使用System.Text
使用Autodesk.AutoCAD.Runtime
使用Autodesk.AutoCAD.ApplicationServices
使用Autodesk.AutoCAD.DatabaseServices
使用Autodesk.AutoCAD.Geometry
使用App=Autodesk.AutoCAD.ApplicationServices.Application
名称空间WindowsFormsApplication1
{
类抽绳
{
[CommandMethod(“Drline”)]
静态公共无效行()
{
文档acDoc=App.DocumentManager.MdiActiveDocument
数据库acCurDb=acDoc.Database
使用(Transaction-acTrans=acCurDb.TransactionManager.StartTransaction())
{
BlockTable:acBlkTbl=acTrans.GetObject(acCurDb.BlockTableId,OpenMode.ForRead)作为BlockTable
BlockTableRecord:acBlkTblRec=acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace],OpenMode.ForWrite)作为blockTable记录
Line-acLine=新线(新点3d(0,0,0),新点3D(10,10,0))
acBlkTblRec.AppendEntity(acLine)
演员。AddNewlyCreatedBobObject(acLine,true)
acTrans.Commit()
}
}
}
}
本帖以下内容被隐藏保护;需要你回复后,才能看到! 游客,如果您要查看本帖隐藏内容请 回复 |
|