Skip to content

Instantly share code, notes, and snippets.

@stephensmitchell
Created February 22, 2026 06:09
Show Gist options
  • Select an option

  • Save stephensmitchell/9461bf68d30e106d63ff88a8aceb1b82 to your computer and use it in GitHub Desktop.

Select an option

Save stephensmitchell/9461bf68d30e106d63ff88a8aceb1b82 to your computer and use it in GitHub Desktop.
Alibre Design parameter debugging
import sys
from AlibreScript.API import *
# Ensure we are using millimeters for script units
Units.Current = UnitTypes.Millimeters
# Create a new part
part = CurrentPart()
# Create parameters (C - Create)
def create_parameters():
print("Creating parameters...")
part.AddParameter("Width", ParameterTypes.Distance, 50.0)
part.AddParameter("Height", ParameterTypes.Distance, ParameterUnits.Centimeters, 5.0)
part.AddParameter("Angle", ParameterTypes.Angle, 30.0)
part.AddParameter("HoleDiameter", ParameterTypes.Distance, 12.0)
part.AddParameter("EquationParam", ParameterTypes.Distance, "Width/2")
print("Parameters created successfully.")
# Read and list all parameters (R - Read)
def list_parameters():
print("Listing all parameters...")
if not part.Parameters:
print("No parameters found.")
else:
for param in part.Parameters:
print("---------------------------------")
print("Name: ", param.Name)
print("Type: ", param.Type)
print("Units: ", param.Units)
print("Value: ", param.Value)
print("Raw Value: ", param.RawValue)
print("Equation: ", param.Equation)
print("Comment: ", param.Comment if param.Comment else "None")
print("---------------------------------")
# Update parameter values and equations (U - Update)
def update_parameters():
print("Updating parameters...")
width_param = part.GetParameter("Width")
if width_param:
width_param.Value = 75.0
print("Updated 'Width' parameter to 75.0 mm")
equation_param = part.GetParameter("EquationParam")
if equation_param:
equation_param.Equation = "Height * 2"
print("Updated 'EquationParam' equation to 'Height * 2'")
print("Parameters updated successfully.")
# Delete a parameter (D - Delete)
def delete_parameter(param_name):
print("Deleting parameter: ", param_name)
param = part.GetParameter(param_name)
if param:
part.RemoveFeature(param.Name)
print("Parameter deleted: ", param_name)
else:
print("Parameter not found: ", param_name)
# Check if a parameter exists
def parameter_exists(param_name):
return part.GetParameter(param_name) is not None
# Main Execution Flow
#create_parameters()
list_parameters()
#update_parameters()
#list_parameters()
#delete_parameter("HoleDiameter")
#list_parameters()
print("Parameter showcase completed.")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment