This page will show you how to assign a cross section to frame elements based on the layer name. Specifically, it will attempt to assign a cross section whose name matches the last sub-layer name.
This is useful if you have placed frame elements on specific layers based on their assumed cross section. Organizing frames this way is great for book-keeping and filtering. It also allows for easily changing the assigned cross section, as every time the layer is changed, Grasshopper will automatically reassign the cross section.
The procedure is:
- Create layers whose last sub-layer name matches the name of a cross section. All cross sections must be defined in the Model Definitions component for them to be available. The layer name may read something like ‘Beams::Lateral::W21x44’. The “::” delimiter is used by Rhino to separate nested layers.
- Get the geometry from Rhino in your preferred manner, such as with a Geometry Pipeline.
- Create Design Frame Elements from the Rhino geometry using the Create Design Frame Element component. Note that this step is not shown.
- Plug your Rhino geometry into an Object Details component.
- Use a Text Split component to split the “Name” output of the Object Details component using the “::” delimiter. This will create a tree, with each branch containing a list of the nested layers for each object.
- Use a List Length component to get the length of each list from the Text Split output.
- Using a Subtraction component, subtract 1 from the list length. This gets the last 0-based index of each list.
- Using a List Item component, get the last item in each layer list. This should be the last nested sub-layer name.
- Use the Assign Frame Section component to assign the section name to the Design Frame Element. The Design Frame Element input on this component should be the list of Design Frame Elements created in step 3.
This process will automatically assign the frame cross section based on the last sub-layer name. Again, note that you must define every cross section you want to use in the Model Definitions component for this to work properly.
Components Used