Author Topic: Modify insertion point of simple block  (Read 2380 times)

0 Members and 1 Guest are viewing this topic.

BillZndl

  • Guest
Modify insertion point of simple block
« on: August 05, 2014, 04:40:22 PM »
I have many drawings containing a simple block, that was first defined years ago, with multiple references. That have been copied and inserted from other drawings over the years.
The references, when inserted, shows the small area of visible polyline entities, approx. 150" away from the actual insertion point (shows up as a blue grip point when the reference is selected).
I would like to correct this block programically using C# so that the insertion point is within the graphical area of the block.
I believe hat may mean moving the entities to the insertion point and moving the block to the correct position.

I've tried to use TransformBy on the entities (mostly polylines) of the exploded block reference but it doesn't seem to affect complex entities?
I'm working on a drawing that contains only one reference to the block record until I get it right.
Do I need to redefine the BlockTableRecord? If so, Can someone give me a hint on how to move the entities?
Been looking at all web the posts but nothing seems to tell me how to change the relation between the entities in the block and the insertion point.

The Blocktablerecord of this reference has an Origin of 0,0,0.
The drawings all have an insertion point and base point of 0,0,0.

Code - C#: [Select]
  1. using (DocumentLock doclck = doc.LockDocument())
  2.             {
  3.                 using (Transaction trans = db.TransactionManager.StartTransaction())
  4.                 {
  5.                     BlockReference br = trans.GetObject(per.ObjectId, OpenMode.ForWrite) as BlockReference;
  6.                     ObjectId blockId = br.BlockTableRecord;
  7.                     BlockTableRecord btr = trans.GetObject(blockId, OpenMode.ForWrite) as BlockTableRecord;
  8.                                        
  9.                                          
  10.                         Point3d org = btr.Origin;
  11.                         Point3d pmin = br.Bounds.Value.MinPoint;
  12.                         Point3d pmax = br.Bounds.Value.MaxPoint;
  13.                         Point3d newPos = (Point3d)(pmin + (pmax - pmin) / 2);  //center of graphical area of entities.
  14.                         Vector3d vec = org.GetVectorTo(newPos);                
  15.                         Matrix3d mat = Matrix3d.Displacement(vec);                                          
  16.  
  17.                         br.RecordGraphicsModified(true);
  18.                              
  19.  
  20.                     trans.Commit();
  21.                 }

TIA
Bill
« Last Edit: August 07, 2014, 10:57:00 AM by BillZndl »

BillZndl

  • Guest
Re: Modify insertion point of simple block
« Reply #1 on: August 06, 2014, 06:22:05 AM »
Oh, Wait!
After I posted this, I thought of some code I had from several years ago.
I'll get this straightened out and post back after I do.

Thanks!

Bill

BillZndl

  • Guest
Re: Modify insertion point of simple block
« Reply #2 on: August 06, 2014, 08:10:55 AM »
I posted my results over in the .NET Library threads/block routines section found in the sticky at the top of the forum page.