I want to calculate the area of a surface(Autocad surfaces, not TIN surfaces) in Civil3d

I would like to create a Dynamo that measures the area of a surface (Explode Solid), but I just can’t get it to load. Could you please advise?


Hi
Attached example drawing

Thank you very much.
I cannot see the attached diagram, so I would appreciate it if you could attach it.

hi
try

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 *
import Autodesk

def GetArea(Surfaces):
	
	global adoc
	global cdoc
	
	output = []
	

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

	with adoc.LockDocument():
	    with adoc.Database as db:
	        with db.TransactionManager.StartTransaction() as t:
				for Surfac in Surfaces:
					vals = []
					
					SurfacId = Surfac.InternalObjectId
					obj = t.GetObject(SurfacId, OpenMode.ForRead)
					
					if isinstance(obj, Autodesk.AutoCAD.DatabaseServices.Surface):

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

OUT = GetArea(IN[0])

3 Likes

Thanks for your reply.
Where do I paste the code you gave me?
I would appreciate it if you could tell me.

1 Like