Block Insertion Point
Demonstrates how to set (or reset) the block insertion point of a block instance.
partial class Examples
{
public static Rhino.Commands.Result BlockInsertionPoint(Rhino.RhinoDoc doc)
{
Rhino.DocObjects.ObjRef objref;
Result rc = Rhino.Input.RhinoGet.GetOneObject("Select instance", true, Rhino.DocObjects.ObjectType.InstanceReference, out objref);
if (rc != Rhino.Commands.Result.Success)
return rc;
Rhino.DocObjects.InstanceObject instance = objref.Object() as Rhino.DocObjects.InstanceObject;
if (instance != null)
{
Rhino.Geometry.Point3d pt = instance.InsertionPoint;
doc.Objects.AddPoint(pt);
doc.Views.Redraw();
}
return Rhino.Commands.Result.Success;
}
}
Partial Friend Class Examples
Public Shared Function BlockInsertionPoint(ByVal doc As Rhino.RhinoDoc) As Rhino.Commands.Result
Dim objref As Rhino.DocObjects.ObjRef = Nothing
Dim rc As Result = Rhino.Input.RhinoGet.GetOneObject("Select instance", True, Rhino.DocObjects.ObjectType.InstanceReference, objref)
If rc IsNot Rhino.Commands.Result.Success Then
Return rc
End If
Dim instance As Rhino.DocObjects.InstanceObject = TryCast(objref.Object(), Rhino.DocObjects.InstanceObject)
If instance IsNot Nothing Then
Dim pt As Rhino.Geometry.Point3d = instance.InsertionPoint
doc.Objects.AddPoint(pt)
doc.Views.Redraw()
End If
Return Rhino.Commands.Result.Success
End Function
End Class
import Rhino
import scriptcontext
def BlockInsertionPoint():
rc, objref = Rhino.Input.RhinoGet.GetOneObject("Select instance", True, Rhino.DocObjects.ObjectType.InstanceReference)
if rc!=Rhino.Commands.Result.Success: return rc;
instance = objref.Object()
if instance:
pt = instance.InsertionPoint
scriptcontext.doc.Objects.AddPoint(pt)
scriptcontext.doc.Views.Redraw()
return Rhino.Commands.Result.Success
return Rhino.Commands.Result.Failure
if __name__=="__main__":
BlockInsertionPoint()