Message 1 of 8
entity position deviates from the specified position while copy BlockReference by blockId
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
static void CopyBlocks()
{
Database db = HostApplicationServices.WorkingDatabase;
Document doc = Autodesk.AutoCAD.ApplicationServices.Application.DocumentManager.MdiActiveDocument;
Editor ed = doc.Editor;
var dynBlockNames = new List<string> { "block1", "block2", "block3" };
for (int i = 0; i < dynBlockNames.Count; i++)
{
var basePoint = new Point3d(i, i, i);
ObjectId blockId;
BlockReference newBr;
using (Transaction trans = db.TransactionManager.StartTransaction())
{
BlockTable bt = (BlockTable)trans.GetObject(db.BlockTableId, OpenMode.ForRead);
newBr = new BlockReference(basePoint, bt["blockName"]);
BlockTableRecord modelSpace = trans.GetObject(SymbolUtilityServices.GetBlockModelSpaceId(db), OpenMode.ForWrite) as BlockTableRecord;
modelSpace.AppendEntity(newBr);
blockId = newBr.ObjectId;
trans.Commit();
}
using (Transaction trans = db.TransactionManager.StartTransaction())
{
for (int j = 100; j < 1000; i++)
{
var tp = new Point3d(j, j, j);
ed.Command("_.COPY", blockId, "", basePoint, tp);
}
trans.Commit();
}
}
}
something was wrong with the specified position "tp"