Helper scripts

This commit is contained in:
jlpoole 2026-04-12 15:52:08 -07:00
commit 8fe4145060
2 changed files with 41 additions and 0 deletions

21
python/assign_alias.py Normal file
View file

@ -0,0 +1,21 @@
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()

View file

@ -0,0 +1,20 @@
#
# 3/23/26 ChatGPT
# shows details of constraints
#
sk = App.ActiveDocument.ActiveObject
App.Console.PrintMessage("Constraint Listing:\n")
print(f'Constraint Listing: ')
for i, c in enumerate(sk.Constraints):
App.Console.PrintMessage(f"\nConstraint {i}: {c.Type}")
if hasattr(c, "Value") and c.Value != 0:
App.Console.PrintMessage(f" = {c.Value}")
App.Console.PrintMessage(
f"\n First : Geo {c.First}, Pos {c.FirstPos}"
f"\n Second: Geo {c.Second}, Pos {c.SecondPos}"
f"\n Third : Geo {c.Third}, Pos {c.ThirdPos}\n"
)