明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1807|回复: 8

[JIG] Jig操作拖动墙块

[复制链接]
发表于 2020-1-4 11:50 | 显示全部楼层 |阅读模式
用的是AutoCAD2018+vs2015写的
代码详见:
AutoCad 二次开发 Jig操作之墙块的拖动

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2020-1-4 11:52 | 显示全部楼层
代码在这个地址里:
https://www.cnblogs.com/HelloQLQ/p/12148343.html
发表于 2020-2-9 20:27 | 显示全部楼层
楼主加油啊,多出好作品!
发表于 2020-4-22 14:17 | 显示全部楼层
楼主大神,少了tospace函数,能否上传上来给大家学习?谢谢!
 楼主| 发表于 2020-4-22 14:20 | 显示全部楼层
mycad 发表于 2020-4-22 14:17
楼主大神,少了tospace函数,能否上传上来给大家学习?谢谢!

我去找找看
 楼主| 发表于 2020-4-22 14:25 | 显示全部楼层
  1. public static ObjectId ToSpace(this Entity ent, Database db = null, string space = null)
  2.         {
  3.             db = db ?? Application.DocumentManager.MdiActiveDocument.Database;
  4.             var id = ObjectId.Null;

  5.             using (var trans = db.TransactionManager.StartTransaction())
  6.             {
  7.                 var blkTbl = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
  8.                 var mdlSpc = trans.GetObject(blkTbl[space ?? BlockTableRecord.ModelSpace],
  9.                     OpenMode.ForWrite) as BlockTableRecord;

  10.                 id = mdlSpc.AppendEntity(ent);
  11.                
  12.                 trans.AddNewlyCreatedDBObject(ent, true);

  13.                 trans.Commit();
  14.             }

  15.             return id;
  16.         }

  17.         /// <summary>
  18.         /// 将实体集合添加到特定空间。
  19.         /// </summary>
  20.         /// <param name="ents"></param>
  21.         /// <param name="db"></param>
  22.         /// <param name="space"></param>
  23.         /// <returns></returns>
  24.         public static ObjectIdCollection ToSpace(this IEnumerable<Entity> ents,
  25.             Database db = null, string space = null)
  26.         {
  27.             db = db ?? Application.DocumentManager.MdiActiveDocument.Database;
  28.             var ids = new ObjectIdCollection();

  29.             using (var trans = db.TransactionManager.StartTransaction())
  30.             {
  31.                 var blkTbl = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
  32.                 var mdlSpc = trans.GetObject(blkTbl[space ?? BlockTableRecord.ModelSpace],
  33.                     OpenMode.ForWrite) as BlockTableRecord;

  34.                 foreach (var ent in ents)
  35.                 {
  36.                     ids.Add(mdlSpc.AppendEntity(ent));
  37.                     trans.AddNewlyCreatedDBObject(ent, true);
  38.                 }

  39.                 trans.Commit();
  40.             }

  41.             return ids;
  42.         }



本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?注册

x
 楼主| 发表于 2020-4-22 14:26 | 显示全部楼层
mycad 发表于 2020-4-22 14:17
楼主大神,少了tospace函数,能否上传上来给大家学习?谢谢!

已经上传了,你自己看一下,是扩展方法。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-6 14:21 , Processed in 0.578156 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表