Jump to content

Lines Auto Dimensioning


Fire Alarm

Recommended Posts

I have looked for a lisp routine or command, for having the lines that I draw automatically show their lenght. I do not know how lisp routines work. I am currently studying them, but cannot figure out how to create one. Any help would be greatly appreciated. It would help me save time when I try to figure out voltage drop calculations for my notification circuits.

 

Thanks :?

Link to comment
Share on other sites

  • Replies 37
  • Created
  • Last Reply

Top Posters In This Topic

  • Lee Mac

    14

  • Fire Alarm

    12

  • chelsea1307

    4

  • scwoo

    3

Do you mean get an proper dimension as soon as you have completed the line? That would be tricky, but probably not impossible.

 

If you mean see the lenght of the line while you are drawing it, you can turn on Dynamic Input (click the DYN button at the bottom of the screen) - right-click on the DYN-button to get to Settings for it and set it up as you want it.

Link to comment
Share on other sites

What I usually do is draw a pline from device to device and then select the line and go to properties to see the length. I would like to see the lenght of the line once it is drawn. Not while I am drawing it.

Link to comment
Share on other sites

You want to figure it alone? a few tips if yes, you can take 2 points, do the pline command and then, add this

 

(command "dist" p1 p2);if p1 and p2 is the points.
(princ)
(setq di (getvar "Distance"))

 

This will show the distance from points.

Link to comment
Share on other sites

when you draw you line is it a line or pline?

is it always straight or is the curves involved?

is it from point a to point b or many points?

do you want a autocad dimension or just a text with the length?

Link to comment
Share on other sites

when you draw you line is it a line or pline?

is it always straight or is the curves involved?

is it from point a to point b or many points?

do you want a autocad dimension or just a text with the length?

JohnM

1) They are plines

2 & 3) there are 90 deg turns (I try not to go point to point so I have a distance safety factor)

4) just show text length is fine

 

BlackAlnet

Don't know enough to do alone.

 

Thanks

Link to comment
Share on other sites

lee mac wrote me a lisp a while back that after the plines are drawn you start the lisp and select your pline and the text is placed next to it, would that get you closer to what you want?

Link to comment
Share on other sites

Something like this?

 

