Dynamic link to volume surface cut and fill values

Dynamic link to volume surface cut and fill values

Anonymous
Not applicable
6,689 Views
20 Replies
Message 1 of 21

Dynamic link to volume surface cut and fill values

Anonymous
Not applicable

Is it possible to add a formula to a table cell that dynamically links to the cut/fill values of a volume surface?

I'm hoping to use formulas in a table to compare values from different volume surfaces. The values will need to be dynamic though so if the volume surface is updated, the link values are updated too. I looked in the field options for the object but they were just the basic properties.

 

Regards,

Peter

0 Likes
Accepted solutions (2)
6,690 Views
20 Replies
Replies (20)
Message 2 of 21

Anonymous
Not applicable

Paste the volume surface into an empty Tin for more readability.

 

not sure of the formula but makes the vol more useable 

 

see previous link 

 

https://www.google.com/search?q=dynamic+differential+tin+surface&ie=UTF-8&oe=UTF-8&hl=en-us&client=s...

0 Likes
Message 3 of 21

Anonymous
Not applicable

@Anonymous, thanks for your response. As indicated in my response to the other related thread, I have a feeling I can't achieve what I want through modelling dynamic volume surfaces alone.

 

For others reading this, I am trying to get the volume of sub-surface materials dynamically without using the Material Quantities command as this is painstakingly slow on long complex alignments, especially when multiple edits are being made. I just want to be able to review the totals for each material on the go while making edits to balance or generate material. The volumes dashboard is a great tool but I would like to be able to list the volumes in a table where I can then add formula to make calculations between them. I think that I could get around the whole thing if I am able to create dynamic links to a table showing the cut volume of the surfaces and then use formula to do what I need.

 

For example I could have three volume surfaces as below:

1 - Rock Cut (compare design surface to top of rock)

2 - Rock+Clay Cut (compare design surface to top of clay)

3 - Rock+Clay+Topsoil Cut (compare design surface to top of topsoil)

 

If these values were in a table I could then apply formula as below:

1 - Rock Volume = (Rock Cut)

2 - Clay Volume = (Rock+Clay Cut) - (Rock Cut)

3 - Topsoil Volume = (Rock+Clay+Topsoil Cut) - (Rock+Clay Cut)

 

As I alter my profile/alignment these values would then be automatically refreshed (maybe requiring a regen first).

 

I just need to figure out how to link to the cut values of volume surfaces...……………...

0 Likes
Message 4 of 21

tcorey
Mentor
Mentor
Accepted solution

You could do it with VisualLISP. Obtain the volume values from the volume surface, store the values as public variables. Within each table cell, create fields that get their info from the LISP variables. You will need a Reactor that gets the new volumes if the selected volume surface has been modified.

 

This short code shows how easy it is to get the volume data from the surface:

 

