How can I select existing point load and assign them load values by python on Plaxis3D?

64 views Asked by At

I created a 3D raft model on . The raft must transfer structural loads by point loads which are reperesents base stroy columns. Structural loads obtained from a different CAE (SAP2000). In that case all loads must be assign one by one and requires way. Therefore I need a script which [tag:selects existing point load] and assign them loads read from a txt file which is obtained from another CAE (SAP2000) software.

I made a code by pycharm. Let me share it to you:

import subprocess, time
from plxscripting.easy import *

PLAXIS_PATH = r"C:\Program Files\Seequent\PLAXIS 3D 2023.2\Plaxis3DInput.exe"
FILE_PATH = r'C:\Siyahkalem\Plaxis3D\python deneme\python_deneme.p3d'
PORT_i = 10000
PORT_i = 10001
PASSWORD = 'V??kBcQeiiv!5w?v'

subprocess.Popen([PLAXIS_PATH, f"--AppServerPort={PORT_i}", f"AppServerPassword={PASSWORD}"])
#from plaxis.plaxutil.command import Command
time.sleep(5) #wait till plaxis boot finish
s_i, g_i = new_server('localhost', PORT_i, password=PASSWORD)
s_o, g_o = new_server('localhost', PORT_i, password=PASSWORD)s_i.open(FILE_PATH)


g_i.gotostages()

g_i.pointload(60)

all codes works well except "g_i.pointload(60)". I was expecting this row to select the "PointLoad_60_1" which is exist on my Plaxis3d model I created. But I doesn't work. Could you please help me.

thank you.

3

There are 3 answers

0
Burak Doğaroğlu On

I find another code

g_i.set(PointLoad_26_1.Fx, Phase_5, 999)

instead

g_i.pointload(60)

But I get error

NameError: name 'PointLoad_26_1' is not defined

Even PointLoad_26_1 is exist.

0
Burak Doğaroğlu On

I proceed a little bit further by chatGPT. The final code is;

import subprocess, time
import pandas
from plxscripting.easy import *

PLAXIS_PATH = r"C:\Program Files\Seequent\PLAXIS 3D 2023.2\Plaxis3DInput.exe"
FILE_PATH = r'C:\XXXXX\Plaxis3D\python deneme\python_deneme.p3d'
PORT_i = 10000
PORT_i = 10001
PASSWORD = 'V??kBcQeiiv!5w?v'

subprocess.Popen([PLAXIS_PATH, f"--AppServerPort={PORT_i}", f"AppServerPassword={PASSWORD}"])
#from plaxis.plaxutil.command import Command
time.sleep(5) #wait till plaxis boot finish
s_i, g_i = new_server('localhost', PORT_i, password=PASSWORD)
s_o, g_o = new_server('localhost', PORT_i, password=PASSWORD)

s_i.open(FILE_PATH)

g_i.gotostages()

g_i.phase(g_i.phases[-1]) #adds phase without ID


source_file = pandas.read_csv('C:\xxxxx\python_prj\input_datas\G.txt', sep="\t", header=None)



# Assuming PointLoad_26_1 is the name of the existing point load

for i in range(0, len(source_file)):


    point_load_name = str(f"{source_file[i, 6]}")
    # Find the point load with the specified name
    existing_point_load = None
    for point_load in g_i.PointLoads:
        if point_load.Name == point_load_name:
            existing_point_load = point_load
            break

    # Check if the point load was found
    if existing_point_load:
        # Set the force value for the specified phase directly
        g_i.set(existing_point_load.Fx, g_i.Phase_5, float(source_file[i, 0]))
        g_i.set(existing_point_load.Fy, g_i.Phase_5, float(source_file[i, 1]))
        g_i.set(existing_point_load.Fz, g_i.Phase_5, float(source_file[i, 2]))
        g_i.set(existing_point_load.Mx, g_i.Phase_5, float(source_file[i, 3]))
        g_i.set(existing_point_load.My, g_i.Phase_5, float(source_file[i, 4]))
        g_i.set(existing_point_load.Mz, g_i.Phase_5, float(source_file[i, 5]))
    else:
        print(f"Point load with name '{point_load_name}' not found.")

right now I get this error;

raise KeyError(key) from err
KeyError: (0, 6)
0
Burak Doğaroğlu On

I solved what I want with;

import subprocess, time
import pandas
from plxscripting.easy import *

PLAXIS_PATH = r"C:\Program Files\Seequent\PLAXIS 3D 2023.2\Plaxis3DInput.exe"
FILE_PATH = r"C:\**\PLAXIS3D\***.p3d"
PORT_i = 10000
PORT_i = 10001
PASSWORD = 'V??kBcQeiiv!5w?v'

subprocess.Popen([PLAXIS_PATH, f"--AppServerPort={PORT_i}", f"AppServerPassword={PASSWORD}"])
#from plaxis.plaxutil.command import Command
time.sleep(5) #wait till plaxis boot finish
s_i, g_i = new_server('localhost', PORT_i, password=PASSWORD)
s_o, g_o = new_server('localhost', PORT_i, password=PASSWORD)

