+ Reply to Thread
Page 1 of 2 1 2 LastLast
Results 1 to 10 of 17
  1. #1
    Full Member emwhite's Avatar
    Computer Details
    emwhite's Computer Details
    Operating System:
    Win 7 Pro
    Computer:
    Lenovo w510
    CPU:
    Intel® Core™ i7-720QM (1.60GHz base; 2.80GHz Max Turbo, 6MB Cache)
    RAM:
    8GB (2 X 4GB) PC3-10600 DDR3 1333MHz
    Graphics:
    NVIDIA® Quadro® FX 880M
    Primary Storage:
    Intel 160gb SSD, Windows Home Server 5TB+
    Discipline
    Structural
    emwhite's Discipline Details
    Occupation
    Sales Support/CAD Monkey
    Discipline
    Structural
    Details
    Light gauge framing of homes.
    Using
    AutoCAD 2010
    Join Date
    Feb 2011
    Location
    Dallas, TX
    Posts
    74

    Default Lisp routine to measure line and add length to existing text

    Registered forum members do not see this ad.

    Hi all, I'm new to this forum and know very little about programming lisp routines. I usually just come across ones every now and then and add them to my installation of AutoCAD.

    I was looking for a Lisp routine that would be able to measure a 2d line of my choosing, then for it to prompt me to choose an existing text to add the length of the line to the text.

    So basically I have a wall outline with the wall number above it. I would like to be able to click a line of the wall to measure it. Then be prompted to click on a multi line or single line text to add the length to the end of the text with spaces and equal sign separating the two. Hopefully be able to keep in feet & inches as shown below or based on what the drawing Units are set to?


    Sample (Please don't laugh too much at my text drawing skills ):

    Wall 1
    ______________________________
    |_____________________________|


    Wall 1 = 5' 3 1/2"
    ______________________________
    |_____________________________|

    So the top is the before and the bottom is the after.

    If someone knows of a routine that can do this and can point me to it, that would be awesome!

    If not, would this be overly complicated for a beginner to attempt to code? I just need some guidance on how to begin. Or someone could code it for me?

    Thanks for any and all help!

    -Evan
    Last edited by emwhite; 8th Feb 2011 at 11:06 pm. Reason: Oops, copy & paste removal

  2. #2
    Quantum Mechanic ReMark's Avatar
    Computer Details
    ReMark's Computer Details
    Operating System:
    Windows 7 Pro 64-bit
    Computer:
    Thinkmate
    Motherboard:
    Intel DX58SO2 LGA1366 X58
    CPU:
    Intel i7-960 Quad-core 3.20GHz 8MB cache
    RAM:
    12GB (3x4GB) PC3-106000 DDR3
    Graphics:
    nVidia Quadro 4000, 2GB GDDR5
    Primary Storage:
    150GB Velocipraptor 10,000 rpm
    Secondary Storage:
    none
    Monitor:
    Dell P24LLH - 24" wide screen LCD
    Discipline
    See details...
    ReMark's Discipline Details
    Occupation
    CAD Draftsman/Designer...chemical manufacturing.
    Discipline
    See details below.
    Details
    I work for a specialty chemical manufacturer. I do a little bit of everything from P&IDs to civil to architectural and structural.
    Using
    AutoCAD 2013
    Join Date
    Nov 2005
    Location
    Norwalk, CT USofA
    Posts
    33,137

    Default

    There are already lisp routines that will measure the length of a line and put that measurement above the line. The only thing you would have to add is the wall number. I think forum member Lee Mac and/or alanjt posted lisp routines that you could study and use as a basis for your new routine.
    "I have only come here seeking knowledge. Things they wouldn't teach me of in college." The Police

    Eat brains...gain more knowledge!

  3. #3
    Luminous Being alanjt's Avatar
    Using
    Civil 3D 2011
    Join Date
    Apr 2008
    Posts
    6,015

    Default

    Both Lee and I have posted similar routines, but why not just use a Dimension with a prefix?
    DropBox | finding the light...
    Seann: ...it went crazy ex-girlfriend on me...
    eric_monceaux...its pretty funny seeing two AutoCAD Gods give each other flak...

  4. #4
    Full Member emwhite's Avatar
    Computer Details
    emwhite's Computer Details
    Operating System:
    Win 7 Pro
    Computer:
    Lenovo w510
    CPU:
    Intel® Core™ i7-720QM (1.60GHz base; 2.80GHz Max Turbo, 6MB Cache)
    RAM:
    8GB (2 X 4GB) PC3-10600 DDR3 1333MHz
    Graphics:
    NVIDIA® Quadro® FX 880M
    Primary Storage:
    Intel 160gb SSD, Windows Home Server 5TB+
    Discipline
    Structural
    emwhite's Discipline Details
    Occupation
    Sales Support/CAD Monkey
    Discipline
    Structural
    Details
    Light gauge framing of homes.
    Using
    AutoCAD 2010
    Join Date
    Feb 2011
    Location
    Dallas, TX
    Posts
    74

    Default

    Quote Originally Posted by ReMark View Post
    There are already lisp routines that will measure the length of a line and put that measurement above the line. The only thing you would have to add is the wall number. I think forum member Lee Mac and/or alanjt posted lisp routines that you could study and use as a basis for your new routine.
    That is the routine that brought me here but it's not 100% what I would like to do. I was browsing through the code but it appeared way over my head. This is the thread that brought me here:
    http://www.cadtutor.net/forum/showth...-labeling-them

  5. #5
    Full Member emwhite's Avatar
    Computer Details
    emwhite's Computer Details
    Operating System:
    Win 7 Pro
    Computer:
    Lenovo w510
    CPU:
    Intel® Core™ i7-720QM (1.60GHz base; 2.80GHz Max Turbo, 6MB Cache)
    RAM:
    8GB (2 X 4GB) PC3-10600 DDR3 1333MHz
    Graphics:
    NVIDIA® Quadro® FX 880M
    Primary Storage:
    Intel 160gb SSD, Windows Home Server 5TB+
    Discipline
    Structural
    emwhite's Discipline Details
    Occupation
    Sales Support/CAD Monkey
    Discipline
    Structural
    Details
    Light gauge framing of homes.
    Using
    AutoCAD 2010
    Join Date
    Feb 2011
    Location
    Dallas, TX
    Posts
    74

    Default

    Quote Originally Posted by alanjt View Post
    Both Lee and I have posted similar routines, but why not just use a Dimension with a prefix?
    The builder I am working with wants a separate layout with no dimensions, just text above the walls with the length of the wall with the text. I'm trying to make it as easy as possible on me to suffice the builder.

  6. #6
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    Set your dims as per Alanjt you can turn off all the line work so only text appears, exploding dims turns it to plain text.

    Did you have a look at those lisp routines suggested they may label lots of line in one go, I would then run an alternative lisp that added the wall label so you can pick manually the wall number sequence.

    A bit further ahead when you draw lines and then pick a whole bunch at one time they are in the drawn order so if you could regiment your self then you could do what you want in one go automatically labelling the walls in the drawn order. I would probably write two routines (in one program) manual or automatic.

  7. #7
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,791

    Default

    Your lucky day added about 5 lines to this code and now it works if want other changes then probably a good time to learn how to write/change a program. This will work as per my post above either auto pick or manual thanks Lee

    Code:
    : original program by lee mac
    ; Room and number added by Alan H FEB 2011
    (princ "\nTo run type plen3")
     
    (defun c:pLen3 (/ *error* doc spc ss mid tStr tBox tObj lAng)
      (vl-load-com)
      (defun *error* (msg)
        (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 (not ss)
        (setq ss (ssget '((0 . "*LINE")))))
      (setq tSze (getvar "DIMTXT"))
    (setq x 1)
      (foreach Obj
        (mapcar 'vlax-ename->vla-object
          (vl-remove-if 'listp
            (mapcar 'cadr (ssnamex ss))))
        (setq tStr (rtos (vla-get-length Obj) 3 2)
              tBox (textbox
                     (list
                       (cons 1 (strcat "room" tStr ".."))
                       (cons 40 tSze)
                       (cons 7 (getvar "TEXTSTYLE")))))
        (setq mid (/ (abs (- (vlax-curve-getEndParam Obj)
                               (vlax-curve-getStartParam Obj))) 2.)
              lAng (angle '(0 0 0) (vlax-curve-getFirstDeriv Obj mid)))
        (cond ((and (> lAng (/ pi 2)) (<= lAng pi))
           (setq lAng (- lAng pi)))
          ((and (> lAng pi) (<= lAng (/ (* 3 pi) 2)))
           (setq lAng (+ lAng pi))))
    (setq rnum (rtos X 2 0))
    (setq tstr (strcat "ROOM" rnum  tStr))
          (setq tObj
            (vla-addMText spc
              (vlax-3D-point (vlax-curve-getPointatParam Obj mid))
                (- (caadr tBox) (caar tBox)) tStr))
        (vla-put-Height tObj tSze)
        (vla-put-Rotation tObj lAng)
    (setq x (+ x 1)) 
    )
      (princ)
    )

  8. #8
    Full Member emwhite's Avatar
    Computer Details
    emwhite's Computer Details
    Operating System:
    Win 7 Pro
    Computer:
    Lenovo w510
    CPU:
    Intel® Core™ i7-720QM (1.60GHz base; 2.80GHz Max Turbo, 6MB Cache)
    RAM:
    8GB (2 X 4GB) PC3-10600 DDR3 1333MHz
    Graphics:
    NVIDIA® Quadro® FX 880M
    Primary Storage:
    Intel 160gb SSD, Windows Home Server 5TB+
    Discipline
    Structural
    emwhite's Discipline Details
    Occupation
    Sales Support/CAD Monkey
    Discipline
    Structural
    Details
    Light gauge framing of homes.
    Using
    AutoCAD 2010
    Join Date
    Feb 2011
    Location
    Dallas, TX
    Posts
    74

    Default

    Sorry for the delay in getting back to you guys. Both Kaspersky AV and Google were blocking the page. The last time I was on here, Kaspersky said a virus was blocked from this site. I assume malware in an advertisement was to blame?

    Quote Originally Posted by alanjt View Post
    Both Lee and I have posted similar routines, but why not just use a Dimension with a prefix?
    Thank you, I used your idea of adding a dimension with a prefix of " = " (no quotes but spaces). Then I copied the text from the wall label and edited the dimension to add the copied text.

    Quote Originally Posted by BIGAL View Post
    Set your dims as per Alanjt you can turn off all the line work so only text appears, exploding dims turns it to plain text.

    Did you have a look at those lisp routines suggested they may label lots of line in one go, I would then run an alternative lisp that added the wall label so you can pick manually the wall number sequence.

    A bit further ahead when you draw lines and then pick a whole bunch at one time they are in the drawn order so if you could regiment your self then you could do what you want in one go automatically labelling the walls in the drawn order. I would probably write two routines (in one program) manual or automatic.
    I use a different program to create the walls in 3D. Then I export the 2D view to AutoCAD to create the layout, so the wall labels are already in place for me. I was looking for a quick way to edit the text that is there with the length of the line.

    Quote Originally Posted by BIGAL View Post
    Your lucky day added about 5 lines to this code and now it works if want other changes then probably a good time to learn how to write/change a program. This will work as per my post above either auto pick or manual thanks Lee
    Thank you, I will give it a shot when I get home tonight.

    Any good links to review to find out more about Lisp programming?

  9. #9
    Forum Deity Tharwat's Avatar
    Discipline
    Mechanical
    Tharwat's Discipline Details
    Occupation
    MEP AutoCAD Draftsman
    Discipline
    Mechanical
    Using
    AutoCAD 2014
    Join Date
    Oct 2009
    Location
    Lives in Abu Dhabi
    Posts
    2,631

    Default

    Hope this help you out with it ......

    Code:
    (defun c:test (/ ss ss1 e d lens adds e1 )
      ; Tharwat 14.02.2011
      (setq lens 0)
      (if (setq ss (ssget "_:L" '((0 . "LINE"))))
        (progn
          (repeat (setq i (sslength ss))
        (while
          (setq ss1 (ssname ss  (setq i (1- i))))
           (setq e (entget ss1))
            (setq d (distance (cdr (assoc 10 e))(cdr (assoc 11 e))))
             (setq lens (+ lens d))
              ))
          (setq adds (entsel "\n Select Text to add lengths to :"))
          (entupd (cdr (assoc -1 (entmod (subst
                           (cons 1 (strcat (cdr (assoc 1 (setq e1 (entget (car adds)))))
                                    " = " (rtos lens 4 5)))
                           (assoc 1 e1) e1 )))))
          )
        (princ "\n No lines selected")
        )
      (princ)
      )
    Tharwat

  10. #10
    Full Member emwhite's Avatar
    Computer Details
    emwhite's Computer Details
    Operating System:
    Win 7 Pro
    Computer:
    Lenovo w510
    CPU:
    Intel® Core™ i7-720QM (1.60GHz base; 2.80GHz Max Turbo, 6MB Cache)
    RAM:
    8GB (2 X 4GB) PC3-10600 DDR3 1333MHz
    Graphics:
    NVIDIA® Quadro® FX 880M
    Primary Storage:
    Intel 160gb SSD, Windows Home Server 5TB+
    Discipline
    Structural
    emwhite's Discipline Details
    Occupation
    Sales Support/CAD Monkey
    Discipline
    Structural
    Details
    Light gauge framing of homes.
    Using
    AutoCAD 2010
    Join Date
    Feb 2011
    Location
    Dallas, TX
    Posts
    74

    Default

    Registered forum members do not see this ad.

    Quote Originally Posted by Tharwat View Post
    Hope this help you out with it ......
    I was able to run home at lunch and give it a whirl. It works great! Thank you!!!!

Similar Threads

  1. Measure length of continuous line
    By Vigilante in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 30th Jan 2012, 08:14 am
  2. how to measure chord length
    By tonika in forum AutoCAD General
    Replies: 10
    Last Post: 4th Jan 2011, 10:05 am
  3. Tough Questions - Line Length Lisp
    By johnshar123xx in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 30th Nov 2009, 11:43 pm
  4. Need a code lisp sum the length of line, pline, arc..
    By Nad SK in forum AutoLISP, Visual LISP & DCL
    Replies: 2
    Last Post: 4th Dec 2008, 08:53 am
  5. changing line space factor for existing text
    By Hickoz_bro in forum AutoLISP, Visual LISP & DCL
    Replies: 5
    Last Post: 28th Mar 2008, 01:46 pm

Bookmarks

Posting Permissions

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