At AU 2008 David Garigues presented a class "Caffeinated Grading" in which he used some VBA macros. The VBA code was shared as part of the class and posted the the now defunct CivilCommunity files section. Starting with C3D2010 the VBA DVB was included under the Samples folder in a typical C3D installation, but the code was not kept up to date. And with VBA being phased out, it seemed like the logical choice was to port the code to a .NET DLL.
As it turned out, Justin Ralston and I somehow managed to to be thinking the same thing, at about the same time. He chose to go the VB.NET route, and I chose C# as the program language. The 2 versions may be slightly different (I have not tested his code) but they should yield the same results.
And with that, I am attaching the complete VS2008 C# solutions, along with the Readme.txt, in a ZIP. Due to C3D not having a .NET managed API for Surfaces until 2012, the code uses the COM libraries. This means each version of C3D needs it's own version of this DLL. The code is included for all 3 versions of C3D 2010-2012.
There are likley better ways to do some of the things in this code using native .NET methods, but I decided to focus on just getting the code ported over with minimal changes to the original. I hope some of you find it useful, both the new commands and the example code.
Solved! Go to Solution.
Excellent - many thanks Jeff.....although a couple of comments....
1. I couldn't see the readme file in the zip
2. When using the commands and being prompted for the first point it isn't clear that it must be a "proper" point e.g. Civil Point (this may be in the readme though). Would it be a great hassle to modify the code such that for the first point the user can also pick any XY location and be prompted for the level (or surface from which to obtain the level)??
3. Presumably these commands can be added to a toolbar/pallete etc in the usual way??
1. The readme is iin the zip, at the root level:
2. I didn't include any instructions for the actual usage other than what was originally included with the VBA macro. To be honest, I have not used these commands much (in the VBA form or this new one) so am not real familiar with HOW they are supposed to be used. All pick points allow random picks, no need to select a C3D point (in fact, no provision is given for selecting a Point object so I'm not sure about this question...) As for adding the elevation prompt, I think you can just use te normal Autocad filters (.xy, then it prompts for the z), and the option is there to select from a surface (although I did not test this option as it was late, is this not working? I won't be able to test myself until this evening.)
3. Yes, these are new commands added to the Command pool, once the DLL is loaded, so they may be used as any other C3D command.
Thanks for the reply:
1. I just unzipped the zip and couldn't find the readme as it was in the root - but ok now and the commands make more sense after reading it..
2. I had forgotten about using the .XY filter, this does indeed allow a Z to be entered. If a C3D point is selected then the level is obtained from the point. The Surface level option also works fine..
3. By putting the DLL in the support path, I assume it gets loaded every session so I can create a toolbar button with for example, ^C^CWORKINGPLANE2POINT as the command macro??
I hvae been using these routines today and they are working well and saving me quite a bit of time..
3. No, the DLL still needs to be loaded when C3D starts, or when the command is invoked. Here is a detailed explantion of how to do this in the registry.Link to Kean's blog Alternatively, you could have it load at startup by adding a line to your acad.lsp file. But once loaded, then the macro you show will work.
I'm not to keen on modifying the Registry - what is the syntax for modifying acad.lsp (and where is acad.lsp usually located)?
acad.lsp is placed in any one of the support folders listed under Options->Files->Support File Search Path. I prefer to add my own folder to the top of the list, this way it is always seperate from C3D's install and it can be used with multiple installs if desired.
acad.lsp is just a text file, edited with any text editor such as Notepad. If one doesn't exist (C3D does not ship with one, this is a user customization file) just create it. To load .NET dll's, add the following code:
(defun S : Startup() ;;remove the spaces before and after the colon (command "netload" "filetoload.dll") ;;one line for each dll )
Note, I believe the lisp shown should work, but I use the Registry method so I have not tested this. A Google search should be able to help if this doesn't do it for you.
Many thanks - will give it a try
Too funny! I came up here to ask something today and what do I see.... PLANE GRADING!!! I have to tell you I use this command a lot. I wanted to give everyone our updated one that has been modified/converted to work still in VBA (2011). I too had to make a slight modification because we wanted our users to know if they picked a 0 elevation first we give them a little alert box notifying them.
Funny stuff... the actual creator of this was the Chris Putnam who created this on his sabbatical (the guy is truly committed and we love him very much!)
I am thrilled it has been converted to .Net and C# thanks you guys so so much I think we will probably dump the one we are posting here and pick up the new better stuff :-)
It's a tool I've been needing since C3D 2011 and someone had blogged about the AU caffeinated grading paper and it went from there....
Jeff has done a supreme job (as usual)
Log into access your profile, ask and answer questions, share ideas and more. Haven't signed up yet? Register
Start with some of our most frequented solutions to get help installing your software.