Block insertion point


#1

i went through the sample to set / reset the insertion point of block

i don’t get how the code in the sample helps in changing the base point.

It only creates a point object of the base point in the document.
Kindly throw some light.

when the block has the insertion point (10, 10), it looks fine in the layout page but when print is clicked with extents visibility and scaled to fit, the block moves another (10, 10) from the margin.

why is this so?


(Dale Fugier) #2

Hi @HepChan,

Yea either the sample is incorrect, or the description.

Here’s how you ‘move’ a block instance to a new location - to the world origin in this example.

protected override Result RunCommand(RhinoDoc doc, RunMode mode)
{
  ObjRef objref;
  var rc = RhinoGet.GetOneObject("Select instance", true, ObjectType.InstanceReference, out objref);
  if (rc != Result.Success)
    return rc;

  var rh_instance = objref.Object() as InstanceObject;
  if (null != rh_instance)
  {
    var xform = Transform.Translation(Point3d.Origin - rh_instance.InsertionPoint);
    doc.Objects.Transform(rh_instance, xform, true);
    doc.Views.Redraw();
  }

  return Result.Success; 
}

– Dale