为何我全部缩放所有图元总提示有问题
我想放大整个图形10倍,程序代码如下,但总有问题,请高手帮忙看看吧!public static void seAll(Point3d pt)
{
Document acDoc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
Editor ed = acDoc.Editor;
Entity entity = null;
DBObjectCollection EntityCollection = new DBObjectCollection();
PromptSelectionResult ents = ed.SelectAll();
if (ents.Status == PromptStatus.OK)
{
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
BlockTable acBlkTbl;
acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord acBlkTblRec;
acBlkTblRec = acTrans.GetObject(acBlkTbl, OpenMode.ForWrite) as BlockTableRecord;
SelectionSet ss = ents.Value;
foreach (ObjectId id in ss.GetObjectIds())
{
entity = acTrans.GetObject(id, OpenMode.ForWrite, true) as Entity;
if (entity != null)
{
entity.TransformBy(Matrix3d.Scaling(10, pt));
acBlkTblRec.AppendEntity(entity);
acTrans.AddNewlyCreatedDBObject(entity, true);
}
}
acTrans.Commit();
}
}
else
{
ed.WriteMessage("全部图元选择失败");
}
}
总提示 acBlkTblRec.AppendEntity(entity);有问题,不知是什么原因
你只是修改实体,你用acBlkTblRec.AppendEntity(entity);
acTrans.AddNewlyCreatedDBObject(entity, true);这两个函数干嘛?
实体已经存在,你重复添加当然会报错。 sieben 发表于 2012-6-1 14:14 static/image/common/back.gif
你只是修改实体,你用acBlkTblRec.AppendEntity(entity);
acTrans.AddNewlyC ...
谢谢,搞定了!
页:
[1]