Jig操作拖动墙块
用的是autocad2018+vs2015写的代码详见:
AutoCad 二次开发 Jig操作之墙块的拖动
代码在这个地址里:
https://www.cnblogs.com/HelloQLQ/p/12148343.html 楼主加油啊,多出好作品! 楼主大神,少了tospace函数,能否上传上来给大家学习?谢谢! mycad 发表于 2020-4-22 14:17
楼主大神,少了tospace函数,能否上传上来给大家学习?谢谢!
我去找找看 public static ObjectId ToSpace(this Entity ent, Database db = null, string space = null)
{
db = db ?? Application.DocumentManager.MdiActiveDocument.Database;
var id = ObjectId.Null;
using (var trans = db.TransactionManager.StartTransaction())
{
var blkTbl = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
var mdlSpc = trans.GetObject(blkTbl,
OpenMode.ForWrite) as BlockTableRecord;
id = mdlSpc.AppendEntity(ent);
trans.AddNewlyCreatedDBObject(ent, true);
trans.Commit();
}
return id;
}
/// <summary>
/// 将实体集合添加到特定空间。
/// </summary>
/// <param name="ents"></param>
/// <param name="db"></param>
/// <param name="space"></param>
/// <returns></returns>
public static ObjectIdCollection ToSpace(this IEnumerable<Entity> ents,
Database db = null, string space = null)
{
db = db ?? Application.DocumentManager.MdiActiveDocument.Database;
var ids = new ObjectIdCollection();
using (var trans = db.TransactionManager.StartTransaction())
{
var blkTbl = trans.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
var mdlSpc = trans.GetObject(blkTbl,
OpenMode.ForWrite) as BlockTableRecord;
foreach (var ent in ents)
{
ids.Add(mdlSpc.AppendEntity(ent));
trans.AddNewlyCreatedDBObject(ent, true);
}
trans.Commit();
}
return ids;
}
mycad 发表于 2020-4-22 14:17
楼主大神,少了tospace函数,能否上传上来给大家学习?谢谢!
已经上传了,你自己看一下,是扩展方法。
页:
[1]