Message 1 of 2
How to make a block referecne with my position.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, everyone. Now I make a code to make a block referecne with customized position.
But if I use my position any block reference is not made. Could someone help me?
my code is as followings.
var doc = Application.DocumentManager.MdiActiveDocument;
var db = doc.Database;
var ed = doc.Editor;
int refcircount = 0;
refcircount++;
PromptPointResult pPtRes;
PromptPointOptions pPtOpts = new PromptPointOptions("");
// Prompt for the start point
pPtOpts.Message = "\nEnter the center point of the line: ";
pPtRes = ed.GetPoint(pPtOpts);
Point3d ptCenter = pPtRes.Value;
if (pPtRes.Status == PromptStatus.OK)
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
BlockTable acBlkTbl;
acBlkTbl = tr.GetObject(db.BlockTableId,
OpenMode.ForRead) as BlockTable;
BlockTableRecord acBlkTblRec = new BlockTableRecord();
acBlkTblRec.Name = "DirectionRef_PreVal "+ refcircount.ToString();
acBlkTbl.UpgradeOpen();
ObjectId btrId = acBlkTbl.Add(acBlkTblRec);
tr.AddNewlyCreatedDBObject(acBlkTblRec, true);
dirrefcount++;
DBObjectCollection ents = makefloorcircle(ptCenter);
foreach (Entity ent in ents)
{
acBlkTblRec.AppendEntity(ent);
tr.AddNewlyCreatedDBObject(ent, true);
}
DBObjectCollection ents1 = makeResiBUAcircle(ptCenter);
foreach (Entity ent1 in ents1)
{
acBlkTblRec.AppendEntity(ent1);
tr.AddNewlyCreatedDBObject(ent1, true);
}
BlockTableRecord ms = (BlockTableRecord)tr.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForWrite);
BlockReference br =new BlockReference(ptCenter, btrId);
ms.AppendEntity(br);
tr.AddNewlyCreatedDBObject(br, true);
tr.Commit();
}
}
Here If I use BlockReference br =new BlockReference(Point3d.Origin, btrId); it works well. Thank you in advance.