oldfox
Alibre Super User
This script runs just fine with the exception that it falls through to the last line in the so-called DataBase.
This can be proven by commenting out lines starting at the last line in the DB.
What am I doing wrong or missing????
# This is a troubleshooter script only.
Units.Current = UnitTypes.Millimeters
DefaultName = 'None'
def InputChanged(Index, Value):
if Index == 0:
global Name
Name = MetricNames[Value]
print Name
def SelectionMade(Values):
global Name
Name = MetricNames[Values[0]]
print Name
Win = Windows()
MetricNames = ['None', 'M2', 'M2.5', 'M3', 'M4']
Options = []
Options.append(['Size', WindowsInputTypes.StringList, MetricNames, DefaultName])
DialogWidth = 400
Win.UtilityDialog('Metric Sizes', 'Apply', SelectionMade, InputChanged, Options, DialogWidth)
print 'You chose %s' % Name
if Name == 'M2':
Choice = 1
print '\nChoice is %i\n' % Choice
elif Name == 'M2.5':
Choice = 2
print '\nChoice is %i\n' % Choice
elif Name == 'M3':
Choice = 3
print '\nChoice is %i\n' % Choice
elif Name == 'M4':
Choice = 4
print '\nChoice is %i\n' % Choice
Length = 5.0
MetricSizeData = {} # 0 1 2 3 4 5 6 7 8 9
MetricSizeData[Choice] = ['M2', 2.0, 5.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, Length]
MetricSizeData[Choice] = ['M2.5', 2.5, 6.5, 2.5, 0.0, 0.0, 0.0, 0.0, 0.0, Length]
MetricSizeData[Choice] = ['M3', 3.0, 6.5, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, Length]
MetricSizeData[Choice] = ['M4', 4.0, 6.5, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, Length]
Name = MetricSizeData[Choice][0]
BodyDiameter = MetricSizeData[Choice][1]
HeadDiameter = MetricSizeData[Choice][2]
HeadHeight = MetricSizeData[Choice][3]
HexSocketSize = MetricSizeData[Choice][4]
HexHoleDepth = MetricSizeData[Choice][5]
TransitionDiameter = MetricSizeData[Choice][6]
RimChamfer = MetricSizeData[Choice][7]
EndChamfer = MetricSizeData[Choice][8]
Length = MetricSizeData[Choice][9]
print 'Name is %s' % Name
print 'Body Diameter is %.2f' % BodyDiameter
print 'Head Diameter is %.2f' % HeadDiameter
print 'Head Height is %.2f' % HeadHeight
TIA
This can be proven by commenting out lines starting at the last line in the DB.
What am I doing wrong or missing????
# This is a troubleshooter script only.
Units.Current = UnitTypes.Millimeters
DefaultName = 'None'
def InputChanged(Index, Value):
if Index == 0:
global Name
Name = MetricNames[Value]
print Name
def SelectionMade(Values):
global Name
Name = MetricNames[Values[0]]
print Name
Win = Windows()
MetricNames = ['None', 'M2', 'M2.5', 'M3', 'M4']
Options = []
Options.append(['Size', WindowsInputTypes.StringList, MetricNames, DefaultName])
DialogWidth = 400
Win.UtilityDialog('Metric Sizes', 'Apply', SelectionMade, InputChanged, Options, DialogWidth)
print 'You chose %s' % Name
if Name == 'M2':
Choice = 1
print '\nChoice is %i\n' % Choice
elif Name == 'M2.5':
Choice = 2
print '\nChoice is %i\n' % Choice
elif Name == 'M3':
Choice = 3
print '\nChoice is %i\n' % Choice
elif Name == 'M4':
Choice = 4
print '\nChoice is %i\n' % Choice
Length = 5.0
MetricSizeData = {} # 0 1 2 3 4 5 6 7 8 9
MetricSizeData[Choice] = ['M2', 2.0, 5.0, 2.0, 0.0, 0.0, 0.0, 0.0, 0.0, Length]
MetricSizeData[Choice] = ['M2.5', 2.5, 6.5, 2.5, 0.0, 0.0, 0.0, 0.0, 0.0, Length]
MetricSizeData[Choice] = ['M3', 3.0, 6.5, 3.0, 0.0, 0.0, 0.0, 0.0, 0.0, Length]
MetricSizeData[Choice] = ['M4', 4.0, 6.5, 4.0, 0.0, 0.0, 0.0, 0.0, 0.0, Length]
Name = MetricSizeData[Choice][0]
BodyDiameter = MetricSizeData[Choice][1]
HeadDiameter = MetricSizeData[Choice][2]
HeadHeight = MetricSizeData[Choice][3]
HexSocketSize = MetricSizeData[Choice][4]
HexHoleDepth = MetricSizeData[Choice][5]
TransitionDiameter = MetricSizeData[Choice][6]
RimChamfer = MetricSizeData[Choice][7]
EndChamfer = MetricSizeData[Choice][8]
Length = MetricSizeData[Choice][9]
print 'Name is %s' % Name
print 'Body Diameter is %.2f' % BodyDiameter
print 'Head Diameter is %.2f' % HeadDiameter
print 'Head Height is %.2f' % HeadHeight
TIA