Skip to content

Instantly share code, notes, and snippets.

@berkdemir
Last active May 2, 2021 09:40
Show Gist options
  • Save berkdemir/6b62233ab88631c0ac5e8bf864fe224e to your computer and use it in GitHub Desktop.
Save berkdemir/6b62233ab88631c0ac5e8bf864fe224e to your computer and use it in GitHub Desktop.
Plaxis plate list fetcher.
def plate_forces(plate_list, plate_names, phase_list):
"""
Plaxis plate forces fetcher by Berk Demir / https://github.com/berkdemir
Returns (M, N) as a tuple from Plaxis.
"""
select_plate_obj = []
for _, j in enumerate(plate_names):
# In my original code, I offer user the list of plate_names and user select the plates. Returned selected_plate_names is used to enumerate here. This is why code is structured the way it is.
select_plate_obj.append(
plate_list[plate_names.index(j)]
) # Selected plate names mapped in the plate list to create a list of Plaxis objects.
Results_M = []
Results_N = []
for _, j in enumerate(select_plate_obj):
for _, l in enumerate(phase_list):
try:
m = g_o.getresults(j, l, g_o.ResultTypes.Plate.M2D, "node")
Results_M.append([x for x in m])
n = g_o.getresults(j, l, g_o.ResultTypes.Plate.Nx2D, "node")
Results_N.append([-x for x in n])
except:
pass
return Results_M, Results_N
def plate_list_func():
"""
Plaxis plate list fetcher by Berk Demir / https://github.com/berkdemir
Returns (plate_list, plate_names) as a tuple from Plaxis. No error handling is present assuming user will not run the function without plates present in the model.
"""
plate_list = []
plate_names = []
for i in g_o.Plates:
plate_list.append(i)
plate_names.append(i.Name.value)
return plate_list, plate_names
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment