Hello, I`m new ussing the Autocad and Civil 3D API and I would like to combine a part of a python code to get the area of a group of surfaces (wich are not TIN Surface) with the Node SelectObejcts.
In the image, I have two Python nodes, The first one (Python Script(01)) is to select the elements in the drawing space and the second one (Python Script(02)) is to get the area from the selection group, I think the problem could be the ObjectId.
if someone can help me, I really appreciate
Let the files that I used below
Thanks
PythonScript(01)
# Load the Python Standard and DesignScript Libraries
import sys
import clr
# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
# The inputs to this node will be stored as a list in the IN variables.
dataEnteringNode = IN
Ids1 = []
Areas = []
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
#Selection Elements in Drawing Space
Seleccion = editor.GetSelection()
if Seleccion.Status == PromptStatus.OK:
#Get into a variable the objects in slection
Elements = Seleccion.Value
# Commit before end transaction
#t.Commit()
pass
# Assign your output to the OUT variable.
OUT = Elements
PythonScript(02)
# Load the Python Standard and DesignScript Libraries
import sys
import clr
# Add Assemblies for AutoCAD and Civil3D
clr.AddReference('AcMgd')
clr.AddReference('AcCoreMgd')
clr.AddReference('AcDbMgd')
clr.AddReference('AecBaseMgd')
clr.AddReference('AecPropDataMgd')
clr.AddReference('AeccDbMgd')
# Import references from AutoCAD
from Autodesk.AutoCAD.Runtime import *
from Autodesk.AutoCAD.ApplicationServices import *
from Autodesk.AutoCAD.EditorInput import *
from Autodesk.AutoCAD.DatabaseServices import *
from Autodesk.AutoCAD.Geometry import *
# Import references from Civil3D
from Autodesk.Civil.ApplicationServices import *
from Autodesk.Civil.DatabaseServices import *
# The inputs to this node will be stored as a list in the IN variables.
Ids1 = []
Areas = []
Layers = []
Surface_Types = ["Autodesk.AutoCAD.DatabaseServices.Surface",
"Autodesk.AutoCAD.DatabaseServices.LoftedSurface",
"Autodesk.AutoCAD.DatabaseServices.PlaneSurface",
"Autodesk.AutoCAD.DatabaseServices.SweptSurface",
"Autodesk.AutoCAD.DatabaseServices.ExtrudedSurface"]
adoc = Application.DocumentManager.MdiActiveDocument
editor = adoc.Editor
with adoc.LockDocument():
with adoc.Database as db:
with db.TransactionManager.StartTransaction() as t:
#Get into a variable the objects in slection
Elementos = IN[0]
for elemento in Elementos:
Ids1.append(t.GetObject(elemento.ObjectId,OpenMode.ForRead))
for i in Ids1:
if str((i.GetType())) in Surface_Types:
Areas.append(i.GetArea())
Layers.append(i.Layer)
else:
Areas.append(None)
# Commit before end transaction
#t.Commit()
pass
# Assign your output to the OUT variable.
OUT = zip(Areas,Layers)
Get_Surface_Area_Prototype.dyn (13.7 KB)
Test_01.dwg (918.0 KB)