- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi. Thank you so much guys, for your help! this problem is bothering me.
Problem Description:
1. I have a block "door" like a rectangle that has been shaped with automatic constraints;
2. Then a vertical constraint parameter is built in the "Door" block: "Height", so the height is 500;
3. In addition, an nested block like a cross is inserted: "coordinateBlock";
4. Create a coincidence constraint on the top of the "Height" edge of "coordinateBlock" and "Door", such that the position is (0, 500);
5. Insert the "Door" block reference in the new file through the C# API code, and modify the "Door" constraint parameter "Height" to change the block reference height, such as from 500 to 800;
6. At this time, the position of the "coordinateBlock" has changed, and it has actually followed (0, 800);
Phenomenon:
1. The display position of the nested block "coordinateBlock" in the "Door" block in model space has indeed become (0, 800);
2. I have tried many methods, but I can't get the coordinate position (0, 800) after the "coordinateBlock" changes, but can only get the insert position (0, 500);
Question:
1. Is there any way to get the position data of the inline block changed by constraints without explode the "Door" block;
Code I use:
Document acDoc = Application.DocumentManager.MdiActiveDocument;
Database acCurDb = acDoc.Database;
Editor ed = acDoc.Editor;
using (Transaction acTrans = acCurDb.TransactionManager.StartTransaction())
{
BlockTable acBlkTbl = acTrans.GetObject(acCurDb.BlockTableId, OpenMode.ForRead) as BlockTable;
BlockTableRecord acBlkTblRec = acTrans.GetObject(acBlkTbl[BlockTableRecord.ModelSpace], OpenMode.ForRead) as BlockTableRecord;
foreach (ObjectId acObjId in acBlkTblRec)
{
if (acObjId.ObjectClass.Name == "AcDbBlockReference")
{
BlockReference bf = acObjId.GetObject(OpenMode.ForRead) as BlockReference;
string bname = (bf.IsDynamicBlock) ? (bf.DynamicBlockTableRecord.GetObject(OpenMode.ForRead) as BlockTableRecord).Name : bf.Name;
if (bname.StartsWith("Door"))
{
if (bf.IsDynamicBlock)
{
BlockTableRecord btr = bf.DynamicBlockTableRecord.GetObject(OpenMode.ForRead) as BlockTableRecord;
foreach (ObjectId item in btr)
{
if (item.ObjectClass.Name == "AcDbBlockReference")
{
BlockReference btf = item.GetObject(OpenMode.ForWrite) as BlockReference;
string tname = (btf.IsDynamicBlock) ? (btf.DynamicBlockTableRecord.GetObject(OpenMode.ForRead) as BlockTableRecord).Name : btf.Name;
if (tname.StartsWith("coordinateBlock"))
{
btf.Position; // here is not change (0, 200);
}
}
}
}
}
}
}
acTrans.Commit();
}
Solved! Go to Solution.