Exemplo n.º 1
0
def ZoomBoundingBox(bounding_box, view=None, all=False):
    """Zooms to the extents of a specified bounding box in the specified view
    Parameters:
      bounding_box: eight points that define the corners of a bounding box
        or a BoundingBox class instance
      view:[opt] title or id of the view. If omitted, current active view is used
      all:[opt] zoom extents in all views
    """
    bbox = rhutil.coerceboundingbox(bounding_box)
    if bbox:
      if all:
          views = scriptcontext.doc.Views.GetViewList(True, True)
          for view in views: view.ActiveViewport.ZoomBoundingBox(bbox)
      else:
          view = __viewhelper(view)
          view.ActiveViewport.ZoomBoundingBox(bbox)
      scriptcontext.doc.Views.Redraw()
Exemplo n.º 2
0
def IsObjectInBox(object_id, box, test_mode=True):
    """Verifies an object's bounding box is inside of another bounding box
    Parameters:
      object_id: String or Guid. The identifier of an object
      box: bounding box to test for containment
      test_mode[opt] = If True, the object's bounding box must be contained by box
        If False, the object's bounding box must be contained by or intersect box
    Returns:
      True if object is inside box
      False is object is not inside box
    """
    rhobj = rhutil.coercerhinoobject(object_id, True, True)
    box = rhutil.coerceboundingbox(box, True)
    objbox = rhobj.Geometry.GetBoundingBox(True)
    if test_mode: return box.Contains(objbox)
    union = Rhino.Geometry.BoundingBox.Intersection(box, objbox)
    return union.IsValid
Exemplo n.º 3
0
def IsObjectInBox(object_id, box, test_mode=True):
    """Verifies an object's bounding box is inside of another bounding box
    Parameters:
      object_id: String or Guid. The identifier of an object
      box: bounding box to test for containment
      test_mode[opt] = If True, the object's bounding box must be contained by box
        If False, the object's bounding box must be contained by or intersect box
    Returns:
      True if object is inside box
      False is object is not inside box
    """
    rhobj = rhutil.coercerhinoobject(object_id, True, True)
    box = rhutil.coerceboundingbox(box, True)
    objbox = rhobj.Geometry.GetBoundingBox(True)
    if test_mode: return box.Contains(objbox)
    union = Rhino.Geometry.BoundingBox.Intersection(box, objbox)
    return union.IsValid
Exemplo n.º 4
0
def ZoomBoundingBox(bounding_box, view=None, all=False):
    """Zooms to the extents of a specified bounding box in the specified view
    Parameters:
      bounding_box: eight points that define the corners of a bounding box
        or a BoundingBox class instance
      view:[opt] title or id of the view. If omitted, current active view is used
      all:[opt] zoom extents in all views
    """
    bbox = rhutil.coerceboundingbox(bounding_box)
    if bbox:
        if all:
            views = scriptcontext.doc.Views.GetViewList(True, True)
            for view in views:
                view.ActiveViewport.ZoomBoundingBox(bbox)
        else:
            view = __viewhelper(view)
            view.ActiveViewport.ZoomBoundingBox(bbox)
        scriptcontext.doc.Views.Redraw()