Civil 3D Tin Volume Surface Color Range

Hello - I’m new to dynamo and trying to figure out if I can create a color range to override the surface style for a tin volume surface.

Essentially, I want to automate the cut/fill map process with the standards I use regularly. Usually, I use 255, 200, 200 as my 0 to -1 cut color and then use a darker red for each increment of increased cut. For the fill values I do the same with shades of blue (0 to 1 is 200, 200, 255, 1 to 2 is 190, 190, 255, and so on). Is there a way to automate this in dynamo?

Thanks in advance!

1 Like

@Paolo_Emilio_Serra1 do you have any recommendations on this? I’m assuming this time of process would need a Python script to automate, but could the color range nodes be linked into this at all? I appreciate all of your help!

like this?

Yes you can do it in Python, you need to override the Analysis property of the Surface and set a collection of SurfaceAnalysisElevationData with the values you want.

here is an example (it doesn’t do exactly what you want but close enough)

You can also use a Dynamo Color range as an input.

3 Likes

Yes, that’s it! Thank you, this is very helpful! I’ll give this a try and let you know when I reach a solution.

Hi Paolo,
I’ve been testing your script. Could you please help me how cdoc is defined? I tried it as cdoc = CivilApplication.ActiveDocument, but I have this error:
Thanks in advance!
image

Are you 100% sure you have the exact same code I wrote? I’m calling “GetGeneralProperties()” not “GeneralProperties”

Thank you very much. It was bad calling exactly as wou wrote. There were some another warnings and error. Some of them I solved by adding: import math and from Autodesk.AutoCAD.Colors import *

At this moment I can¨t solve this NameError. Could you please give me any hint here?
image

1 Like

I added from System import Array and it works now.

1 Like

@Drbohlav Could you drop here python code. It will help others who is trying to help you.

After some investigation it does not work for minel, which is between -1 and 0.

 gp = surface.GetGeneralProperties()
                minel = gp.MinimumElevation
                maxel = gp.MaximumElevation
                
                saed = []

interval = .25
                cut = int(math.ceil((-1 - minel) / interval)) if minel < -1 else None
                fill = int(math.ceil((maxel - 1) / interval)) if maxel > 1 else None
                
                if cut is not None:
                    a = 200 / cut
                    
                    for i in range(cut + 1):
                        saed.append(SurfaceAnalysisElevationData(-1 - (cut - i) * interval, -1 - (cut - i - 1) * interval, Color.FromRgb(255,i * a, i * a)))
                
                        
                if fill is not None:
                    a = 200 / fill
                    for i in range(fill + 1):
                        saed.append(SurfaceAnalysisElevationData(i * interval, 1 + i * interval, Color.FromRgb(200 - i * a, 200 - i * a, 255)))

The Color range then look like this (intervals -0.75 to 0.00 and 0.00 to 0.25 are missing, step in fill is 1m not interval = 0.25):

Hi!

I’m trying to write some python script to define a particular style of analysis.
First of all, thanks @Paolo_Emilio_Serra1 for the inspiration!

Here is my code:

I’ve got an issue with the color…

erreur
anyone could help me…?

Thanks

I answer to myself…

You have to import autocad colors…

from Autodesk.AutoCAD.Colors import *
2 Likes

Great question. Civil 3D surface elevations properties are very cumbersome and time consuming, making this an ideal candidate for automation. Too bad there aren’t nodes for it yet, but in the meantime I’ll be testing out the Python codes posted here.

1 Like

@Paolo_Emilio_Serra1 , I’m getting this error:
NameError: global name ‘math’ is not defined

But I don’t see “math” being set by a global keyword anywhere. What does this mean?

@jameshitt did you import the math module?

2 Likes

Got it, I needed to import the math module, and also the colors and array talked about in this thread as well.
Thanks for the help! Editing code when you don’t really know how to code is the strangest thing; simultaneously more difficult and less difficult than you think…

2 Likes

Here’s what I’ve come up with…Forgive the unrefinement; it is a bit of a frankenstein, starting with Paulo’s script and modifying with everyone’s help and the C3D Developer’s Guide.


As for the surface selection, it appears Paulo’s original script looks for a surface by the name “Surface1”. In Dynamo proper, I added Surface Selection and Object Name nodes for the input.

Gotta say, I love it when a program comes together!

(And now will be changing up the color assignments…)

1 Like

Hi everyone,

Is there a full step-by-step on this topic. I’m not very knowledgeable of Python or C3D .NET API and I don’t seem to entirely understand what are the inputs for this code.

Thanks a lot to whoever replies, as this is a repeated and cumbersome task to go through every single time.

I haven’t used the code yet but from the images there is a function working on a given surface and the surface is hardcoded into the output, meaning that the function is being called by “Surface1” (see the last line) No inputs defined in the code but you should be able to modify this so it is done with any surface you define

1 Like

Can you post full snippets of your code? or the txt file of the full finalized code. Thanks!