Civil 3D Tin Volume Surface Color Range

HI
TRY

# Load the Python Standard and DesignScript Libraries
import sys
import clr
import math

# 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 *
from Autodesk.AutoCAD.Colors import *

from System import Array

# 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[0]
interval = IN[1]
surveyprecision = IN[2]

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

def set_surface_analysis(surface_name,interval,surveyprecision):
	
	global adoc
	global cdoc

	with adoc.LockDocument():
		with adoc.Database as db:

			with db.TransactionManager.StartTransaction() as t:
            	# Place your code below
           		# 
            	#
				bt = t.GetObject(db.BlockTableId, OpenMode.ForWrite)
				btr = t.GetObject(bt[BlockTableRecord.ModelSpace], OpenMode.ForWrite)
			
				surface = None
				for oid in cdoc.GetSurfaceIds():
					obj = t.GetObject(oid, OpenMode.ForRead)
					if obj.Name == surface_name:
						surface = obj
						break
					
				if surface is None:
					return False
				
				gp = surface.GetGeneralProperties()
				minel = gp.MinimumElevation
				maxel = gp.MaximumElevation
				#minelf = minel - (minel - (math.floor(minel / interval) * interval))
				minelf = int(minel)
				maxelc = int(maxel)
				#maxelc = ((math.ceil(maxel / interval) * interval) - maxel) + maxel
				minelfn = int(minelf)
				maxelcn = int(maxelc)
				
				upperprecision = 0 + surveyprecision
				lowerprecision = 0 - surveyprecision
				saed = []
			
				#interval = .5
				
				redsteps = int(((lowerprecision - minelf) / interval)+1)
				greensteps = int(((maxelc - upperprecision) / interval)+1)
				
				i = 0
				n = 0
				upperbound = 0
				lowerbound = 0
				table = []
				while upperbound >= minelf:
						lowerbound = lowerprecision - interval - i
						upperbound = lowerbound+interval
						g = ((250/redsteps)*n)
						b = ((250/redsteps)*n)
						saed.append(SurfaceAnalysisElevationData(lowerbound, upperbound, Color.FromRgb(250,g,b)))
						i += interval
						n += 1
						table.append([int(lowerbound),int(upperbound),250,g,b])

				else:
					i = 0
					n = 0
					while lowerbound <= maxelc:
						lowerbound = upperprecision + i
						upperbound = lowerbound + interval
						r = ((250/greensteps)*n)
						b = ((250/greensteps)*n)
						saed.append(SurfaceAnalysisElevationData(lowerbound, upperbound, Color.FromRgb(r,250,b)))
						i += interval
						n += 1
						table.append([int(lowerbound),int(upperbound),r,250,b])
						
				
				saed.append(SurfaceAnalysisElevationData(lowerprecision, 0, Color.FromRgb(255,190,92)))
				table.append([int(lowerprecision),0,255,190,92])
				
				saed.append(SurfaceAnalysisElevationData(0, upperprecision, Color.FromRgb(236,247,29)))
				table.append([0,int(upperprecision),263,247,29])
				sorttable = table.sort()
				
				surface.Analysis.SetElevationData(Array[SurfaceAnalysisElevationData](saed))
			
			
            	# Commit before end transaction
				t.Commit()
	
	return table

# Assign your output to the OUT variable.
OUT = set_surface_analysis(IN[0],IN[1],IN[2])

FOR EXPORT TO EXCEL SEE THIS IS

1 Like