Results 1 to 4 of 4

Thread: Help Adding a divider to Lisp Routine

  1. #1
    Member jekstein's Avatar
    Join Date
    2000-12
    Location
    Taylorsville, Utah
    Posts
    26
    Login to Give a bone
    0

    Default Help Adding a divider to Lisp Routine

    I would like this lisp routine to automatically divide by 12 (currently it gives me a length in inches so i have to convert it to feet then to architectural) I would like it to do this automatically. I did not write it I dont know much about LISP

    HELP!!

    THank you,
    Attached Files Attached Files

  2. #2
    AUGI Addict
    Join Date
    2005-08
    Posts
    1,043
    Login to Give a bone
    0

    Default Re: Help Adding a divider to Lisp Routine

    Change this line
    Code:
      (prin1 (read (rtos EntityLengths 2 2)))
    to
    Code:
      (prin1 (read (rtos EntityLengths 4 2)))

  3. #3
    All AUGI, all the time CAB2k's Avatar
    Join Date
    2016-01
    Location
    Brandon, Florida
    Posts
    687
    Login to Give a bone
    0

    Default Re: Help Adding a divider to Lisp Routine

    Here is another play toy.
    Code:
    ;;;=======================[ LengthByLayer.lsp ]=========================
    ;;; Author: Copyright© 2007 Charles Alan Butler 
    ;;; Version:  1.0 Dec. 26, 2007
    ;;; Purpose: display the length of objects on layer(s)
    ;;; Object Types allowed are LINE LWPOLYLINE POLYLINE SPLINE ARC CIRCLE
    ;;; Returns: -NA  
    ;;;==============================================================
    
    (defun c:LBL()(c:LengthByLayer))
    (defun c:LengthByLayer (/ cur_opt entlst ent_allowed filter layfilter len
                            mode ss tmp total_len txt_opt typ OutStr)
      (vl-load-com)
      ;|
         mode 
       An integer specifying the linear units mode. The mode corresponds to the
         values allowed for the AutoCAD system variable lunits and can be one of
         the following numbers:
       1  Scientific
       2  Decimal
       3  Engineering (feet and decimal inches)
       4  Architectural (feet and fractional inches)
       5  Fractional
       nil  default to DWG settings
      |;
      (setq mode 4)
      
      (defun put_txt (txt / pt th)
        ;;  Check if the drawing height is set to 0: 
        (if (setq pt (getpoint "\nPick Text Location..."))
         (progn
          (if (= 0 (setq th (cdr (assoc 40 (tblsearch "style"  (getvar "textstyle"))))))
            (setq th (getvar "textsize"))
          )
          (entmake (list (cons 0 "TEXT")
                   (cons 1 txt)
                   (cons 7 (getvar "textstyle"))
                   (cons 10 pt)
                   (cons 40 th)
          ))
         )
          (prompt "\n***  Text Insert skipped  ***")
        )
      )
    
      (initget "Yes No" )
      (setq txt_opt (getkword "\nPut text total in drawing [Yes/No]. <No>"))
      (or txt_opt (setq txt_opt "No"))
    
      (initget "Yes No" )
      (setq cur_opt (getkword "\nCurrent Space Only? [Yes/No] No for entire DWG. <Yes>"))
      (or cur_opt (setq cur_opt "Yes"))
    
      (prompt "\nSelect object(s) for layer filter.")
      (if (setq ss (ssget))
        (progn
          (setq tmp (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))
                tmp (mapcar '(lambda(x) (cdr(assoc 8 (entget x)))) tmp)
                layFilter "")
          (mapcar '(lambda(x) (setq layFilter (strcat x "," layFilter))) tmp)
          (setq ent_allowed '("LINE" "LWPOLYLINE" "POLYLINE" "SPLINE" "ARC" "CIRCLE"))
          (setq Filter (list '(0 . "LINE,LWPOLYLINE,POLYLINE,SPLINE,ARC,CIRCLE") (cons 8 layFilter)))
          (if (= cur_opt "Yes")
            (setq Filter (cons (cons 410 (getvar "ctab")) Filter))
          )
          (if (setq ss (ssget "_X" Filter))
            (progn
              (setq entlst (mapcar 'cadr (ssnamex ss))
                    total_len 0)
              (foreach en entlst
                (if (vl-position (setq typ (cdr (assoc 0 (entget en)))) ent_allowed)
                  (setq len (vlax-curve-getdistatparam en (vlax-curve-getendparam en))
                        total_len (+ len total_len))
                )
              )
            )
            (prompt "\n***  Nothing on that layer with a length.  ***")
          )
        )
      )
      (and total_len (not (zerop total_len))
           (setq OutStr (strcat "Total length is " (if mode (rtos total_len mode)(rtos total_len))))
           (princ (strcat "\n" OutStr)) ; display on command line
           (if (= txt_opt "Yes") (put_txt OutStr))
      )
      (princ)
    )
    (prompt "\nGet Length By Layer loaded, Enter LBL to run")
    (princ)
    Last edited by CAB2k; 2007-12-27 at 03:29 AM.

  4. #4
    Member jekstein's Avatar
    Join Date
    2000-12
    Location
    Taylorsville, Utah
    Posts
    26
    Login to Give a bone
    0

    Default Re: Help Adding a divider to Lisp Routine

    You guys/girls are awesome thanks a million!

Similar Threads

  1. 2013: LISP Routine for adding Coords / Leader / Northing + Easting to Drawing
    By Wayne.Tappe in forum AutoCAD General
    Replies: 1
    Last Post: 2013-12-11, 02:10 PM
  2. Help with a lisp routine to add a 12" line to this routine
    By Orbytal.edge341183 in forum AutoLISP
    Replies: 3
    Last Post: 2012-11-14, 10:33 PM
  3. Replies: 9
    Last Post: 2012-01-21, 07:58 AM
  4. help adding to a LISP routine
    By james.126519 in forum AutoLISP
    Replies: 1
    Last Post: 2007-11-21, 08:06 PM
  5. Replies: 2
    Last Post: 2005-03-18, 09:05 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •