Convert DatabaseServices.Polyline to Dynamo Polyline

Good morning,

I’m trying to get the geometry from a parcel segment. I’ve selected the parcel segment and opened it up to get the baseline in Python. This returns Autodesk.AutoCAD.DatabaseServices.Polyline which isn’t something I can use in Dynamo. The method from google that is used to convert it to a dynamo object is to grab the polyline’s ObjectId and use t.GetObject(Id, OpenMode) to convert to a dynamo polyline. However, since this polyline is the baseline of an parcel segment the ObjectId for the baselines is returning (0).

Is there a good way to convert from Autodesk.AutoCAD.DatabaseServices.Polyline to a Dynamo Polyline object?

image

The Arkance Systems Node Library contains a node to get Dynamo geometry from parcels.

I don’t know how it works in Python. Normally you can convert a polyline with the Dynamo functions to a polycurve, but I don’t think it works on a parcel’s baseline.

1 Like

This doesn’t answer your question, but FYI the Civil 3D Toolkit has a node to get parcel geometry as well.

1 Like

One clarification: are you trying to extract the parcel geometry and output a new polyline into model space? Or are you trying to get a Dynamo polycurve only?

I’m trying to set a custom attribute for each parcel segment based on its geometry. Either making a new polyline or a Dynamo polycurve could work. I ended up making a new polyline in model space then extracted that polyline’s geometry. Code below for anyone interested:

2 Likes

thanks, in text if anyone else wants to copy:

#dict = Dictionary [String, Object]() 
errorReport = None
debug_log = []
result = []

with adoc.LockDocument():
	with adoc.Database as db:
		for x in range(0,len(obj_lst)):
			obj = obj_lst[x]
			with db.TransactionManager.StartTransaction() as t:
				try:
					bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
					btr t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
					
					aeccObj = obj.InternalDBObject
					aeccObj.UpgradeOpen()
					parcel_line = aeccObj.BaseCurve
					
					btr_obj_id = btr.AppendEntity(parcel_line)
					t.AddNewlyCreatedDBObject(parcel_line, True)
					aeccObj.DowngradeOpen()
					btr_obj = t.GetObject(btr_obj_id,OpenMode.ForRead)
					obj_handle = str(btr_obj.Handle)
					
					t.Commit()
				except:
					import traceback
					errorReport = traceback.format_exc()
			new_obj = SelectionByQuery.GetObjectByObjectHandle(obj_handle)
			result.append(new_obj)
			
OUT = result if errorReport is None else errorReport`Preformatted text`