this was my initial attempt but there were many issue.
import rhinoscriptsyntax as rs
import scriptcontext as sc
import Rhino
def move_objects(geometry, move_vec):
“”“Moves a list of Rhino objects by a given vector.”“”
moved_geometry =
for obj in geometry:
moved_obj = rs.CopyObject(obj, move_vec)
if moved_obj:
moved_geometry.append(moved_obj)
return moved_geometry
def create_block(geometry, base_pt, block_name=“Ladybug_Chart_Block”):
“”“Creates and bakes a block from the given geometry at the base point.”“”
if not base_pt or not geometry:
print("Error: Missing base point or geometry.")
return None
# Ensure layer exists
if not rs.IsLayer(block_name):
rs.AddLayer(block_name)
# If the block already exists, delete and replace
if rs.IsBlock(block_name):
rs.DeleteBlock(block_name)
# Create the new block
block_def = rs.AddBlock(geometry, base_pt, block_name, True)
# Insert the block instance at the final location
return rs.InsertBlock(block_name, base_pt)
Grasshopper Inputs:
base_pt = base_pt # Original base point
final_pt = final_point # New location where the block should be placed
Ladybug Monthly Chart outputs:
data_meshes = data_mesh # List of meshes
data_lines = data_lines # List of polylines/curves
col_lines = col_lines if “col_lines” in globals() else # Colored polylines (if exist)
legend = legend # Legend geometry
borders = borders # Axes and grid lines
labels = labels # Month and Y-axis labels
y_title = y_title # Y-axis title
title = title # Global chart title
Combine all elements into a single list
all_geometry = data_meshes + data_lines + col_lines + legend + borders + labels + [y_title, title]
Compute move vector
move_vector = rs.VectorCreate(final_pt, base_pt)
Move objects to new location
moved_geometry = move_objects(all_geometry, move_vector)
Create and bake block
bake_block = create_block(moved_geometry, final_pt, “Ladybug_Chart_Block”)