Elk package, some polygons can't be created

Hi,
I wonder about your suggestions to create buildings better.

I am using Elk to create buildings. I use PolygonByPoints and then extrude as solid nodes to create a building in 3d. I wonder if I can add any node to create polygons better since some polygons can’t be created.

I added PruneDuplicates node to avoid getting null when creating polygons, but it still can’t create some buildings.

some polygons can't be created, I am sure every building has height value.

Where does Elk come in? Are you using it to generate the initial point list or just for creating shapes later? We need to see the error to know what’s causing the problem but I’m guessing you just have points that don’t generate a closed loop. There’s nothing that’s going to “improve” your geometry creation except better handling the geometry.

1 Like


It comes from here.

I am using Elk to get the initial point list of building footprints and building heights. I extrude polygons by using the Elk key, “height”. Since all buildings have height keys added I only have a problem with creating closed polygons.

I thought maybe Nurbs Curve (which is a worse way to create footprints) or any other package’s curve creation node might be suggested.

But as you say, I should think of improving geometry. I understand I should write a Python code that takes each sublist of the point list and creates a closed polyline from each point. Thank you.

There are a few custom nodes that already attempt to do this but depending on your geometry and use cases, it may be worth developing something yourself.

Hi,
I have looked at the building footprints points exported from OSM. I have realized that the points are constructed like this:
If the building has 4 edges, the building has 5 points which the first and the last are the same. That is why when we create a polygon from points some buildings are created like triangular like below.

image

I mean if there were 4 points, not 5 points, the polygon would look like this. (which is the right appearance)
image

I also realized the points are in order the first one creates a line with the second, the second with third and the last point creates a line with the first point.

In summary, the nulls are created like this

So, I wanted to write a script that creates a polyline by joining lines that are created from the points list which is a sublist of each building list.
Because my Python skills are not developed enough, the script has a little bit issue.

Could you help me, please?

Script
# Load the Python Standard and DesignScript Libraries
import sys
import clr

clr.AddReference('ProtoGeometry')
import Autodesk
from Autodesk.DesignScript.Geometry import *

clr.AddReference('DSCoreNodes') 
import DSCore
from DSCore import *


# The inputs to this node will be stored as a list in the IN variables.
buildingsList = IN[0]

# Place your code below this line

# Flatten a list
def flat(ptList):
    return DSCore.List.Flatten(ptList,1)


# create polycurves from a pointlist
def createPolyline(ptList):
    
    for point in range(len(ptList)):
        
        lineList=[]
        i=0
        
        # create Lines from ptList
        
        if i< len(ptList):
            
            lineList.append(Line.ByStartPointEndPoint((DSCore.List.GetItemAtIndex(ptList,i)),(DSCore.List.GetItemAtIndex(ptList, i+1))))
            
        
        if i==len(ptList):
            lineList.append(Line.ByStartPointEndPoint((DSCore.List.GetItemAtIndex(ptList,i)),(DSCore.List.GetItemAtIndex(ptList, 0))))
            
        # create polyLines from lineList
        t2 = List.RestOfItems(lineList);
        t3 = List.FirstItem(lineList);
        polyCurve = Autodesk.Curve.Join(t3, t2);


# create polyLines 

polycurveList = []

for buildingPtList in buildingsList:
    
    for ptList in buildingPtList:
        ptList=flat(ptList)
        polycurveList.append(createLines(ptList))


# Assign your output to the OUT variable.
OUT = PolyCurveList

the first error I get is this, I’ll probably get more if I fix that too.

It seems like pruning the duplicate points like you attempted would solve your problem. What was the result of you doing that? Did you get 4 points instead of 5? If you did then there’s something else going on. If you didn’t then you might want to reevaluate whether your tolerance is working or if something else is causing you not to get a cleaned up set of points.

Also, instead of connecting the points into individual lines and then connecting the lines, you can just use Polycurve.ByPoints to do them all at once. This is essentially what Polygon.ByPoints is doing as well, so I don’t see why you need to do this in python.

1 Like

it didn’t solve my problem. :confused:

I also test it like this. I get null again.
I added prune node to the one null building to create a polygon

But what did it do? We can’t help you if you don’t tell us what’s going on. Did it prune the list of points or did it not? What do the errors your getting say? If something is failing then it’s obviously going to cause issues downstream. We need to know what is failing and why.

it did prune the list. I will think again for what is the problem behind it.

It says Polycurves may be branching either way when I create from “polygon.ByPoints” node or by “curve.Join” node.


image

I am not sure what that means. The points have no z values so, they are located in the same x and y plane, so I guess they are aligned to each other. I think the line order is the issue. I am not sure how curve Join works, is it joining the points in order or by the closest points?

I draw the points in Autocad, I guess there are multiple way to create a polygon like this.


the building is normally should look like that.
image

but I am not sure if I think in the right way.

By the way polygon.Bypoints do great job in civil 3d but in Revit 23 it can’t create polygons. I will try to use the dynamo file in Revit 24 right now I am using Revit 23.
in civil 3d 2023 it looks like this


in Revit 2023 it looks like this

FYI: I got the right results in Revit 2024.
Problem solved I guess. :tada: :tada: