无法找到名为"?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版,不知道该如何处理。

...全文
334 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
青瓜蛋子 2016-01-01
  • 打赏
  • 举报
回复
调用CAD填充对话框,就是为了选择填充的图案,这个在程序中就可以设置,没必要在弹出填充图案对话框让使用者选择,真想说句当时的我SB
xian_wwq 2015-11-23
  • 打赏
  • 举报
回复
找不到入口点,可能是因为dll中的函数名称不对 可以用Depends工具查看具体的函数名称
Poopaye 2015-11-22
  • 打赏
  • 举报
回复
装个2008版的CAD

110,524

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