Hey Guys.
Im trying to create a simple script, that creates a clipping plane, based on a selected geometry. My script is nowhere near to be working.
Someone with some python skills here?
import rhinoscriptsyntax as rs
def create_clipping_plane():
# Select a surface
surface_id = rs.GetObject("Select a surface to create a clipping plane", rs.filter.surface)
if surface_id:
# Get the surface's bounding box
bbox = rs.SurfaceBoundingBox(surface_id)
if bbox:
# Extract the dimensions of the bounding box
xmin, ymin, zmin, xmax, ymax, zmax = bbox
# Calculate the size of the bounding box in the X, Y, and Z directions
width = xmax - xmin
height = ymax - ymin
depth = zmax - zmin
# Calculate the center point of the bounding box
center = rs.SurfaceAreaCentroid(surface_id)[0]
# Create a plane aligned with the surface's axes and passing through the center
plane = rs.PlaneFromNormal(center, (0, 0, 1), (1, 0, 0))
# Create a rectangle representing the size of the surface
rectangle = rs.AddRectangle(plane, width, height)
# Create a clipping plane based on the rectangle
clipping_plane = rs.AddClippingPlane(rectangle)
if clipping_plane:
# Enable the clipping plane for the surface
rs.EnableClippingPlane(surface_id, clipping_plane)
rs.DeleteObject(rectangle)
rs.Redraw()
# Run the function
create_clipping_plane()
Ideally id like to select a whole box and in that way create 6 clippingplanes identical to the surface dimensions. In that way creating a “SectionBox” ala Revit