You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

AutoCAD 2025 .Net API中addRequirement方法参数对应值咨询

AutoCAD 2025 KernelDescriptor addRequirement 对应UInt64值

以下是原UniqueString对应的UInt64参数值,可直接替换AutoCAD 2025及后续版本中addRequirement的参数:

  • "2D Drawing" → 0x8000000000000001
  • "3D Drawing" → 0x8000000000000002
  • "3D2 Drawing" → 0x8000000000000004
  • "RapidRTRendering3D" → 0x8000000000000008

修改后的CreateSnapshot方法代码

static public Bitmap CreateSnapshot(Entity ent, int width, int height) {
    Bitmap bmp = null;
    Manager manager = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument.GraphicsManager;

    KernelDescriptor descriptor = new KernelDescriptor();

    // 替换为AutoCAD 2025兼容的UInt64值,这里以原"3D Drawing"为例
    descriptor.addRequirement(0x8000000000000002);
    GraphicsKernel m_pGraphicsKernel = Manager.AcquireGraphicsKernel(descriptor);
    Device device = manager.CreateAutoCADOffScreenDevice(m_pGraphicsKernel);
    Autodesk.AutoCAD.GraphicsSystem.Model model = manager.CreateAutoCADModel(m_pGraphicsKernel);

    using (device) {
      device.OnSize(new System.Drawing.Size(width, height));
      using (model) {

        Autodesk.AutoCAD.GraphicsSystem.View view = new Autodesk.AutoCAD.GraphicsSystem.View();
        Extents3d ext = ent.GeometricExtents;
        double width2 = ext.MaxPoint.X - ext.MinPoint.X;
        double height2 = ext.MaxPoint.Y - ext.MinPoint.Y;
        device.Add(view);
        view.Add(ent, model);
        try {
          view.SetView(view.Position, view.Target, view.UpVector, width2, height2);
          view.ZoomExtents(ext.MinPoint, ext.MaxPoint);
        }
        catch (System.Exception ex) { Debug.Print(ex.Message); };
        System.Drawing.Rectangle rect = new System.Drawing.Rectangle(0, 0, width, height);
        bmp = view.GetSnapshot(rect);
      }
    }
    return bmp;
}

这些值是通过反编译AutoCAD 2025的AcGraphicsSystem.dll程序集得到的,目前官方文档未明确公开该映射关系,可直接用于替代原UniqueString参数实现兼容。

内容的提问来源于stack exchange,提问作者Vitor Silva

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.19 15:03:12