def AddDetail(layout_id, corner1, corner2, title=None, projection=1): """Add new detail view to an existing layout view Parameters: layout_id = identifier of an existing layout corner1, corner2 = 2d corners of the detail in the layout's unit system title[opt] = title of the new detail projection[opt] = type of initial view projection for the detail 1 = parallel top view 2 = parallel bottom view 3 = parallel left view 4 = parallel right view 5 = parallel front view 6 = parallel back view 7 = perspective view Returns: identifier of the newly created detial on success None on error """ layout_id = rhutil.coerceguid(layout_id, True) corner1 = rhutil.coerce2dpoint(corner1, True) corner2 = rhutil.coerce2dpoint(corner2, True) if projection<1 or projection>7: raise ValueError("projection must be a value between 1-7") layout = scriptcontext.doc.Views.Find(layout_id) if not layout: raise ValueError("no layout found for given layout_id") projection = System.Enum.ToObject(Rhino.Display.DefinedViewportProjection, projection) detail = layout.AddDetailView(title, corner1, corner2, projection) if not detail: return scriptcontext.errorhandler() scriptcontext.doc.Views.Redraw() return detail.Id
def AddDetail(layout_id, corner1, corner2, title=None, projection=1): """Adds new detail view to an existing layout view Parameters: layout_id = identifier of an existing layout corner1, corner2 = 2d corners of the detail in the layout's unit system title[opt] = title of the new detail projection[opt] = type of initial view projection for the detail 1 = parallel top view 2 = parallel bottom view 3 = parallel left view 4 = parallel right view 5 = parallel front view 6 = parallel back view 7 = perspective view Returns: identifier of the newly created detial on success None on error """ layout_id = rhutil.coerceguid(layout_id, True) corner1 = rhutil.coerce2dpoint(corner1, True) corner2 = rhutil.coerce2dpoint(corner2, True) if projection < 1 or projection > 7: raise ValueError("projection must be a value between 1-7") layout = scriptcontext.doc.Views.Find(layout_id) if not layout: raise ValueError("no layout found for given layout_id") projection = System.Enum.ToObject(Rhino.Display.DefinedViewportProjection, projection) detail = layout.AddDetailView(title, corner1, corner2, projection) if not detail: return scriptcontext.errorhandler() scriptcontext.doc.Views.Redraw() return detail.Id
def XformScreenToWorld(point, view=None, screen_coordinates=False): """Transforms a point from either client-area coordinates of the specified view or screen coordinates to world coordinates. The resulting coordinates are represented as a 3-D point Parameters: point = 2D point view[opt] = title or identifier of a view. If omitted, the active view is used screen_coordinates[opt] = if False, point is in client-area coordinates. If True, point is in screen-area coordinates Returns: 3D point on success None on error Example: import rhinoscriptsyntax as rs point2d = 200,100 view = rs.CurrentView() point = rs.XformScreenToWorld(point2d, view) print point See Also: XformWorldToScreen """ point = rhutil.coerce2dpoint(point, True) view = rhview.__viewhelper(view) viewport = view.MainViewport xform = viewport.GetTransform(Rhino.DocObjects.CoordinateSystem.Screen, Rhino.DocObjects.CoordinateSystem.World) point3d = Rhino.Geometry.Point3d(point.X, point.Y, 0) if screen_coordinates: screen = view.ScreenRectangle point3d.X = point.X - screen.Left point3d.Y = point.Y - screen.Top point3d = xform * point3d return point3d
def XformScreenToWorld(point, view=None, screen_coordinates=False): """Transforms a point from either client-area coordinates of the specified view or screen coordinates to world coordinates. The resulting coordinates are represented as a 3-D point Parameters: point (point): 2D point view (str, optional): title or identifier of a view. If omitted, the active view is used screen_coordinates (bool, optional): if False, point is in client-area coordinates. If True, point is in screen-area coordinates Returns: point: on success None: on error Example: import rhinoscriptsyntax as rs point2d = 200,100 view = rs.CurrentView() point = rs.XformScreenToWorld(point2d, view) print point See Also: XformWorldToScreen """ point = rhutil.coerce2dpoint(point, True) view = rhview.__viewhelper(view) viewport = view.MainViewport xform = viewport.GetTransform(Rhino.DocObjects.CoordinateSystem.Screen, Rhino.DocObjects.CoordinateSystem.World) point3d = Rhino.Geometry.Point3d(point.X, point.Y, 0) if screen_coordinates: screen = view.ScreenRectangle point3d.X = point.X - screen.Left point3d.Y = point.Y - screen.Top point3d = xform * point3d return point3d
def XformScreenToWorld(point, view=None, screen_coordinates=False): """Transforms a point from either client-area coordinates of the specified view or screen coordinates to world coordinates. The resulting coordinates are represented as a 3-D point Parameters: point = 2D point view[opt] = title or identifier of a view. If omitted, the active view is used screen_coordinates[opt] = if False, point is in client-area coordinates. If True, point is in screen-area coordinates Returns: 3D point on success None on error """ point = rhutil.coerce2dpoint(point, True) view = rhview.__viewhelper(view) viewport = view.MainViewport xform = viewport.GetTransform(Rhino.DocObjects.CoordinateSystem.Screen, Rhino.DocObjects.CoordinateSystem.World) point3d = Rhino.Geometry.Point3d(point.X, point.Y, 0) if screen_coordinates: screen = view.ScreenRectangle point3d.X = point.X - screen.Left point3d.Y = point.Y - screen.Top point3d = xform * point3d return point3d