Automating Layout Creation Using RhinoScriptSyntax

Hi all,

I am trying to automate a relatively tedious task. Basically, I am envisioning a script where one inputs any solid model, and it returns a new layout with (3) details:

            -An isometric view of the input object
            -A top section of the object
            -A side section of the object

Where I am stuck: see script attached and some images of my current output vs. what my desired output would look like. In the RhinoScriptSyntax framework I am not yet sure how “activate” a specific clipping plane so it only references a specific detail.

I do some variation of this dozens of times a day so any suggestions about how I may better approach automating a task like this would be greatly appreciated.

Thank you,

Parry

Input (any solid model):

current output:

desired output:

autoLayout-07-01.py (1.2 KB)

import rhinoscriptsyntax as rs
import Rhino.Geometry as rg

def auto_layout(objects):
    # Construct bounding box
    bounding_box = rs.BoundingBox(objects)
    box = rs.AddBox(bounding_box)
    center_of_box = rs.SurfaceAreaCentroid(box)[0]
    box_centroid = rs.AddPoint(center_of_box)
    
    # Delete temporary box
    rs.DeleteObject(box)
    
    # Construct clipping planes
    equator_plane = add_clipping_plane(box_centroid, 180)
    prime_meridian_plane = add_clipping_plane(box_centroid, 90)
    
    # Capture views and add to layout
    layout = rs.AddLayout("Layout", (17, 11))
    if layout:
        perspective_view = rs.AddDetail(layout, (0.5, 0.5), (8, 10.5), None, 7)
        top_view = rs.AddDetail(layout, (5, 5), (12, 12), None, 1)
        rs.DetailScale(top_view, 18, 1)
        side_view = rs.AddDetail(layout, (16.7, 11.51), (10.7, -0.5), None, 4)
        rs.DetailScale(side_view, 18, 1)

def add_clipping_plane(center, angle):
    plane = rs.RotatePlane(rs.MovePlane(rs.WorldXYPlane(), center), angle, (0, -1, 0))
    return rs.AddClippingPlane(plane, 5.0, 5.0)

if __name__ == "__main__":
    input_objects = rs.GetObjects()
    if input_objects:
        auto_layout(input_objects)

_

Hi,
Streamline Manufacturing: Dynamic Exploded Views and Data Extraction AI Powered (youtube.com)
If you need any serious level of automation with detailed views you can reach out to me at farouk.serragedine@gmail.com
We also integrate labelling and symbology agents for the drawings in case your drawings are complex, the symbology can be automated aswell

Farouk