SLW210 Posted Monday at 06:55 PM Posted Monday at 06:55 PM (edited) I don't know if there was ever another LISP/Program to do this type of get length at least I never found one, my original just did what I needed, I have since made it more generally useful (I hope). As per the drawing I will attach, I just need to get the length of the center between the inner and outer of the perimeter of guards, etc. to determine the unrolled length. Normally the guards are 3D and I create the profiles with SOLPROF which creates an anonymous block (I used to change these with UNANON) or sometimes in the past I have used SOLVIEW and SOLDRAW, the same issue arises that you just can't select them and get the profile length. So originally that's what this LISP was created to do (I still have some of the older basic versions). I have upgraded it to it's current state and also still working on another version, but only small enhancements. For inside a block that is scaled, you will need to multiply the results by the scale factor, working through a viewport the viewport needs to be active, so I might tackle those issues as well as make a more detailed CSV. I also will try to make sure it works in non-AutoCAD like BricsCAD, CMS IntelliCAD, nanoCAD, etc. when I get time. I lightly tested in most situations, I have no idea how it acts on non-uniformly scaled blocks, though. It handles gaps and slight overlaps, I have some settings at the top, hopefully with enough instructions to modify on your own. Where I work (except for the machine shop which uses decimal inches) they use Architectural units, I did not double check this in Metric, so if someone would report back on that it would help. GetLenTest.dwg Edited yesterday at 01:42 PM by SLW210 Remove Old LISP, new one coming soon! 1 Quote
BIGAL Posted Tuesday at 12:17 AM Posted Tuesday at 12:17 AM @SLW210 did a little bit of testing and works ok in Metric dwt. The only thing is the Architectural result. Limited Testing in Bricscad V25. made some shapes and inserted some blocks. A rectang 5000x4000 mm or decimal units. For metric don't need Architectural units. Curve length: 18000 Gaps: 0 Total: 18000 Architectural: 1500'-0" ?? For metric could do dwg is in mm but result is in metres to 3 decimals. You could use the Multi radio buttons.lsp to make choices. As its demand loaded you do not have to add it to your code. Re CSV your more than welcome to use the defuns in Alan Excel.lsp to write direct to Excel. Could demand load a lisp with just the defuns needed as don't need all that is in the lisp. Just a Ps a big file to screen copy maybe also post a file copy. 1 Quote
SLW210 Posted Tuesday at 10:41 AM Author Posted Tuesday at 10:41 AM Somebody else can add the Multi, it works great for my job right now. I do not want direct to Excel as I plan to use LibreOffice when away from work, in the beginning of updating I had thoughts of making it an option, that is still on the table. I may remove the code and just paste the file, so at least a sign-in is required. As for a long code to copy, just double-click the first character then shift-click the end. As for the Architectural: 1500'-0", you didn't change the values in the code to convert to mm, I put them at the top. Quote PROFILE 1 ================================ Block scale: 1.00000000 Objects traced: 1 LWPOLYLINE Handle=275 Length=18000.000000 -------------------------------- Curve length: 18000.000000 Gaps: 0.000000 Total: 18000.000000 Architectural: 59'-5/8" ================================ I need to do a few changes on that output when metric, I'll see if the next version was already doing that. That's the reason I posted this version, to see what I didn't think of before the final version. I think I started the next version to include a DCL to switch instead of commandline as well as the report, as well as multiple selections and more columns in CSV. Is there a big need for meters in something like this? I know in the USA sheet metal is normally Metric in mm and Imperial is inches, sometimes on certain things they use Meters and Architectural, but I have seldom seen that. I do need to add the inches option as well, so Meters should be an option I suppose. I need to do more gap and overlap testing, most of my actual job is actually ends touching, I just needed to get them through a Viewport and in an anonymous block (I used to need to change to a regular block, then go to block editor, etc.), SOLPROF is lines and arcs, etc. so a lot of work . I'll finish up my work work and see if I have time to work on this some more. Thanks for the Metric test and BricsCAD test. If any GstarCAD, NanoCAD, CMS IntelliCAD users could test, that would be nice. I go over their sites and see if I can see what users report working and not working, but that probably doesn't cover everything or account for those that just made an error using the code. For USA that use both Metric and Imperial, would reporting both be beneficial? That might yet again be more options needed. P.S. My 3 grandkids from near me in Florida are now in Australia until the End of October, so last night my time they Facetimed me, so I got very little done at home. Quote
BIGAL Posted Tuesday at 11:10 PM Posted Tuesday at 11:10 PM (edited) Yes outputting results as both may be the simplest way. Re make a dcl, I use say multi radio buttons.lsp as it only needs 3 lines of code to work, you comment out the vla-deletefile, so the dcl code remains, I then use the RLX convert dcl to lisp so paste the converted code into my programs, using the multi just saves typing to make the source dcl. Just another comment, I have a make a radio button dcl from a dwg. RLX was looking into doing similar. I have code also for Libreoffice Calc reading and writing plus more. Happy to post. Opening is not as straight forward as Excel. Where are the grand kids ? I am north of Sydney. Convert dcl 2 lisp rlx.lsp Edited Tuesday at 11:12 PM by BIGAL 1 Quote
SLW210 Posted Wednesday at 11:14 AM Author Posted Wednesday at 11:14 AM I have all of that from you and @rlx, thanks though, I have a DCL built for this already, I made it a little fancy with the options, I might go simpler though. I made some improvements to the Metric side. When I have time I'll get it cleaned up and on here. I was thinking about instead of the commandline having the results in a DCL on screen and put options to make the CSV, Excel, Print, etc., though that will be when I have time. I am not sure how many actually would have use of this, but I plan to get it finished hopefully this week, hopefully I can wrap up my CAD work and get back on this. My grandkids are in a small town 268 km (167 mi) NE of Melbourne just into New South Wales and a little ways west of Lake Hume and 457 km (284 mi) SW of Sydney. I hate the time difference, but not too bad, they wake up when I'm eating supper or going to bed, they are getting ready for bed when I am getting to work. Quote
SLW210 Posted Wednesday at 11:23 AM Author Posted Wednesday at 11:23 AM 12 hours ago, BIGAL said: I have code also for Libreoffice Calc reading and writing plus more. Happy to post. Opening is not as straight forward as Excel. Post that, I was working on some of that from the thread a while back, but do not remember how far I went. Quote
BIGAL Posted Wednesday at 11:55 PM Posted Wednesday at 11:55 PM Here is libreoffice code. Hopefully it is the correct one. Re display answers. The simplest is use Alert just add the "\n" in string for multi lines. Yes can do a dcl its made up of text paragraphs. And message boxes as last idea. (alert "This is line one\nline 2\nline 3") ;;;;;;;;;;;;;;;;;;;;; ; make text dcl from list ; By Alan H july 2026 (defun AHmakepara (lst / fo x dcl_id) (setq fo (open (setq fname (vl-filename-mktemp "" "" ".dcl")) "w")) (write-line "AHpara: dialog {" fo) (write-line (strcat " label = " (chr 34) "Current values" (chr 34) " ;") fo) (write-line " : column {" fo) (write-line " width =25;" fo) (write-line " : paragraph {" fo) (setq x 0) (repeat (length lst) (write-line " : text_part {" fo) (write-line (strcat "label = " (chr 34) (nth x lst) (chr 34) ";") fo) (setq x (1+ x)) (write-line " }" fo) ) (write-line " }" fo) (write-line "spacer_1 ;" fo) (write-line "ok_cancel ; }" fo) (write-line " }" fo) (close fo) (setq dcl_id (load_dialog fname)) (if (not (new_dialog "AHpara" dcl_id)) (exit) ) (action_tile "accept" "(setq ans 1)(done_dialog)") (action_tile "cancel" "(setq ans 2)(done_dialog)") (start_dialog) (unload_dialog dcl_id) (vl-file-delete fname) (princ ans) (princ) ) ; (if (not AHmakepara)(load "Multi para.lsp")) ; (setq lst (list "This is line 1 " "this is line 2" "line 3" "A big line 4 like this")) ; (AHmakepara lst) ;;;;;;;;;;;;;;;;;;;;;; ; this allows for a time so message closes. (defun MsgBox (title options message time / WshShell) (setq WshShell (vlax-create-object "WScript.Shell")) (vlax-invoke WshShell 'Run (strcat "mshta.exe vbscript:close(CreateObject(\"WScript.Shell\").Popup(\"" message "\"," (itoa time) ",\"" title "\"," (itoa options)"))" ) ) (vlax-release-object WshShell) ) (MsgBox "this is me" 0 "have a good day" 1) ; pretty sure can do multi line, using \n or \r ? libre2.lsp 1 Quote
SLW210 Posted yesterday at 01:41 PM Author Posted yesterday at 01:41 PM I have this almost finished, but currently have a separate DCL for it, looks to work very well for all units and recognizes the drawing units for Metric, Imperial by using Insertunits. I'll try to post next week, Tuesday or Wednesday if I get a chance to get it like I want it. I need to look into the option for MS Excel and LibreOffice Calc vs CSV I may or may not bother. So far... ;;; ============================================================ ;;; GetLen.lsp ;;; PROFILE / CENTERLINE LENGTH ;;; ;;; VERSION: 2026-09-03 ;;; ;;; Supports: ;;; LINE ;;; ARC ;;; CIRCLE ;;; LWPOLYLINE ;;; POLYLINE ;;; SPLINE ;;; ELLIPSE ;;; ;;; If PELLIPSE=1: ;;; Heavy Polyline (a.k.a. Old Style or 2D Polylines) made from bulged VERTEX records. ;;; These can be converted with CONVERTPOLY command, I chose to work with the Heavy Polylines. ;;; ;;; Supports: ;;; - Model Space ;;; - Paper Space ;;; - Blocks ;;; - Nested blocks ;;; - Anonymous/dynamic blocks (*U...) ;;; - Uniform block scaling ;;; - Single profile ;;; - Two-profile average / centerline ;;; - Batch (Sends output to CSV for perimeters of multiple selected entities.) ;;; - Screen output ;;; - CSV output ;;; - Multiple output unit formats ;;; * Metric - Millimeters ;;; * Metric - Meters ;;; * Architectural - Feet/Inches ;;; * Imperial - Fractional Inches ;;; * Imperial - Decimal Feet ;;; * Imperial - Decimal Inches ;;; - Automatic drawing-unit detection from INSUNITS ;;; - Endpoint tolerance ;;; - Optional gap measurement Quote
BIGAL Posted 12 hours ago Posted 12 hours ago For Excel direct the simplest is open a new Excel. You can open an existing excel by file name or even get current Excel Worksheet. You can then get say last row that contains something so that when you add more answers you know the row to start at. I would just make a simple lisp that has all the required defuns in it. Open a new Excel. Then write the row answers. with say a 1 row gap. As version 1. Yes version 2 Open new, use existing, open an existing file. The other defuns that could be added are stuff like color cell text and backgrounds. I called this little lisp "Alan open-read-write excel.lsp" ; Excel function using lisp ; By AlanH and inspiration from others ; Gilles ; JefferyPSanders.com ; Lee-mac ; MunteanStefan ; danielrodriguez ; code by the great FIXO no longer with us (defun Openexcel ( / ) (princ "\nOpening Excel...") ;; Try to get or create Excel instance (setq myxl (vl-catch-all-apply 'vlax-get-or-create-object '("Excel.Application"))) (if (vl-catch-all-error-p myxl) (progn (prompt "\nError: Could not start Excel.") (exit) ) ) (if (= (vlax-get-property (vlax-get-property myXL 'WorkBooks) 'count) 0) (vlax-invoke-method (vlax-get-property myXL 'WorkBooks) 'Add) ) (vla-put-visible myXL :vlax-true) (vlax-put-property myxl 'ScreenUpdating :vlax-true) (vlax-put-property myXL 'DisplayAlerts :vlax-true) (princ) ) ;; Thanks to fixo ;; ;; = Set Excel cell text = ;; (defun xlsetcelltext ( row column text) (setq cells (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Cells")) (vl-catch-all-apply 'vlax-put-property (list cells 'Item row column (vlax-make-variant (vl-princ-to-string text) vlax-vbstring))) ) ;; Thanks to fixo ;; get value of a cell (defun getcell2 (row column / ) (setq cells (vlax-get-property (vlax-get-property myxl "ActiveSheet") "Cells")) (setq cell (vlax-get (vlax-variant-value (vlax-get-property cells "Item" row column)) 'value)) ) A sample sequence. You could put all the code in your program. Maybe later will post something with a Excel option. (if (not openexcel)(load "alan open-read-write.lsp")) (openexcel) (xlsetcelltext 4 4 "Alan") (getcell2 4 4) @SLW210 Happy to do the CSV, Excel or Libreoffice code. Post updated code and dcl etc. 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.