Retrieve coordinates of a Polygon in PLAXIS 2D using Python

26 June 2019

In PLAXIS 2D, you may want to know all the coordinates of a polygon in order to use it in your Python/scripting environment. When looking at the items in the Selection Explorer in the PLAXIS 2D User Interface when selecting such a polygon, we nicely see all the corner points with their coordinates. However, the internal structure of the polygon object stores these polygon-points as a combination of a base insertion point and a list of so-called HelperPoints (e.g. Polygon_1.Points). These HelperPoints are relative to this insertion point.

PLAXIS 2D polygon points

Figure 1. Selected polygon (right) with the polygon points on the right in the selection explorer

Attached here is a small snippet for extracting this as a list of (x, y)-tuples and returning this list to be used in your Python script.

def getpolygoncoords(pg):
    """ reads all coordinates of the specified polygon and returns a list """
    # get insertion point
    base_x = pg.x.value
    base_y = pg.y.value
    # loop over all HelperPoints and return coordinates
    return [(base_x + i.x.value, base_y + i.y.value) for i in pg.Points]

# EXAMPLE: now loop over all polygons to print all the coordinates
for polygon in g_i.Polygons[:]:
    print("{}: {}".format(polygon.Name.value, getpolygoncoords(polygon)))

Note: this only works for Polygons in Structures mode, not for soil polygons created by a borehole.

Related posts

Privacy Preference Center


The Cookies are necessary for the site to function

CONSENT, NID, _cfduid, wp-settings-time-16, wp-setting-16, wordpress_test_cookie, gdpr[allowed_cookies], gdpr[consent_types], wp_woocommerce_session, wordpress_logged_in, wordpress_sec, PHPSESSID


These Cookies are used to provide you with useful information based on recent browser data

UserMatchHistory, lang, BizoID
lidc, bcookie


These are used to track user interaction and detect potential problems. These help us improve our services by providing analytical data on how users use this site

_ga, _gid