Select Objects in Civil3D

Does someone know the reason why i can’t get the geometry which is selected?

Because they are not implemented as Dynamo Objects yet.

USE THIS

Is there a node to transform them into Dynamo objects?

1 Like

Does someone know how to convert Civil Object to Autodesk.AutoCAD.DynamoNodes.Object ?

because of my language
Post a picture of what you want
so I can help you
But this code helps

sampleLineId = sampleLine.InternalObjectId
					obj = t.GetObject(sampleLineId, OpenMode.ForRead

Hi, Just as i posted. I need the get the geometry of selected sample line in Dynamo. But i need to convert the object typ (Civil Object) to Dynamo Object so that i can use the node Object.Geometry to implement it. Thanks for your posted code before, but i think it is used to get all informations of the sample lines, right?

test

import sys
import clr

clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry')

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

from System.Collections.Generic import Dictionary

adoc = Application.DocumentManager.MdiActiveDocument
cdoc = CivilApplication.ActiveDocument

from Autodesk.DesignScript.Geometry import *


def get_sample_line_info(sampleLines):
	
	global adoc
	global cdoc
	
	output = []
	

	if not sampleLines:
		return
	
	if not isinstance(sampleLines, list):
		sampleLines = [sampleLines]

	with adoc.LockDocument():
	    with adoc.Database as db:
	        with db.TransactionManager.StartTransaction() as t:
				for sampleLine in sampleLines:
					vals = []
					
					sampleLineId = sampleLine.InternalObjectId
					obj = t.GetObject(sampleLineId, OpenMode.ForRead)
					
					if isinstance(obj, SampleLine):
						vals.append(obj.Name)
						vals.append(obj.Number)
						vals.append(obj.Station)
						output.append(vals)
						
				t.Commit()
	return output 		

OUT = get_sample_line_info(IN[0])

or this

import sys
import clr

clr.AddReference('AcMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AeccDbMgd')
clr.AddReference('ProtoGeometry')

from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *

from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *

from System.Collections.Generic import Dictionary

adoc = Application.DocumentManager.MdiActiveDocument
cdoc = CivilApplication.ActiveDocument

from Autodesk.DesignScript.Geometry import *


def get_sample_line_info(sampleLines):
	
	global adoc
	global cdoc
	
	output = []
	

	if not sampleLines:
		return
	
	if not isinstance(sampleLines, list):
		sampleLines = [sampleLines]

	with adoc.LockDocument():
	    with adoc.Database as db:
	        with db.TransactionManager.StartTransaction() as t:
				for sampleLine in sampleLines:
					vals = []
					
					sampleLineId = sampleLine.InternalObjectId
					obj = t.GetObject(sampleLineId, OpenMode.ForRead)
					
					if isinstance(obj, SampleLine):

						output.append(obj)
						
				t.Commit()
	return output 		

OUT = get_sample_line_info(IN[0])
1 Like

Hi i need the typ Autodesk.AutoCAD.DynamoNodes.Object, what your code did is not exactly what i want…

image
Or can i get the Location inside the vertices List so that i can get the left, center, right points coordinates?

Ok ,yes

You need this

Must be modified to fit the code

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)	

Hi @1054896935,

This is not going to be possible as you’ve described. The Object.Geometry node is doing a lot of work under the hood to make it possible to get the Dynamo geometric representation of many different types of native AutoCAD and Civil 3D objects. You can’t just pass anything into Object.Geometry and expect it to work because, at the moment, the Autodesk team has only implemented a limited set of object types for it to work with. So when you get the warning that says “Not implemented”, it means exactly that: the object type that you’re trying to use (in this case a Sample Line) has not be implemented to work in Dynamo yet. So that is a sign that you need to go a different route.

The workflow is:

  1. Select the objects, which will be the Autodesk.Civil.DynamoNodes.CivilObject class
  2. Get the native Civil 3D object (Autodesk.Civil.DatabaseServices.SampleLine) from the Civil Object
  3. Get the collection of vertices for each Sample Line
  4. Connect the vertices together to create a Dynamo curve

Like @hosneyalaa mentioned earlier, there is another post where I shared Python code to do all of this:

6 Likes