“”"
Copyright 2019 Autodesk, Inc. All rights reserved.
This file is part of the Civil 3D Python Module.
“”"
author = ‘Paolo Emilio Serra’
copyright = ‘2019’
version = ‘1.0.0’
def get_featurelines():
“”"
Extract the Land Feature Lines in the document and converts them into Dynamo PolyCurves
:returns: Dynamo PolyCurves
“”"
global adoc
global cdoc
output = []
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
fls = []
for oid in btr:
fl = t.GetObject(oid, OpenMode.ForRead)
if isinstance(fl, FeatureLine) and fl.SiteId == ObjectId.Null:
pts = []
for pt in fl.GetPoints(FeatureLinePointType.AllPoints):
pts.append(DS.Point.ByCoordinates(pt.X, pt.Y, pt.Z))
if len(pts) > 1:
fls.append(DS.PolyCurve.ByPoints(pts))
if len(fls) > 0:
output.append(fls)
for sid in cdoc.GetSiteIds():
site = t.GetObject(sid, OpenMode.ForRead)
fls = []
for fid in site.GetFeatureLineIds():
fl = t.GetObject(fid, OpenMode.ForRead)
pts = []
for pt in fl.GetPoints(FeatureLinePointType.AllPoints):
pts.append(DS.Point.ByCoordinates(pt.X, pt.Y, pt.Z))
if len(pts) > 1:
fls.append(DS.PolyCurve.ByPoints(pts))
if len(fls) > 0:
output.append(fls)
return output