Last active
May 2, 2021 10:04
-
-
Save berkdemir/6519ee150bdbb3ee2aa1259b7254f116 to your computer and use it in GitHub Desktop.
Plaxis group list fetcher.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def group_forces(plate_list, plate_names, phase_list): | |
""" | |
Plaxis group forces fetcher by Berk Demir / https://github.com/berkdemir | |
Returns (M, N) as a tuple from Plaxis. If no group is defined in the model, it will return None. | |
""" | |
select_group_obj = [] | |
for i, j in enumerate(group_names): | |
# In my original code, I offer user the list of group_names and user select the groups. Returned selected_group_names is used to enumerate here. This is why code is structured the way it is. | |
select_group_obj.append( | |
group_list[group_names.index(j)] | |
) # Selected group names mapped in the group list to create a list of Plaxis objects. | |
Results_M = [] | |
Results_N = [] | |
for i, j in enumerate(select_group_obj): | |
for k, 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def group_list_func(): | |
""" | |
Plaxis group list fetcher by Berk Demir / https://github.com/berkdemir | |
Returns (group_list, group_names) as a tuple from Plaxis. If no group is defined in the model, it will print an error and will not return a value. | |
""" | |
group_list = [] | |
group_names = [] | |
try: | |
for i in g_o.Groups: | |
group_list.append(i) | |
group_names.append(i.Name.value) | |
return group_list, group_names | |
except: | |
print("Error. No group is defined.") |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment