- UID
- 658062
- 积分
- 2147
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2008-10-22
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
原帖地址:
http://blog.sina.com.cn/s/blog_4cb57a380101f5gt.html
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Autodesk.AutoCAD.ApplicationServices;
using Autodesk.AutoCAD.DatabaseServices;
using Autodesk.AutoCAD.Geometry;
namespace DotNetARX
{
public static class EntTools
{
public static void Move(this ObjectId id, Point3d sourcePt, Point3d targetPt)
{
//构建用于移动实体的函数
Vector3d vector = targetPt.GetVectorTo(sourcePt);//获得一个从起点到终点的向量vector
Matrix3d mt = Matrix3d.Displacement(vector);//构建移动矩阵
//displacement是matrix3d的一个函数(方法),用于构建一个以vector为向量的矩阵
//以写的方式打开ID表示的实体对象
Entity ent = (Entity)id.GetObject(OpenMode.ForWrite);
偏移时用到的addtomodelspace:
public static ObjectIdCollection AddToModelSpace(this Database db, params Entity[] ents)
{
ObjectIdCollection ids = new ObjectIdCollection();
var trans = db.TransactionManager;
BlockTableRecord btr = (BlockTableRecord)trans.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite);
foreach (var ent in ents)
{
ids.Add(btr.AppendEntity(ent));
trans.AddNewlyCreatedDBObject(ent, true);
}
btr.DowngradeOpen();
return ids;
}
|
|