Message 1 of 18
Problem when insert and move a block references
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hi everyone
I want to insert a block reference to my drawing. Sometimes I have a problem with moving. When the block reference is inserted, the base point has moved away from the lines and lines will show in the wrong position.
The piece of code I used is:
using (DocumentLock dlock = doc.LockDocument())
{
using (Transaction tr = db.TransactionManager.StartTransaction())
{
#region bt
// Open the Block table for read
BlockTable bt;
bt = tr.GetObject(db.BlockTableId, OpenMode.ForRead) as BlockTable;
ObjectId blockId = ObjectId.Null;
if (bt.Has(blockName))
blockId = bt[blockName];
else
return;
#endregion
// Focus on drawing
Autodesk.AutoCAD.Internal.Utils.SetFocusToDwgView();
using (BlockReference br = new BlockReference(Point3d.Origin, blockId))
{
#region Move BlockReference
Point3d p3d = Point3d.Origin;
Vector3d vector3D = p3d.GetVectorTo(insertPoint.Point3d());
br.TransformBy(Matrix3d.Displacement(vector3D));
#endregion
...
}This problem only happens sometimes and this code works correctly most of the time.
How can I fix it?