s_i.open(FILE_PATH)

g_i.gotostages()

last_phase = None
g_i.phase(g_i.phases[-1]) #adds phase without ID+
phase_ids = []
for new_phase in g_i.phases: #loop for obtain the last phase ID
    phase_ids.append(new_phase)
    last_phase = new_phase #end of the loop last_phase ID will be obtained

new_phase = input("name of the phase?") #and input() method to get phase name by user initiative
last_phase.PreviousPhase = phase_ids[3]
last_phase.Identification = str(f"{new_phase}") #setting the ID name of the phase based on the assigning str by input method

source_file = pandas.read_csv(f'C:\***\***\python_prj\input_datas\{str(new_phase)}.txt', sep="\t", header=None) #reading the source file. source file size must be [n, 7]. and the column seperator must be \t. use pandas



# Assuming PointLoad_26_1 is the name of the existing point load

for i in range(0, len(source_file[0:])):


    point_load_name = str(source_file.iloc[i, 6])
    # Find the point load with the specified name
    existing_point_load = None
    for point_load in g_i.PointLoads:
        if point_load.Name == point_load_name:
            existing_point_load = point_load
            break

    target_phase = g_i.phases[-1]

    # Check if the point load was found
    if existing_point_load:
        # Set the force value for the specified phase directly
        g_i.set(existing_point_load.Fx, target_phase, float(source_file.iloc[i, 0]))
        g_i.set(existing_point_load.Fy, target_phase, float(source_file.iloc[i, 1]))
        g_i.set(existing_point_load.Fz, target_phase, float(source_file.iloc[i, 2]))
        g_i.set(existing_point_load.Mx, target_phase, float(source_file.iloc[i, 3]))
        g_i.set(existing_point_load.My, target_phase, float(source_file.iloc[i, 4]))
        g_i.set(existing_point_load.Mz, target_phase, float(source_file.iloc[i, 5]))
    else:
        print(f"Point load with name '{point_load_name}' not found.")

g_i.save()

by reading file named such as G+Q for obtain the point loads in order to poin load number and finally assign them to the related point loads. the input_data.txt must be such as

