采用c#CAD二次开发,怎么添加填充,且不用用户先选择填充图案,而之直接给他设定图案,那位大神指点迷津下
先在cad录制一个宏。然后再在你的代码中照着写就可以了。
试过了不知道怎么看宏代码,和word等office不一样,另外cad没有给接口,是通过P/Invoke技术实现,也试过了但老是出现无法找到入口点
using Autodesk.AutoCAD.Runtime;
using Autodesk.AutoCAD.EditorInput;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.ApplicationServices;
using System.Reflection;
using System.Runtime.InteropServices;
namespace HatchDialogTest
{
public class Commands
{
** [DllImport(
"acad.exe",
EntryPoint =
"?acedHatchPalletteDialog@@YA_NPB_W_NAAPA_W@Z",
CharSet = CharSet.Auto
)
]**
static extern bool acedHatchPalletteDialog(
string currentPattern,
bool showcustom,
out string newpattern
);
[CommandMethod("SHD")]
static public void ShowHatchDialog()
{
string sHatchType;
string sNewHatchType;
bool bRet;
sHatchType = "ANGLE";
bRet =
acedHatchPalletteDialog(
sHatchType,
true,
out sNewHatchType
);
if (bRet)
{
Editor ed =
Application.DocumentManager.MdiActiveDocument.Editor;
ed.WriteMessage(
"\nHatch type selected: " + sNewHatchType
);
}
}
}
}
Here's what happens when you run the code:
Command: SHD
Hatch_dialog
D应该是llImport后面的问题但又不知道怎么改,
代码参照Kean Walmsley的代码,源代码http://through-the-interface.typepad.com/through_the_interface/2007/03/showing_autocad.html