(defun c:getvol ( / srf stats);these variables are private
(vl-load-com)
(setq srf (vlax-ename->vla-object (car (entsel "\nSelect TIN Volume Surface: ")))
      stats (vlax-get srf 'Statistics)
	  cut (rtos (vlax-get stats 'cutvolume) 2 2);this variable is public
	  fill (rtos (vlax-get stats 'fillvolume) 2 2) ;this variable is public
	  )
	  (princ)
	  )

 

 

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 5 of 21

Anonymous
Not applicable

@tcorey, you are speaking my language. I didn't realise you could access C3D object properties with Lisp. I thought that ability was just limited to .net, of which I know nothing.

 

Using your quick code I can indeed create the variables and link a table cell to it. This could be the start of something beautiful. Definitely going to expand on and play with that.

 

Thanks @tcorey , you just made my day.

Message 6 of 21

tcorey
Mentor
Mentor

I’m glad I could help. Often, when I mention LISP, people’s eyes glaze over.  😉



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 7 of 21

Anonymous
Not applicable
Accepted solution

In the interests of giving back to the community. After a leg up from @tcorey I have created the attached lisp routine.

It simply creates cut and fill variables for all volume surfaces in a drawing. It seemed quicker that way, rather than selecting each one required. Fields can then be linked to the cut/fill values of any volume surface, and if like me you need to take them away from each other to achieve an in-between volume then you can setup a table, populate relevant cells with cut/fill fields and then add formula to do the rest. Works great for me.

After making any updates to your surfaces the routine will need to be run again, but will also update your linked fields too.

 

I now only have to run a full material take-off once the trial and error process is more or less done. Joy!

Message 8 of 21

tcorey
Mentor
Mentor

I is satisfying for me to see someone take a seed and make a tree. Thanks for sharing. 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
Message 9 of 21

neilyj666
Mentor
Mentor

@Anonymous wrote:

In the interests of giving back to the community. After a leg up from @tcorey I have created the attached lisp routine.

It simply creates cut and fill variables for all volume surfaces in a drawing. It seemed quicker that way, rather than selecting each one required. Fields can then be linked to the cut/fill values of any volume surface, and if like me you need to take them away from each other to achieve an in-between volume then you can setup a table, populate relevant cells with cut/fill fields and then add formula to do the rest. Works great for me.

After making any updates to your surfaces the routine will need to be run again, but will also update your linked fields too.

 

I now only have to run a full material take-off once the trial and error process is more or less done. Joy!

 

 


Please can you advise how to "...populate relevant cells with cut/fill fields...." as I'm lost at this stage...:)

neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
0 Likes
Message 10 of 21

Anonymous
Not applicable

The variables can be linked to any field depending on your requirement.

- To insert field go to 'Insert' tab, 'Data' tile and select 'Field'. In the field dialog box filter 'Field Category' for "Other", select "LispVariable" in the 'field names' and then select the variable from the list of 'lisp variabes'. Variables will be stored as "{SurfaceName}_FillVol" or "{SurfaceName}_CutVol".

- If like me you want to use these values in formulas, then first create an autocad table. Go to 'Annotate' tab, 'Tables' tile and select 'Table'. Now setup the properties for your table and click 'OK' to insert it into the drawing. To add a field in a cell, click in the desired cell and select 'Field' button from 'Insert' tile, or right-click in the cell and select 'Insert>Field'. The Field dialog box now pops up and the variable can be added as process above. Once you have multiple values in a table you can now add formulas. Click in a cell and select 'Formula' button from 'Insert' tile. This can also be achieved by right-click in cell and select 'Insert>Formula'. Choose the type of formula you wish to add. For computing formulas between cell values you can use cell references just like in excel A1, B2 etc.

 

When the values update, the formula results should also update.

 

Hope the above helps.

 

EDIT: Not sure what happened to the text styles above.

Message 11 of 21

neilyj666
Mentor
Mentor

@Anonymous  Thanks for this - I was actually doing it correctly but the volume surface names were causing an issue.

 

Our surface naming convention is to name volume surfaces as below with a leading VS and spaces which created one lisp variable called vs

 

2019-07-26 11_18_19-Toolspace.jpg

 

I added an underscore to the surface names in Prospector and the Lisp Variables worked as expected

 

2019-07-26 11_24_33-Autodesk Civil 3D 2020 - [L__Tenders_Tenders 2019_E2701 Gordonbush WF_2 Tender w.jpg

 

I'm totally lisp illiterate (and wouldn't know where to start) but is it possible to account for spaces in the names programatically as this looks like a very useful routine which could add fields to multileaders and mtext etc?

 

Thanks

 

Neil

 

neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
0 Likes
Message 12 of 21

Anonymous
Not applicable

To be honest I never use spaces in C3D naming and so didn't realise this would cause an issue. I'll definitely take a look when I get chance later today.

 

Regards,

Peter

0 Likes
Message 13 of 21

neilyj666
Mentor
Mentor

@Anonymous That would be great if it is possible - if not I can use CamelCase for naming the Volume surfaces

 

Civil objects are probably the only thing I do use spaces for when naming as my Layers and file names are to BS1192 naming convention using underscores and hyphens.

neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
0 Likes
Message 14 of 21

Anonymous
Not applicable

@neilyj666it seems variables cannot have spaces in them. I can adjust the code to read the full name when creating the variable, but it then errors out due to the spaces. Only way around would be to step through the surface names and replace spaces with underscores before creating the variable. No time to write it right now though.

 

You also need to understand the limitations of this lisp. Lisp variables are not maintained from session to session. When you close the drawing and reopen the variables are no longer present in the drawing. If you force a field update then the linked fields return null as there is no value for it to read.

 

I originally created this to run quick calcs between volumes to get a general idea of my quantities during the design process rather than having to punch the numbers into a calculator each time I made a change, or keep re-running material take-offs which can be time consuming for large projects. It wasn't really created with the intention of placing permanent links. I just run the command TVTF after opening the drawing, previous links then have a target variable (unless I changed the name of a surface!!), and I can plough on.

 

If you added fields to mtext and multileaders, and then someone else opened your drawing and updated the fields globally, you would lose the values in the mtext and multileader objects. To add the values to these objects the variables would want to be saved within the drawing so that they are retained between sessions. No idea how to achieve that. Open to suggestions from all.

 

Regards,

Peter

 

EDIT: My text always seems to go funny when I copy and paste within the message.....strange!

0 Likes
Message 15 of 21

neilyj666
Mentor
Mentor

@Anonymous  thanks for the info - I've never understood why this information isn't made available by Autodesk natively; it is a major source of annoyance having to delve into the properties everytime for this info but I suppose the sanswer would be that it is readily available via the Volumes Dashboard.

 

Is it available via Property Set data? I'm afraid I have no idea how to achieve what you suggest; perhaps @tcorey  can advise??

 

Maybe it needs to be done via .NET (like I know what I'm talking about...Smiley Happy)

 

Regards

 

Neil

neilyj (No connection with Autodesk other than using the products in the real world)
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.

EESignature


AEC Collection 2026 UKIE (mainly Civil 3D UKIE and IW)
Win 11 Pro x64, 1Tb Primary SSD, 1Tb Secondary SSD
64Gb RAM Intel(R) Xeon(R) W-11855M CPU @ 3.2GHz
NVIDIA RTX A5000 16Gb, Dual 27" Monitor, Dell Inspiron 7760
Message 16 of 21

Anonymous
Not applicable

what are the values to add to the lips file for pulling the rest of the surface info?

0 Likes
Message 17 of 21

tcorey
Mentor
Mentor

There are many:

 

(setq name (vlax-get-property srf 'DisplayName))
  (setq desc (vlax-get-property srf 'Description))
  (setq Lyr (vlax-get-property srf 'Layer))
  (setq Sty (vlax-get-property srf 'Style))
  (setq StyName (vlax-get-property srf 'StyleName))
  (setq defProps (vlax-get-property srf 'DefinitionProperties))


;Surface statistics:
(setq stats (vlax-get-property srf 'Statistics))
  (setq Basesurf (vlax-get stats 'BottomSurface)
 Compsurf (vlax-get stats 'TopSurface)  
 cutvol (vlax-get stats 'CutVolume)
 fillvol (vlax-get stats 'FillVolume)
 netvol (vlax-get stats 'NetVolume)
 MaxCutDepth (vlax-get stats 'MaxElevation)
 MaxFillDepth (vlax-get stats 'MinElevation)
 MeanDepth (vlax-get stats 'MeanElevation)
 NoPts (vlax-get stats 'NumberOfPoints)
 NoTris (vlax-get stats 'NumberofTriangles) 
 )

Check your surface object for more properties: (vlax-dump-object surf t)

 

 



Tim Corey
MicroCAD Training and Consulting, Inc.
Redding, CA
Autodesk Platinum Reseller

New knowledge is the most valuable commodity on earth. -- Kurt Vonnegut
0 Likes
Message 18 of 21

cyr_j
Explorer
Explorer

I've tried the routine in this post, as well as adding (vlax-dump-object surf t) as mentioned in this post to dump all of the objects for my surface. I'm looking to get the cut factor and fill factor so I can ensure the values show the correct volumes. We always have a fill factor with our volume surfaces and this doesn't show with the standard data. 

 

How would I go about looking for these values. This routine is an awesome addition to our toolbox, but I need to show the adjusted volumes.

 

Any help would be appreciated.

 

Thanks!

 

Jason

0 Likes
Message 19 of 21

jmeltonXXLFJ
Community Visitor
Community Visitor

I know this is far after the fact, but when I attempt to load this script into Civil3d using VS Code there seems to be an error. The command prompt just reads "unknown command". When I load it through VLIDE it works though. I'm not familiar with VLIDE and am wondering if there are additional steps I need to take to get this to work using VS Code. Does anyone have any insight? 

 

Thanks

0 Likes
Message 20 of 21

gros33
Advocate
Advocate

Thanks @Anonymous and @tcorey!

I know this one is turning into an oldie, but it's still a goodie 🙂

I took the liberty of amedning this one slightly from Peter's last iteration, and included some reporting back whenever there's no surface, or no volume surface in the drawing.

Thanks again, realy useful lisp