-3.2609 -5.9701 140.1087    9.75532 -7.96849    0.00088766  PointLoad_1_1
-3.888  -5.3465 109.0027    8.95988 -8.5642 0.00120982  PointLoad_2_1
-2.3316 -5.2409 73.0104 8.89449 -6.00403    -0.00103105 PointLoad_3_1
-2.9715 -5.9101 171.2827    9.69463 -6.61349    -0.00051764 PointLoad_4_1
-6.0392 -132.1869   959.4964    13.60063    -14.26991   0.07052 PointLoad_5_1
-4.3912 -122.3273   -735.2128   19.07808    -12.6025    -0.05382    PointLoad_6_1
-4.2969 -132.6942   944.1204    13.95933    -11.84142   0.06305 PointLoad_7_1
-2.7531 -125.2636   -758.2481   18.98226    -10.08993   -0.05712    PointLoad_8_1
-4.8085 -84.2177    -506.6073   10.44485    -8.9906 -0.04749    PointLoad_9_1
-3.4422 -110.206    815.1456    9.18841 -7.88852    0.04306 PointLoad_10_1
-0.6881 -102.5075   924.5564    4.81558 -5.0788 0.0432213   PointLoad_11_1
-4.0984 -67.1984    -480.4729   8.83571 -8.80665    -0.09603    PointLoad_12_1
-2.7585 -84.125 -501.4753   10.45279    -6.5992 -0.04982    PointLoad_13_1
-3.4055 -110.7111   816.6459    9.15617 -7.21179    0.04973 PointLoad_14_1
-7.5054 -88.0892    -542.0342   19.99178    -15.71354   -0.06348    PointLoad_15_1
-2.3742 -124.4652   934.9625    7.54833 -6.88641    0.05552 PointLoad_16_1
-0.5452 -8.4301 119.6662    16.35598    -1.63104    0.000408305 PointLoad_17_1
-9.6775 -9.3732 -97.7663    21.33796    -2.76867    0.0694536   PointLoad_18_1
-20.2407    -11.7403    284.7181    23.44512    -2.46374    -0.0765672  PointLoad_19_1
-5.7858 -8.5031 -81.049 20.51614    -2.51047    0.0747804   PointLoad_20_1
-17.1303    -10.7111    300.045 22.44628    -1.14302    -0.0777544  PointLoad_21_1
0.5833331   -11.029166  220.5766    22.67978    -0.80467    -6.63389E-05    PointLoad_22_1
-3.417262   -3.3069 392.7851    7.32894 -7.18063    0.000898441 PointLoad_23_1
-2.886139   -5.429174   284.5967    9.43686 -6.63186    0.000547566 PointLoad_24_1
-3.5492 -7.15308    378.5466    11.13306    -7.38672    0.000737897 PointLoad_25_1
-8.4713 -8.3495948  -109.5216   20.27881    -2.29983    0.07353635  PointLoad_26_1
-20.1886    -11.3678    326.5459    23.01406    -1.24162    -0.0777675  PointLoad_27_1
-4.888  -9.2083 -40.4268    21.08947    -2.61274    0.0691367   PointLoad_28_1
-14.8629    -10.5017    226.9171    22.17974    -1.987  -0.0782271  PointLoad_29_1
-0.489  -5.317  49.9349 13.30536    -1.3802 0.000294335 PointLoad_30_1
-2.1974 -85.6157    -646.0163   7.1099  -5.71661    -0.0304 PointLoad_31_1
-7.0804 -97.076 1018.8904   10.65093    -14.15208   0.05108 PointLoad_32_1
-6.8692 -102.5866   918.9363    4.82877 -10.49269   0.0544981   PointLoad_33_1
-2.5368 -5.0877 -75.5326    8.75631 -5.8509 0.00036978  PointLoad_34_1
-2.7487 -67.878 -481.9494   8.81686 -6.22013    0.00484 PointLoad_35_1
-3.6314 -128.8986   1068.7668   10.03764    -11.3636    0.03723 PointLoad_36_1
-8.7772 -110.0567   -723.9966   14.89329    -16.19095   -0.06432    PointLoad_37_1
-3.1795 -3.2699 37.342  6.87543 -6.45667    0.001003957 PointLoad_38_1
-2.9778 -3.4014 1.3671  6.99427 -7.91652    -0.000945169    PointLoad_39_1
-3.2971 -109.9556   -738.6113   14.6996 -11.50226   -0.04813    PointLoad_40_1
-6.6527 -127.386    1060.5695   10.19462    -14.29757   0.06507 PointLoad_41_1
-1.479  -14.3992    288.495 24.39195    -2.89313    0.000279898 PointLoad_46_1
-50.31  -19.5018    -224.9771   39.28355    -4.68243    0.07391332  PointLoad_47_1
-44.5656    -17.531 -188.4306   37.54623    -4.41097    0.15899 PointLoad_48_1
-69.2869    -9.0432 554.7395    28.898  -5.49458    -0.11368    PointLoad_49_1
-68.2794    -23.2837    500.9856    42.02291    -4.82352    -0.10422    PointLoad_50_1
-1.1664 -5.4555 366.6481    15.93061    -2.56761    0.00064005  PointLoad_51_1
-53.1054    -22.7618    -176.6657   41.61885    -7.10401    0.10982678  PointLoad_52_1
-50.4476    -9.7346 -113.9005   29.63939    -6.24629    0.107025614 PointLoad_53_1
-78.4419    -18.7689    554.9108    38.67573    -5.92022    -0.15742    PointLoad_54_1
-2.2564 -5.9944 374.7445    16.44948    -3.68506    -0.0003616  PointLoad_55_1
-74.2486    -18.3056    525.4187    38.16516    -5.73959    -0.07789    PointLoad_57_1
-1.978552   -13.8542    298.553 23.86385    -3.41235    -0.000466344    PointLoad_58_1
-3.5358 -7.1635847  372.097 11.13785    -7.45495    -0.000826082    PointLoad_59_1
-3.774891   -5.420194   274.3266    9.42134 -7.66552    -0.00063103 PointLoad_60_1
-3.602006   -3.2789 386.3229    7.29301 -7.54815    -0.000748504    PointLoad_61_1
-3.6247 -86.5762    -527.9953   19.99146    -11.12519   -0.04848    PointLoad_62_1
-3.2655 -124.8371   945.563 7.48532 -7.07365    0.05572 PointLoad_63_1
-1.3792 -8.2528 125.4747    16.12188    -2.30883    -0.000061161    PointLoad_64_1
-20.0977    -9.3071 257.3387    21.17519    -2.51176    -0.0680846  PointLoad_65_1
-9.0053 -11.4604    -61.6257    23.09335    -2.86243    0.074896    PointLoad_66_1
-12.9353    -10.8643    -29.5419    22.53183    -5.00022    0.0799823   PointLoad_67_1
-24.7052    -8.4402 271.0479    20.3543 -2.66579    -0.0718731  PointLoad_68_1
-3.5747961  -11.006967  224.8926    22.62686    -4.9882272  -3.21928E-05    PointLoad_69_1
-25.8185    -9.2155 313.5884    21.11036    -2.59801    -0.071261   PointLoad_70_1
-21.3722    -8.3593 245.5649    20.30128    -2.98941    -0.07388502 PointLoad_71_1
-14.4172    -10.7271    -118.8921   22.40618    -3.34927    0.0798888   PointLoad_72_1
-10.0546    -11.1653    -4.3097 22.81154    -4.94032    0.0754482   PointLoad_73_1
-1.4467 -5.4623 55.1812 13.45759    -2.56268    -0.000576379    PointLoad_74_1
-3.4598 -84.8285    -633.0191   7.14303 -8.18774    -0.07906    PointLoad_75_1
-4.1457 -98.159 1030.0533   10.59315    -12.74197   0.06068 PointLoad_76_1
-3.6331 -5.1372 -46.8975    8.80237 -8.53494    -0.00050723 PointLoad_77_1

all seperators are "\t"

I wish it will be usefull who needs.