zoukankan      html  css  js  c++  java
  • CAD二次开发(02)-添加对象到模型空间

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using Autodesk.AutoCAD.DatabaseServices;
    using Autodesk.AutoCAD.Geometry;
    using Autodesk.AutoCAD.Runtime;
    [assembly:CommandClass(typeof(_01_环境测试.AddToModelSpace))]
    namespace _01_环境测试
    {
        class AddToModelSpace
        {
            [CommandMethod("ToModelSpace")]
            public void ModelSpace()
            {
                Database db = HostApplicationServices.WorkingDatabase;
                DBText txt=new DBText();
                txt.Position=new Point3d(100,200,0);
                txt.TextString = "Bim中心";
                ToModelSpace(txt, db);
            }
    
            public static ObjectId ToModelSpace(Entity ent,Database db)
            {
                ObjectId entId;
                using (Transaction trans=db.TransactionManager.StartTransaction())
                {
                    BlockTable bt = (BlockTable) trans.GetObject(db.BlockTableId, OpenMode.ForRead);
                    BlockTableRecord btr =
                        (BlockTableRecord) trans.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
                    entId = btr.AppendEntity(ent);
                    trans.AddNewlyCreatedDBObject(ent,true);
                    trans.Commit();
                }
                return entId;
            }
        }
    }
  • 相关阅读:
    ios状态栏
    RGBA设置颜色
    应用程序的生命周期(转)
    UIViewController的生命周期
    UIViewController的创建
    UIButton
    NSUserDefaults
    打印结构体
    iOS 界面间的传值 属性传值 代理传值
    如何安装Homebrew
  • 原文地址:https://www.cnblogs.com/civil/p/9046134.html
Copyright © 2011-2022 走看看