无法找到名为"?acadHatchPalletteDialog@@YA_NPB_W_NAAPA_W@Z",的入口点,求解决
青瓜蛋子 2015-11-22 12:45:57 using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.Colors;
using Autodesk.AutoCAD.DatabaseServices;
using System.Security;
using System.Runtime.InteropServices;
namespace DotNetARX
{
/// <summary>
/// 填充图案选项板类
/// </summary>
public class HatchPalletteDialog
{
[SuppressUnmanagedCodeSecurity]
[DllImport("acad.exe", EntryPoint = "?acadHatchPalletteDialog@@YA_NPB_W_NAAPA_W@Z", CharSet = CharSet.Auto)]
static extern bool acedHatchPalletteDialog(string currentPattern, bool showCustom, out IntPtr newPattern);
private string pattern;//用于存储用户选择的填充图案名称
/// <summary>
/// 是否显示自定义标签
/// </summary>
public bool ShowCustom { get; set; }
/// <summary>
/// 获取用户选择的填充图案名称
/// </summary>
/// <returns>返回填充图案名称</returns>
public string GetPattern()
{
return pattern;
}
/// <summary>
/// 构造函数,在填充图案选项板中显示自定义标签
/// </summary>
public HatchPalletteDialog()
{
ShowCustom = true;//显示自定义标签
}
/// <summary>
/// 显示填充图案选项板
/// </summary>
/// <returns>如果用户选择了填充图案,则返回true,否则返回false</returns>
public bool ShowDialog()
{
IntPtr ptr;//用户选择的
//显示填充图案选项板
bool isOK = acedHatchPalletteDialog(HatchTools.CurrentPattern, ShowCustom, out ptr);
if (!isOK) return false;//如果用户未选择填充图案,返回false
//用户选择了填充图案,通过指针获得图案名称并将其置为当前名称
pattern = HatchTools.CurrentPattern = Marshal.PtrToStringAuto(ptr);
return true;
}
}
public static class HatchTools
{
public static string CurrentPattern
{
//获取HPNAME系统变量值,它表示默认的填充图案名
get{return Application .GetSystemVariable ("HPNAME").ToString ();}
set
{
//如果要设置的值符合填充图案名,则设置HPNAME系统变量值
if (value.Length <= 34 && !value.Contains(" ") && !string .IsNullOrEmpty (value ) && value != CurrentPattern)
Application.SetSystemVariable("HPNAME", value);
}
}
public static void CreateHatch(this Hatch hatch,HatchPatternType patternType,string patternName,bool associative)
{
Database db = HostApplicationServices.WorkingDatabase;
hatch.SetDatabaseDefaults();//设置填充的属性为当前数据库默认值
//设置图案填充的类型和填充图案名
hatch.SetHatchPattern(patternType, patternName);
db.AddToModelSpace(hatch);//将填充添加到模型空间中
//设置填充和边界是否关联
hatch.Associative = associative ? true : false;
}
}
}
我用的是2010版CAD,而这段代码用的是2008版,不知道该如何处理。