Hi @cslotboom,
Good to see you in our community 
Here is a simple Specklepy script that generates one polygon representing a slab and one mesh representing a wall. I added both and show attached a property “name”, you can modify it to align with your needs.
from specklepy.api.client import SpeckleClient
from specklepy.api.credentials import get_default_account
from specklepy.objects.geometry import Point, Polyline, Mesh
from specklepy.objects.base import Base
from specklepy.api import operations
from specklepy.transports.server import ServerTransport
from specklepy.core.api.inputs.version_inputs import CreateVersionInput
# initialize the Speckle client
client = SpeckleClient(host="app.speckle.systems")
# authenticate with your account
account = get_default_account()
client.authenticate_with_account(account)
# create points for a polygon
points = [
Point(x=0, y=5, z=0),
Point(x=10, y=5, z=0),
Point(x=10, y=15, z=0),
Point(x=0, y=15, z=0),
Point(x=0, y=5, z=0) # close the polygon by repeating first point
]
# create a polyline from points representing a slab
polygon = Polyline.from_points(points)
polygon.closed = True
polygon.name = "Slab"
# now create a mesh representing a wall
vertices = [
0, 0, 0,
10, 0, 0,
10, 0, 10,
0, 0, 10
]
faces = [
3, 0, 1, 2,
3, 0, 2, 3
]
mesh = Mesh.create(
vertices=vertices,
faces=faces,
colors=[],
texture_coordinates=[]
)
mesh.name = "Wall"
# create a base object to hold our geometries
base = Base()
base.polygon = polygon
base.mesh = mesh
# replace these with your actual project and model IDs
project_id = "YOUR_PROJECT_ID"
model_id = "YOUR_MODEL_ID"
# create a server transport
transport = ServerTransport(project_id, client)
# send the object to the server
obj_id = operations.send(base, [transport])
# create a version using the new API
version_input = CreateVersionInput(
objectId=obj_id,
modelId=model_id,
projectId=project_id,
message="Added a polygon",
sourceApplication="py"
)
# send the version to the server
version_id = client.version.create(version_input)
This script will create one polyline and one surface.
Hope this helps. Feel free to ask if you have further questions.