Hi,everyone! At first, I’m soory for my poor English…
Now I want to create featureline from AutocorridorFeatureline through polyline3d.
I could create a polyline3d from AutocorridorFeatureline but couldn’t create featureline from it because of error " Argument Exception : A feature line can’t be created from the entity geometry "
Here is the code. Please correct it.
existing_names = []
featureline = None
fl_name = "法尻"
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
civilDoc = CivilApplication.ActiveDocument
flColl = civilDoc.GetSitelessFeatureLineIds()
p3dColl = Point3dCollection()
for flId in flColl:
fl = t.GetObject(flId,OpenMode.ForRead)
points = fl.GetPoints(2)
existing_names.append(fl.Name)
for point in points:
p3dColl.Add(Point3d(point.X,point.Y,point.Z))
polyline3d = Polyline3d()
btr = t.GetObject(db.CurrentSpaceId,OpenMode.ForWrite)
btr.AppendEntity(polyline3d)
t.AddNewlyCreatedDBObject(polyline3d,True)
for i in range(p3dColl.Count):
vertex = PolylineVertex3d(p3dColl[i])
polyline3d.AppendVertex(vertex)
index = 0
new_fl_name = fl_name
while new_fl_name in existing_names:
index += 1
new_fl_name = f"{fl_name}{index}"
new_fl = FeatureLine.Create(new_fl_name, polyline3d.ObjectId)
featureline = t.GetObject(new_fl,OpenMode.ForWrite)
t.Commit()