Skip to content

Instantly share code, notes, and snippets.

@stephensmitchell
Last active February 14, 2026 13:57
Show Gist options
  • Select an option

  • Save stephensmitchell/6ccdb364381405a95d3993b02a0ac404 to your computer and use it in GitHub Desktop.

Select an option

Save stephensmitchell/6ccdb364381405a95d3993b02a0ac404 to your computer and use it in GitHub Desktop.
# created with Alibre Script Genie by Stephen S. Mitchell, https://github.com/stephensmitchell
import sys
SCRIPT_NAME = "Fix Parameter Type Check (asgenie)"
def printTraceBack():
import traceback
print('\n--------------\n' + str(traceback.format_exc()) + '--------------\n')
def show_error(msg, title=SCRIPT_NAME):
try:
Windows().ErrorDialog(str(msg), str(title))
except:
print("ERROR: " + str(msg))
def show_info(msg, title=SCRIPT_NAME):
try:
Windows().InfoDialog(str(msg), str(title))
except:
print(str(msg))
def safe_try(fn, where=""):
try:
return fn()
except:
show_error("Exception in {0}".format(where if where else "script"))
printTraceBack()
return None
def _get_parameter_types_enum():
# Most AlibreScript installs already expose ParameterTypes in globals
try:
return ParameterTypes
except:
pass
# Fallback import
try:
import AlibreScript
return AlibreScript.API.ParameterTypes
except:
return None
def main():
mP = CurrentPart()
if mP is None:
show_error("No active Part. Open a part and run again.")
return
PT = _get_parameter_types_enum()
if PT is None:
show_error("Could not resolve ParameterTypes enum in this environment.")
return
mScale = 1.5
# print number of parameters
print "Number of Parameters =",
print len(mP.Parameters)
print mScale
print
# print name and type of each Parameter
thisVal = 0.0
thisVal2 = 0.0
for i, parameter in enumerate(mP.Parameters):
p = mP.Parameters[i]
print("{} \t\t {}\t\t{}".format(p.Name, p.Type, p.Value))
# FIX: compare enum-to-enum, not enum-to-string
if p.Type == PT.Distance:
print "distance"
# Uncomment if you want to try scaling (note: equation-driven params may not be writable via Value)
# thisVal = p.Value
# thisVal2 = thisVal * mScale
# p.Value = thisVal2
# print(thisVal)
# print(thisVal2)
else:
print "NOT distance"
safe_try(main, "main")
mP=CurrentPart()
mScale = 1.5
# print number of parameters
print "Number of Parameters =",
print len(mP.Parameters)
print mScale
print
# print name and type of each Parameter
thisVal = 0.0
thisVal2= 0.0
for i, parameter in enumerate(mP.Parameters):
print("{} \t\t {}\t\t{}".format(mP.Parameters[i].Name,mP.Parameters[i].Type,mP.Parameters[i].Value))
if str(mP.Parameters[i].Type) == "Distance":
print "distance"
#thisVal = mP.Parameters[i].Value
#thisVal2 = thisVal * mScale
#mP.Parameters[i].Value = thisVal2
#print(thisVal)
#print(thisVal2)
else:
print "NOT distance"
>>>
Number of Parameters = 97
1.5
calc_angle_result Angle 29.5
NOT distance
D31 Distance 5.08
distance
D30 Distance 0.0
distance
S1 Scale 0.0
NOT distance
A18 Angle 30.0
NOT distance
A19 Angle 30.0
NOT distance
D32 Distance -1.27
distance
D35 Distance 2.54
distance
D50 Distance 281.94
distance
D34 Distance 2.54
distance
D53 Distance 281.94
distance
D37 Distance 281.94
distance
D52 Distance 281.94
distance
D36 Distance -1.27
distance
D55 Distance 281.94
distance
D39 Distance 281.94
distance
D54 Distance 281.94
distance
D57 Distance 1.36034057617
distance
D38 Distance 281.94
distance
D56 Distance 0.0
distance
D59 Distance 1.00470397949
distance
D58 Distance 1.475436306
distance
D3 Distance 76.2
distance
A3 Angle 90.0
NOT distance
D5 Distance 508.0
distance
C3 Count 12.0
NOT distance
A5 Angle 29.5
NOT distance
C5 Count 12.0
NOT distance
column_count Count 12.0
NOT distance
S10 Scale 0.0
NOT distance
S3 Scale 0.0
NOT distance
S5 Scale 0.0
NOT distance
index_a Angle 0.3
NOT distance
index_b Angle 0.4
NOT distance
index_c Angle 0.4
NOT distance
index_d Angle 0.5
NOT distance
index_e Angle 0.6
NOT distance
centerline_elevation Distance 508.0
distance
D7 Distance 34.29
distance
index_0 Angle 3.5
NOT distance
C7 Count 12.0
NOT distance
calc_angle Angle 29.5
NOT distance
plate_angle_trim Angle 0.5
NOT distance
D21 Distance 12.7
distance
D20 Distance 12.7
distance
D23 Distance -111.76
distance
D22 Distance 50.8
distance
D41 Distance 281.94
distance
S7 Scale 0.0
NOT distance
D40 Distance 281.94
distance
D24 Distance 127.0
distance
D43 Distance 281.94
distance
D27 Distance 0.0
distance
D42 Distance 281.94
distance
D26 Distance 24.5427026367
distance
D45 Distance 281.94
distance
D29 Distance 1.27
distance
D44 Distance 281.94
distance
D28 Distance 5.08
distance
D47 Distance 281.94
distance
D46 Distance 281.94
distance
D49 Distance 281.94
distance
D48 Distance 281.94
distance
D8 Distance 0.0
distance
D2 Distance 76.2
distance
A4 Angle 60.0
NOT distance
A20 Angle 180.0
NOT distance
A21 Angle 180.0
NOT distance
S8 Scale 0.0
NOT distance
S2 Scale 0.0
NOT distance
D61 Distance 551.18
distance
D60 Distance 2.11273155212
distance
D63 Distance 551.18
distance
S4 Scale 0.0
NOT distance
D62 Distance 551.18
distance
D64 Distance 551.18
distance
base_dia Distance 508.0
distance
D9 Distance 508.0
distance
D6 Distance 2.54
distance
A6 Angle 33.0
NOT distance
C6 Count 12.0
NOT distance
S9 Scale 0.0
NOT distance
S6 Scale 0.0
NOT distance
Base_Diameter Distance 508.0
distance
D11 Distance 15.0
distance
D10 Distance 508.0
distance
D13 Distance 27.6461973112
distance
D12 Distance 0.0
distance
D15 Distance 0.0
distance
D14 Distance 5.08
distance
D16 Distance 1.0
distance
D19 Distance 8.89
distance
D1 Distance 508.0
distance
A1 Angle 0.0
NOT distance
base_column_angle_3 Angle 30.0
NOT distance
C1 Count 2.0
NOT distance
A14 Angle 30.0
NOT distance
>>>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment