Using Python to draw objects in "Front" or "Right" View

Hi All,

Forgive the newbie question - for now all my work in Python has been done constructing from “Top” view as default with rhinoscriptsyntax.

How do I go about making arc and rectangles in say the “Right” or “Front” view?

I have tried a combination of rs.ViewCPlane(), rs.CurrentView(), rs.RotatePlane() methods.

However, whenever I make rs.AddRectangle((0,0,0),X,Y) it always resorts to building a rectangle in “Top” View

Any help/explanations very much appreciated

The top, right, front, and perspective views are not different canvases to draw on, but rather cameras or ways to look at a simulated, three-dimensional space created by Rhino.

When you create your rectangle, you’re setting a base point (0,0,0), which defaults to the XY-plane of the scene, what you refer to as “Top” view.
However, the documentation states that rs.AddRectangle(plane, width, height) normally expects a plane that the rectangle will lie in.
Planes are three-dimensional analogues, to a two-dimensional line, and a point in one dimension. A plane is an oriented, two-dimensional subspace within a three- or higher-dimensional space, much like a planar wall in a room, just infinite. It has an origin, a x- and y-axis, and a normal or z-axis, all defining its orientation and position in 3D space.

To create a rectangle that is displayed as one in the front view, you first need to create a plane parallel to the same view. And then you can create your rectangle in the same plane.

For instance like this:

import rhinoscriptsyntax as rs

plane = rs.WorldXYPlane()  # plane parallel to the Top view
plane = rs.RotatePlane(plane, 90.0, [1,0,0])  # rotate 90° around the planes x-axis to make it parallel to the Front view
rs.AddRectangle( plane, 5.0, 15.0 ) 

Another possibility is to create geometry in one plane and orient or transform it to another plane.

2 Likes