GHDoc-temp

Documentation for suspension.py

General Description

The suspension.py file contains an algorithm for creating a suspension system from linear elements in Grasshopper/Rhino. The algorithm is designed for automatic generation of suspension structure taking into account geometric constraints and parameters.

Version: v0.06

Main Functions

1. sort_lines_perpendicular(lines, reference_direction)

Sorts lines perpendicular to a given direction.

Parameters:

Returns: sorted list of lines

2. line_same_direction(lines)

Aligns all lines in the same direction and sorts them perpendicularly.

Parameters:

Returns: tuple (sorted lines, reference direction)

3. suspension_corners(lines, dir, round, min_val, is_start)

Generates suspension corner points taking into account rounding and minimum distance.

Parameters:

Returns: list of corner points

4. strict_cluster_points(points, direction, max_distance, is_start=True)

Groups points into clusters based on projection onto a given direction.

Parameters:

Returns: tuple (group indices, representative points)

5. project_points_to_group_scalar(points, group_ids, representative_points, direction)

Projects points to their group representative points along a given direction.

Parameters:

Returns: list of aligned points

6. grouped_polylines_by_index(points, group_indices)

Creates polylines from points based on their group indices.

Parameters:

Returns: tuple (polylines, individual points, one point for each group)

7. connect_point_pairs(start_points, end_points)

Creates lines between pairs of starting and ending points.

Parameters:

Returns: list of lines

8. generate_crossbars_points(lines, max_step, group_points=None)

Generates points for cross elements with uniform step. Supports two operation modes: using group points to determine projection range or classic mode.

Parameters:

Returns: list of point lists for cross elements

9. remove_duplicate_points(points, min_distance=GLOBAL_TOL)

Removes duplicate points that are closer than min_distance.

Parameters:

Returns: list of unique points

10. build_segmented_lines(crossbars_points, max_distance)

Creates segmented lines from cross element points.

Parameters:

Returns: tuple (segmented lines, individual points)

11. polylines_to_lines(poly_curves)

Converts polylines to simple lines.

Parameters:

Returns: list of lines

12. match_support_to_boundary(support_lines, boundary_lines, direction, threshold)

Matches support lines with boundary lines based on projection.

Parameters:

Returns: list of group indices for support lines

13. move_line_to_match_projection(source_line, target_line, direction)

Moves a line to match the projection of the target line.

Parameters:

Returns: moved line

14. filter_and_align_lines(boundary_lines, support_lines, support_indices, direction)

Filters and aligns lines based on their matching. Selects the longest line in each group and aligns support lines with boundary lines.

Parameters:

Returns: tuple (filtered boundary lines, filtered support lines)

15. generate_points_on_lines(lines, step)

Creates points on lines with a given step.

Parameters:

Returns: list of points on lines

16. merge_lines_by_distance(lines, max_distance, length_tolerance=GLOBAL_TOL)

Combines lines that are within a given distance and have the same length.

Algorithm:

  1. Finds center points of all lines
  2. Groups lines by distance between centers and length
  3. For each group, leaves one line positioned at the center of the group

Parameters:

Returns: list of combined lines

Note: The function combines only those lines that are within max_distance of each other and have the same length (with tolerance length_tolerance). This helps reduce the number of duplicate elements in the suspension system.

Global Constants

Input Variables (for Grasshopper)

Note: ROUNDING + MIN_DISTANCE_CORNER = equals the offset from corners

Output Variables

Lines:

Points:

Algorithm Operation

  1. Line Preparation: Aligning all lines in the same direction
  2. Corner Generation: Creating corner points taking into account rounding
  3. Clustering: Grouping corner points by distance
  4. Alignment: Projecting points to group representative points
  5. Polyline Creation: Forming polylines from aligned points
  6. Boundary Line Combination: Combining starting and ending lines that are within DISTANCE_JOINING_START_END_LINES and have the same length
  7. Cross Element Generation: Creating cross elements with uniform step (with group point support)
  8. Segmentation: Breaking cross elements into segments with duplicate removal
  9. Matching: Matching support lines with boundary lines
  10. Filtering: Selecting the longest lines in groups and aligning support lines
  11. Point Generation: Creating points for rods on all lines

New Features v0.06