albie0803
Alibre Super User
I'm trying (and failing) to merge a script with 4 windows into 1
Existing script snippet:
This is as far as I have got:
Can someone please fix up the code so that fields 1 and 2 properly populate?
I will then use this as a template to do the same with 4 other scripts which were originally built the same way.
Many, many thanks in advance.
Allan
Existing script snippet:
Python:
import glob
import os
import re
HData = {}
# HData[Size][Width]=[thick,root,toe],[thick,root,toe]
HData[65]={}
HData[65][50]=[4.6,6,3],[6,6,3],[7.8,6,3]
HData[75]={}
HData[75][50]=[4.6,7,3],[6,7,3],[7.8,7,3]
HData[100]={}
HData[100][75]=[6,8,5],[7.8,8,5],[9.5,8,5]
HData[125]={}
HData[125][75]=[6,8,5],[7.8,8,5],[9.5,8,5],[12,8,5]
HData[150]={}
HData[150][90]=[7.8,10,5],[9.5,10,5],[12,10,5],[15.8,10,5]
HData[150][100]=[9.5,10,5],[12,10,5],[20,10,5]
# width
Width = 75.0
# base thickness
Thick = 6
# root radius
Rr = 10
# toe radius
Rt = 10
# length
Length = 25
readTh = 0
# called when an input changes in the dialog window
def InputChangedL(Index, Value):
# size changed
if Index == 0:
global Height
Height = float(LNames[Value])
def InputChangedW(Index, Value):
# size changed
if Index == 0:
global Width
Width = float(WNames[Value])
def InputChangedT(Index, Value):
# size changed
if Index == 0:
global Thick
Thick = float(TNames[Value])
# called when user confirms selections
def SelectionMadeL(Values):
# get values
global Height
Height = float(LNames[Values[0]])
def SelectionMadeW(Values):
# get values
global Width
Width = float(WNames[Values[0]])
def SelectionMadeT(Values):
# get values
global Thick
Thick = float(TNames[Values[0]])
Win = Windows()
DialogWidth = 100
LNames = list()
for i,j in enumerate(HData):
LNames.append(str(j))
Options = []
Options.append(['UA Height', WindowsInputTypes.StringList, LNames, Length])
Win.UtilityDialog('Length', 'Apply', SelectionMadeL, InputChangedL, Options, DialogWidth)
WData = HData[Height]
WNames = list()
for i,j in enumerate(WData):
WNames.append(str(j))
Options = []
Options.append(['UA Width', WindowsInputTypes.StringList, WNames, Width])
Win.UtilityDialog('Width', 'Apply', SelectionMadeW, InputChangedW, Options, DialogWidth)
TNames = list()
for i,j in enumerate(WData[Width]):
TNames.append(str(j[0]))
Options = []
Options.append(['UA Thickness', WindowsInputTypes.StringList, TNames, Thick])
Win.UtilityDialog('Thickness', 'Apply', SelectionMadeT, InputChangedT, Options, DialogWidth)
sum = 0
for i in TNames:
if i == Thick:
print i
print sum
readTh = sum
sum += 1
Rr = WData[Width][readTh][1]
Rt = WData[Width][readTh][2]
##Input a value window
Lth = 200
Options = []
Options.append(["UA Length", WindowsInputTypes.Real, Lth])
Values = Win.OptionsDialog("Thickness", Options)
#print('Please input length in mm')
Length = int(Values[0])
This is as far as I have got:
Python:
import glob
import os
import re
Win = Windows()
HData = {}
# HData[Size][Width]=[thick,root,toe],[thick,root,toe]
HData[65]={}
HData[65][50]=[4.6,6,3],[6,6,3],[7.8,6,3]
HData[75]={}
HData[75][50]=[4.6,7,3],[6,7,3],[7.8,7,3]
HData[100]={}
HData[100][75]=[6,8,5],[7.8,8,5],[9.5,8,5]
HData[125]={}
HData[125][75]=[6,8,5],[7.8,8,5],[9.5,8,5],[12,8,5]
HData[150]={}
HData[150][90]=[7.8,10,5],[9.5,10,5],[12,10,5],[15.8,10,5]
HData[150][100]=[9.5,10,5],[12,10,5],[20,10,5]
# Height
Height = 65
# width
Width = 50
# base thickness
Thick = 4.6
# length
Length = 0
# root radius
Rr = 10
# toe radius
Rt = 10
readTh = 0
# called when an input changes in the dialog window
def onchange(Index, Value):
global Height
global Width
global Thick
# size changed
if Index == 0:
Height = float(HNames[Value])
WData = HData[Height]
for i,j in enumerate(WData):
WNames.append(str(j))
Win.SetStringList(1,WNames)
elif Index == 1:
Width = float(WNames[Value])
for i,j in enumerate(WData[Width]):
TNames.append(str(j[0]))
Win.SetStringList(2,TNames)
elif Index == 2:
for i,j in enumerate(WData[Width]):
TNames.append(str(j[0]))
Thick = float(TNames[Value])
Rr = WData[Width][Thick][1]
Rt = WData[Width][Thick][2]
def updateui():
# to define a UI start
pass
HNames = list()
for i,j in enumerate(HData):
HNames.append(str(j))
WNames = list()
TNames = list()
Options = []
Options.append(['UA Height', WindowsInputTypes.StringList, HNames, Height])
Options.append(['UA Width', WindowsInputTypes.StringList, WNames, Width])
Options.append(['UA Thickness', WindowsInputTypes.StringList, TNames, Thick])
Options.append(["UA Length", WindowsInputTypes.Real, Length])
Values = Win.OptionsDialog('Create Unequal Angle', Options, 50, onchange, updateui)
Can someone please fix up the code so that fields 1 and 2 properly populate?
I will then use this as a template to do the same with 4 other scripts which were originally built the same way.
Many, many thanks in advance.
Allan