Python get Structual element by Name

Hi,

there is a script example to get the anchor forces out during several phases:

Output scripting example: get anchor force - PLAXIS | SOILVISION Wiki - PLAXIS | SOILVISION - Bentley Communities

the anchor is identified by its location (g_o.getresults(phase,g_o.ResultTypes.NodeToNodeAnchor.Y,'node') )

is it possible to identify anchors or plates by its Name / Identification?

  

EXAMPLE: Plate 438 / [Plate_9_3]

thanks.

  • Dear Falko,

    The getresults command supports an object name directly as a parameter. This means you can do the following:

    g_o.getresults(g_o.NodeToNodeAnchors[0], g_o.Phases[-1], g_o.ResultTypes.NodeToNodeAnchor.Y, 'node')

    Therefore you can simply have a for-loop for each anchor and avoid collecting all data and then sorting them out. This can prove to be a better approach overall.

    Currently most of the properties in the g_o.ResultTypes concern resulting values and not so much the name of objects, which is why you cannot find a property for the name.

  • Thanks Stefanos,

    my model has a lot of plates, and is subject to changes, so I will have to repeat the data extraction procedure. Due to productivity I need to avoid manual actions.

    I was adapting the anchor script :

    anchorF = g_o.getresults(fase,
    g_o.ResultTypes.NodeToNodeAnchor.AnchorForce2D,
    'node')
    anchorX = g_o.getresults(fase,
    g_o.ResultTypes.NodeToNodeAnchor.X,
    'node')
    anchorY = g_o.getresults(fase,
    g_o.ResultTypes.NodeToNodeAnchor.Y,
    'node')

    for x,y,N in zip(anchorX,anchorY,anchorF):
    # check for the correct anchor by location:
    print("Anchor force N in {}: {:.2f} kN/m".format(fase.Name,N))
    #if abs(x - Xanchor) < 1E-5 and abs(y - Yanchor) < 1E-5:

    for plates (just an example):

    Uxs = g_o.getresults(fase,
    g_o.ResultTypes.Plate.Ux,
    'node')
    Uys = g_o.getresults(fase,
    g_o.ResultTypes.Plate.Uy,
    'node')
    X = g_o.getresults(fase,
    g_o.ResultTypes.Plate.X,
    'node')
    for X,ux,uy in zip(Xs,Uxs,Uys):
    print("Plate @ x {}: horizDisp {:.2f} m vertSettlement {:.2f} m".format(X,ux,uy))

    while cycling the following output is generated:

    Plate @ x 105.6196: horizDisp 0.00 m vertSettlement -0.02 m

    Canthis be separated / filtered by Plate ID (Plate_9 for example)? 

    How would you get the sorted plate data out of the model? 

    EDIT:there was an error in the code. Fixed it

  • Hello Falko,

    This is a Python issue (not a PLAXIS one) in which you are simply confused about which variables to call in the print statement.

    You do a for-loop over the lists that contain the results: X, Uxs, Uys

    With this for-loop you use the internal variables: x, y, N

    And when it comes to printing them you should use the internal ones and not the full lists. So, just replace the last command with the following and everything runs smoothly:

    print("Plate @ x {}: horizDisp {:.2f} m vertSettlement {:.2f} m".format(x, y, N))

    In the future, it will be helpful to you to do a small debugging yourself as you could spot this problem by understanding the error message Python gives you. 

    It mentions a TypeError and an unsupported format string passed. This points to the {:.2f} which is the string formatting you do.
    For instance, by removing it you would get the command working but here is how it looks:

    This is what triggered me to check what is actually passed to the string formating via the {}. And then you see that for every line you get the same, which is true, you get the full list as an object (PlxProxyObjectValues to be precise).

    I hope that this helps (in the future, too).

    For the record this is the correct one:

  • Hi Stefanos,

    thank you for your reply, actually I sorted that out after posting the question and edited the question. the code produces now lines like in your screenshot. I only need to separate / filter by Plate ID (Plate_9 for example) in order to get usefull data? Goal is to get the Plate data sorted by a property (ID or Name).

    I guess If I get the Plate_9 plate objects, Plate_9_1, Plate_9_2 are included.

  • Hi Stefanos,

    after digging in a bit:

    I used the g_i.get_equivalent() method to get the Name of the plate and do some filtering on the results.

    Thank You Stefanos.