Do you have the Microsoft Visual Basic for Applications Module?

Registered forum members do not see this ad.
Hi
I am trying to use this report:
http://blog.civil3dreminders.com/2012/03/alignment-length-report.html
But these files seem to be for C3D 2011, and will not work with 2012. There is something at the end explaining what to do if you are using a diff version of C3D. I am just wondering if there is anyone that could adjust the files so it works in 2012? I am really not any good at VBA. Too confusing.
Cheers
Martin
Do you have the Microsoft Visual Basic for Applications Module?
“A narrow mind and a fat head invariably come on the same person” Zig Zigler
![]()

Yes, I downloaded and installed it.
Guys,
The author originally wrote the code in VBA.
The blog post linked above demonstrates how to accomplish a similar plug-in using VB.NET (hence the Visual Studio screenshots). The VBA module is not needed.
Actually, the plug-in works exactly as advertised... Just tested using Civil 3D 2012... I personally think it's more work than is necessary (using the Microsoft.Office.Interop.Excel Library, when writing to a simple CSV would work), but still, it works.
Last edited by BlackBox; 29th Aug 2012 at 07:37 pm.
"Potential has a shelf life." - Margaret Atwood
... Also, FWIW - I *believe* that since this was done via ActiveX COM API originally, that there's still a means to do this with Visual LISP (which also uses ActiveX COM API).
Look into the AeccXUiLand.AeccApplication Object:
Code:(vl-load-com) (defun c:C3dComApi (/ file) (if (setq file (findfile (strcat (vl-registry-read (strcat "HKEY_LOCAL_MACHINE\\" (if vlax-user-product-key ; If 2013 (vlax-user-product-key) ; Use 2013 function (vlax-product-key) ; Use legacy function ) ) "ACADLOCATION" ) "\\help\\civil_api_activex_reference.chm" ) ) ) (startapp "explorer" file) (prompt "\n** File not found ** ") ) (princ) )
"Potential has a shelf life." - Margaret Atwood
Here's a recent (albeit unrelated) example, see post #4:
http://www.theswamp.org/index.php?topic=42585.0
"Potential has a shelf life." - Margaret Atwood

When I try and run the program, it gives me this error:
alignerror.PNG
ct_net.cannot.find.file.png
... That's because the plug-in has a reference to the Microsoft.Office.Interop.Excel Library, and it (the dependent reference) cannot be found on your system. I'll see what I can do to provide an adaptation that does not have this dependency, and instead uses basic .CSV instead.
"Potential has a shelf life." - Margaret Atwood

Registered forum members do not see this ad.
I love it when something is simpler than I thought it would be... It seems that Autodesk was kind enough to expose the Alignment Object Properties to Visual LISP; no AeccXUiLand.AeccApplication Interface Object required for this task.
Enjoy!
Code:(vl-load-com) (defun c:ALR () (c:AlignmentsLengthReport)) (defun c:AlignmentsLengthReport (/ *error*) (princ "\rALIGNMENTSLENGTHREPORT ") (defun *error* (msg) (if file (close file) ) (if oShell (vlax-release-object oShell) ) (cond ((not msg)) ; Normal exit ((member msg '("Function cancelled" "quit / exit abort"))) ; <esc> or (quit) ((princ (strcat "\n** " msg " ** "))) ; Fatal error, display it ) (princ) ) ((lambda (acApp / ss oShell filePath file alignmentName alignmentLength) (if (and (setq ss (ssget "_x" '((0 . "AECC_ALIGNMENT")))) (setq oShell (vla-getinterfaceobject acApp "Shell.Application" ) ) (setq filePath (strcat (vl-filename-directory (vl-filename-mktemp) ) "\\Alignments Length Report_" (menucmd "M=$(edtime,$(getvar,date),YYYY-MO-DD)" ) ".csv" ) ) (princ "\nWorking, please wait... ") (princ) ) (progn (setq file (open filePath "w")) (write-line "Civil 3D Drawing:" file) (write-line (strcat (getvar 'dwgprefix) (getvar 'dwgname)) file ) (write-line "" file) (write-line "Alignment Name:,Length:" file) (vlax-for x (setq ss (vla-get-activeselectionset (vla-get-activedocument acApp))) (if (and (setq alignmentName (vlax-get x 'name)) (setq alignmentLength (rtos (vlax-get x 'length))) ) (write-line (strcat alignmentName "," alignmentLength) file) ) ) (vla-delete ss) (princ "Done.") (setq file (close file)) (vlax-invoke oShell 'open filePath) (*error* nil) ) (cond (ss (*error* "Error: Unable to create \"Shell.Application\" Object" ) ) ((*error* "No alignments found")) ) ) ) (vlax-get-acad-object) ) )
Last edited by BlackBox; 1st Sep 2012 at 09:21 pm.
"Potential has a shelf life." - Margaret Atwood
Bookmarks