bigmaz Posted August 29, 2012 Posted August 29, 2012 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 Quote
SLW210 Posted August 29, 2012 Posted August 29, 2012 Do you have the Microsoft Visual Basic for Applications Module? Quote
bigmaz Posted August 29, 2012 Author Posted August 29, 2012 Yes, I downloaded and installed it. Quote
BlackBox Posted August 29, 2012 Posted August 29, 2012 (edited) 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. 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. 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. Edited August 29, 2012 by BlackBox Quote
BlackBox Posted August 29, 2012 Posted August 29, 2012 ... 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: (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) ) Quote
BlackBox Posted August 29, 2012 Posted August 29, 2012 Here's a recent (albeit unrelated) example, see post #4: http://www.theswamp.org/index.php?topic=42585.0 Quote
bigmaz Posted August 30, 2012 Author Posted August 30, 2012 When I try and run the program, it gives me this error: Quote
BlackBox Posted August 30, 2012 Posted August 30, 2012 ... 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. Quote
bigmaz Posted August 30, 2012 Author Posted August 30, 2012 [ATTACH=CONFIG]36852[/ATTACH] ... 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. That would be fantastic, thank you very much for your help Quote
BlackBox Posted August 30, 2012 Posted August 30, 2012 (edited) 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! (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) ) ) Edited September 1, 2012 by BlackBox Quote
bigmaz Posted August 30, 2012 Author Posted August 30, 2012 I tried the lisp, but i get this error: Quote
bigmaz Posted August 30, 2012 Author Posted August 30, 2012 Must be something to do with my computer, maybe something not installed correctly? Quote
BlackBox Posted August 30, 2012 Posted August 30, 2012 I tried the lisp, but i get this error: Must be something to do with my computer, maybe something not installed correctly? My mistake ... I accidentally left one of my global variables in the code, which has been corrected here. Quote
bigmaz Posted August 30, 2012 Author Posted August 30, 2012 Great, thanks a lot, it seems to work. Just a daft question though, where does the output file get saved? I have tried looking in the path where the drawing is, but not there. Quote
BlackBox Posted August 30, 2012 Posted August 30, 2012 Great, thanks a lot, it seems to work. Just a daft question though, where does the output file get saved? I have tried looking in the path where the drawing is, but not there. The code I provided creates, then opens a temporary file, which you then have the option of saving or not. Quote
bigmaz Posted August 30, 2012 Author Posted August 30, 2012 Oh man, I knew it would be a daft question, didnt realise it started a new excel sheet in the background Thanks again mate, really kind of u to spend the time on this Quote
BlackBox Posted August 30, 2012 Posted August 30, 2012 Oh man, I knew it would be a daft question, didnt realise it started a new excel sheet in the background The code actually does not start Excel, at least not exactly.... The code uses the Shell.Application Object to open the file with your computer's default application for .CSV files. Basically, this means that someone with Excel installed (not version in particular) will have the file open in Excel, whereas someone without Excel may have the file open in Notepad. ... Just another great trick I learned from Lee ( Thanks again mate, really kind of u to spend the time on this No worries; Happy to help. Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.