![]() |
【转帖】【kean】用.net使用标准autocad对话框设置颜色,线形和线宽(c#) - 精华帖集合
【kean】用.net使用标准autocad对话框设置颜色,线形和线宽(c#) - 精华帖集合
www.dimcax.com 【kean】用.net使用标准autocad对话框设置颜色,线形和线宽(c#) 在“autodesk.autocad.windows”命名空间有许多便利的对话框可以使用。下面的代码使用了3个:colordialog,linetypedialog和lineweightdialog。这3个类可以让你通过非常简单的交互界面选择他们对应的属性。 下面是c#代码: using autodesk.autocad.runtime; using autodesk.autocad.applicationservices; using autodesk.autocad.databaseservices; using autodesk.autocad.editorinput; using autodesk.autocad.windows; namespace autocaddialogs { public class commands { [commandmethod("cdl")] public void showcolordialog() { document doc = application.documentmanager.mdiactivedocument; database db = doc.database; editor ed = doc.editor; colordialog cd = new colordialog(); system.windows.forms.dialogresult dr = cd.showdialog(); if (dr == system.windows.forms.dialogresult.ok) { ed.writemessage( "\ncolor selected: " + cd.color.tostring() ); } } [commandmethod("ltdl")] public void showlinetypedialog() { document doc = application.documentmanager.mdiactivedocument; database db = doc.database; editor ed = doc.editor; linetypedialog ltd = new linetypedialog(); system.windows.forms.dialogresult dr = ltd.showdialog(); if (dr == system.windows.forms.dialogresult.ok) { ed.writemessage( "\nlinetype selected: " + ltd.linetype.tostring() ); } } [commandmethod("lwdl")] public void showlineweightdialog() { document doc = application.documentmanager.mdiactivedocument; database db = doc.database; editor ed = doc.editor; lineweightdialog lwd = new lineweightdialog(); system.windows.forms.dialogresult dr = lwd.showdialog(); if (dr == system.windows.forms.dialogresult.ok) { ed.writemessage( "\nlineweight selected: " + lwd.lineweight.tostring() ); } } } } 复制代码 运行cdl命令得到标准颜色对话框,其中包含3个标签: ltdl命令 lwdl命令 运行3个命令以后得到的结果, command: cdl color selected: 91 command: cdl color selected: 56,166,199 command: cdl color selected: dic 266 command: ltdl linetype selected: (2130316464) command: lwdl lineweight selected: lineweight009 好东西.顶了先 |
所有的时间均为北京时间。 现在的时间是 01:41 AM. |