(defun c:leng (/ ent Obj)
 (vl-load-com)
 (while
   (progn
     (setq ent (car (entsel "\nSelect Object: ")))
     (cond ((eq 'ENAME (type ent))
            (setq Obj (vlax-ename->vla-object ent))
            (if (vlax-property-available-p Obj 'length)
              (not (print (vla-get-length Obj)))
              (princ "\n** Invalid Object Selected **")))
           (t (princ "\n** Nothing Selected **")))))
 (princ))

Link to comment
Share on other sites

lee mac wrote me a lisp a while back that after the plines are drawn you start the lisp and select your pline and the text is placed next to it, would that get you closer to what you want?

 

This one I believe:

http://www.cadtutor.net/forum/showthread.php?t=36659

 

:D:D

Link to comment
Share on other sites

Thank you for the replies. Before I try this, one question. Here is my one big headache that I cannot figure out with lisps. Am I to open up notepad, paste the text, save as a .lsp file, then load the lisp. Correct? Then up the "leng" as the command? :?

Link to comment
Share on other sites

yup save the file as a .lsp then you can use appload to load it. Then type leng at the command line and you should be all good

Link to comment
Share on other sites

Here's an upgrade for it :P

 

;; ============ pLen.lsp ===============
;;
;;  FUNCTION:
;;  Will Display the Length of a
;;  Line or Polyline upon selection.
;;
;;  SYNTAX: pLen
;;
;;  AUTHOR:
;;  Copyright (c) 2009, Lee McDonnell
;;  (Contact Lee Mac, CADTutor.net)
;;
;;
;;  VERSION:
;;  1.0  ~  30.06.2009
;;
;; ====================================


(defun c:pLen (/ *error* doc spc ent cObj tStr tSze
                tBox wBse gr cPt pt cAng lAng)
 (vl-load-com)

 (defun *error* (msg)
   (and tObj
     (not
       (vlax-erased-p tObj))
         (vla-delete tObj))
   (if
     (not
       (wcmatch
         (strcase msg) "*BREAK,*CANCEL*,*EXIT*"))
     (princ
       (strcat
         "\n<< Error: " msg " >>")))
   (princ))

  (if
    (eq 4
      (logand 4
        (cdr (assoc 70
               (tblsearch "LAYER"
                 (getvar "CLAYER"))))))
   (progn
     (princ "\n<< Current Layer Locked >>") (exit)))

 (setq doc (vla-get-ActiveDocument
             (vlax-get-Acad-Object))
       spc (if
             (zerop
               (vla-get-activespace doc))
             (if (= (vla-get-mspace doc) :vlax-true)
               (vla-get-modelspace doc)
               (vla-get-paperspace doc))
             (vla-get-modelspace doc)))
 
 (while
   (progn
     (setq ent
       (car (entsel "\nSelect Object: ")))
     (cond
       ((eq 'ENAME (type ent))
        (setq cObj (vlax-ename->vla-object ent))
        (if (vlax-property-available-p cObj 'length)
          (not
            (print
              (setq tStr
                (vl-princ-to-string
                  (vla-get-length cObj)))))
          (princ "\n** Invalid Object Selected **")))
       (t (princ "\n** Nothing Selected **")))))

 (or *Mac$Per*  (setq *Mac$Per* (/ pi 2.)))
 (or *Mac$tOff* (setq *Mac$tOff* 1.))
 (or tSze (setq tSze (getvar "TEXTSIZE")))

 (setq tBox (textbox
              (list
                (cons 1 (strcat tStr ".."))
                (cons 40 tSze)
                (cons 7 (getvar "TEXTSTYLE"))))
       wBse (textbox
              (list
                (cons 1 ".")
                (cons 40 tSze)
                (cons 7 (getvar "TEXTSTYLE"))))
       wBse (- (caadr wBse) (caar wBse)))
           
       (vla-put-attachmentpoint
         (setq tObj
           (vla-addMText spc
             (vlax-3D-point '(0 0 0))
               (setq tWid (- (caadr tBox) (caar tBox))) tStr))
         acAttachmentPointMiddleCenter)
     (vla-put-Height tObj tSze)
     (princ "\n<< Type [+] or [-] for offset, [P]er & [<] or [>] for MText Width  >>")

     ;; Place Text
           
     (while
       (or
         (and
           (setq gr (grread t 15 0))
             (eq (car gr) 5))
         (and
           (eq 2 (car gr))
           (vl-position (cadr gr)
             '(43 ; +
               45 ; -
               61 ; + (as =)
               80 112  ; P/p
               60 62 44 46)))) ; < > , .
       
       (cond ((and (eq 5 (car gr)) (listp (setq cPt (cadr gr))))
              (setq pt (vlax-curve-getClosestPointto cObj cPt)
                    cAng (angle pt cPt)
                    lAng (+ cAng *Mac$Per*))
              
              (cond ((and (> lAng (/ pi 2)) (<= lAng pi))
                     (setq lAng (- lAng pi)))
                    ((and (> lAng pi) (<= lAng (/ (* 3 pi) 2)))
                     (setq lAng (+ lAng pi))))
              
              (vla-move tObj
                (vla-get-InsertionPoint tObj)
                  (vlax-3D-point
                    (polar pt cAng (* tSze *Mac$tOff*))))
              (vla-put-Rotation tObj lAng))

             ((eq 2 (car gr))
              (cond ((vl-position (cadr gr) '(43 61))
                     (setq *Mac$tOff*
                       (+ (/ 1 10.) *Mac$tOff*)))
                    ((eq (cadr gr) 45)
                     (setq *Mac$tOff*
                       (-  *Mac$tOff* (/ 1 10.))))
                    ((vl-position (cadr gr) '(80 112))
                     (setq *Mac$Per* (- (/ pi 2.) *Mac$Per*)))
                    ((vl-position (cadr gr) '(60 44))
                     (if (> (- (vla-get-Width tObj) wBse) 0)
                       (vla-put-Width tObj
                         (- (vla-get-Width tObj) wBse))))
                    ((vl-position (cadr gr) '(62 46))
                     (vla-put-Width tObj
                       (+ (vla-get-Width tObj) wBse)))))))
 (princ))

(princ
 (strcat "\nCurve Length by Lee McDonnell " (chr 169) " June 2009."
         "\n         Type \"PLEN\" to Invoke"))
(princ)
             

Link to comment
Share on other sites

That is what I thought, however, when I save it with notepad I can only save as a .txt file. After I do that I change the extenion from a .txt for a .lsp, then it loads find, but the leng command does not work.

Link to comment
Share on other sites

That is what I thought, however, when I save it with notepad I can only save as a .txt file. After I do that I change the extenion from a .txt for a .lsp, then it loads find, but the leng command does not work.

 

Make sure that the "Save as type" box is set to "All Files".

 

You can also load LISP files in the Visual LISP Editor provided with AutoCAD, type VLIDE at the command line.

Link to comment
Share on other sites

after you set saveas type to all type*.lsp in for the file name and all lsp files in the location you are saving will now show and you can replace the * with the name you want to save as

Link to comment
Share on other sites

It worked when I used vlide, but how can I get the text to show in feet? Does the lisp need to have some kind of dimension or distance command in it?

Link to comment
Share on other sites

It worked when I used vlide, but how can I get the text to show in feet? Does the lisp need to have some kind of dimension or distance command in it?

 

Which LISP are you using?

Link to comment
Share on other sites

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...