round_to_window_slot_duct_t.../python/assign_alias.py

21 lines
599 B
Python
Raw Permalink Normal View History

2026-04-12 15:52:08 -07:00
import FreeCAD as App
# Change 'Spreadsheet' to the actual name of your sheet if different
sheet = App.ActiveDocument.getObject('Spreadsheet')
# Set the range of rows you want to process (e.g., row 1 to 20)
start_row = 1
end_row = 20
for i in range(start_row, end_row + 1):
val_cell = f"A{i}"
name_cell = f"B{i}"
alias_name = sheet.get(name_cell)
if alias_name:
# FreeCAD aliases cannot have spaces or special characters
clean_alias = "".join(filter(str.isalnum, alias_name))
sheet.setAlias(val_cell, clean_alias)
App.ActiveDocument.recompute()