What's new

Script won't run

gld

Member
This gear script will not since I've updated the the latest Alibre update. It has worked good previously.


Code:
# Gear Generator Script
# Used as a demonstration of how to create a custom utility
# for use with Alibre Design

Units.Current = UnitTypes.inch

# default settings
NumberofTeeth = 20
PitchDiameter = 0.417
PressureAngle = 14.5
Thickness = 0.125

Win = Windows()

ScriptName = 'Gear Generator'

# create dialog window and show to user
Options = []
Options.append([None, WindowsInputTypes.Image, 'GearGenerator.png', 170])
Options.append(['Number of Teeth', WindowsInputTypes.Integer, NumberofTeeth])
Options.append(['Pitch Diameter (inch)', WindowsInputTypes.Real, PitchDiameter])
Options.append(['Pressure Angle', WindowsInputTypes.Real, PressureAngle])
Options.append(['Thickness (inch)', WindowsInputTypes.Real, Thickness])
Values = Win.OptionsDialog(ScriptName, Options, 170)
if Values == None:
  sys.exit()

print "Working..."

# get user inputs
NumberofTeeth = Values[1]
PitchDiameter = Values[2]
PressureAngle = Values[3]
Thickness = Values[4]

# get current part
MyPart = CurrentPart()

# get the plane to create the gear on
GearPlane = MyPart.XYPlane

# create the sketch then extrude it
ProfileSketch = MyPart.AddGearNP("Profile", NumberofTeeth, PitchDiameter, PressureAngle, 0, 0, False, GearPlane)
Gear = MyPart.AddExtrudeBoss("Gear", ProfileSketch, Thickness, True)

print "Done"
 
Hello @gld ,

the definition of your UnitsCurrent = UnitTypes.Inch

is wrong. See ScriptReference:
1744443110245.png

Regards
Stefan
 
Well I finally got the scripts to run after fixing two problems.

This little script file:

[CODE]Alibre Script build 347013
IronPython 2.7.10.0 Interactive Console
For documentation visit http://docs.python.org/2.7
The complete standard library is available

Console commands available:
history : Prints history of entered commands
cls : Clears the screen
help : Shows the list of console commands
run : Executes the current script
run arg1 arg2 : Executes the current script, pass arguments
run "scriptname" : Executes a specific script
run "scriptname" arg1 arg2 : Executes a specific script, pass arguments

>>>
>>>[/CODE]


that are always popped up in the script window has to be there for scripts to run . I had deleted it from my lap top. (duh)

Number 2
changing changing inch, to inches did not fix the problem. But this did, inches to Inches.

All is good.Thank you for the help.
 
If an old script stops working in a new version, 1st step is reviewing current version examples:


The error is a hint:

>>>
Traceback (most recent call last):
File "<string>", line 11, in <module>
AttributeError: 'type' object has no attribute 'inches'
>>>help(UnitTypes)

Help on UnitTypes in module __builtin__
| | | enum UnitTypes, values: Centimeters (201), Inches (203), Millimeters (200) | | |
| Data and other attributes defined here: | | MemberwiseClone(...)
| MemberwiseClone(self: object) -> object | | Creates a shallow copy of the current System.Object. | Returns: A shallow copy of the current System.Object. |
| __eq__(...)
| x.__eq__(y) <==> x==yx.__eq__(y) <==> x==yx.__eq__(y) <==> x==y
| __format__(...)
| __format__(formattable: IFormattable, format: str) -> str |
| __ge__(...)
| __ge__[UnitTypes](x: UnitTypes, y: UnitTypes) -> bool | __ge__[UnitTypes](x: UnitTypes, y: object) -> object | __ge__[UnitTypes](y: object, x: UnitTypes) -> object |
| __gt__(...)
| x.__gt__(y) <==> x>yx.__gt__(y) <==> x>yx.__gt__(y) <==> x>y
| __le__(...)
| __le__[UnitTypes](x: UnitTypes, y: UnitTypes) -> bool | __le__[UnitTypes](x: UnitTypes, y: object) -> object | __le__[UnitTypes](y: object, x: UnitTypes) -> object |
| __lt__(...)
| x.__lt__(y) <==> x<yx.__lt__(y) <==> x<yx.__lt__(y) <==> x<y
| __ne__(...)
| __ne__[UnitTypes](x: UnitTypes, y: UnitTypes) -> bool | __ne__[UnitTypes](x: UnitTypes, y: object) -> object | __ne__[UnitTypes](y: object, x: UnitTypes) -> object |
| __reduce_ex__(...)
| helper for pickle
| __str__(...)
| x.__str__() <==> str(x)
>>>
>>>dir(UnitTypes)
['Centimeters', 'CompareTo', 'Equals', 'Format', 'GetHashCode', 'GetName', 'GetNames', 'GetType', 'GetTypeCode', 'GetUnderlyingType', 'GetValues', 'HasFlag', 'Inches', 'IsDefined', 'MemberwiseClone', 'Millimeters', 'Parse', 'ReferenceEquals', 'ToBoolean', 'ToByte', 'ToChar', 'ToDateTime', 'ToDecimal', 'ToDouble', 'ToInt16', 'ToInt32', 'ToInt64', 'ToObject', 'ToSByte', 'ToSingle', 'ToString', 'ToType', 'ToUInt16', 'ToUInt32', 'ToUInt64', 'TryParse', '__and__', '__class__', '__delattr__', '__doc__', '__eq__', '__format__', '__ge__', '__getattribute__', '__gt__', '__hash__', '__init__', '__invert__', '__le__', '__lt__', '__ne__', '__new__', '__nonzero__', '__or__', '__rand__', '__reduce__', '__reduce_ex__', '__repr__', '__ror__', '__rxor__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__xor__', 'value__']
>>>
>>>UnitTypes.Inches

AlibreScript.API.UnitTypes.Inches
 
Back
Top