×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

LISP Routine

LISP Routine

LISP Routine

(OP)
Hi.

I use AutoCAD on daily bases where I draw a mass quantity of lines that represent piping networks. I am counting the total individual length pretty much by hand. I have been doing this for a while ever since I got out of college.
I need LISP routine that labels length of individual lines by selecting them preferably in mass quantity.
For examples, 1 ft 1 inches to 1-1, etc.
If anyone out there who reads this message, please help me find the LISP routine. I will be very appreciated.

,nathan

RE: LISP Routine

Not sure if this does what you want, but it's a first try.  Save it, then load it, then type LL2 to run it.

(DEFUN C:LL2 ()
  (setq osm (getvar "osmode"))
  (setvar "osmode" 0)
  (prompt "\nSelect all objects to measure: ")
  (setq ss (ssget))
  (while (> (sslength ss) 0)
    (setq en (ssname ss 0)
          ed (entget en)
          et (cdr (assoc '0 ed))
    )
    (cond
      ((= et "LINE") (ShowLength))
    ((or
     (/= et "LINE")
    )
       (ssdel en ss)
      )
    )
  )
 (setvar "osmode" osm)
 (princ)
)

(defun ShowLength ()
  (setq pt1 (cdr (assoc '10 ed))
        pt2 (cdr (assoc '11 ed))
        Pt3 (List (/ (+ (Car pt1) (Car pt2)) 2.0) (/ (+ (Cadr Pt1) (Cadr pt2)) 2.0))
       Llen (distance pt1 pt2)
       Lang (angle pt1 pt2)
  )
  (COMMAND "Text" "BC" pt3 "" Lang (rtos Llen))
  (ssdel en ss)
)

RE: LISP Routine

(OP)
Hi IFRs & everyone,

I loaded IFR's code and ran it on my AutoCad 2004 and windowed all lines that I wanted length to be labled. I noticed I wasn't able to aline direction of length label to vertical lines, although the routine worked great in labeling horizontal ones. IFRs, another question I have is due to complexity of drawings that I deal with, can LISP routine be written to strip the ft and inch marks from labels. In other word,(1'-1") to (1-1), etc.  
Other than that, the routine is great!

,nathan

RE: LISP Routine

Sorry for the late response - I was hiking in the Grand Canyon.  Anyway, the orientation of the text is determined by the line Lang (angle pt1 pt2) where the "angle" part the t "TEXT" command is found using AutoCAD's "angle" command to find the angle from point pt1 and point pt2.  I assumed there would be various oblique lines when I wrote this.  I will try vertical lines to see why it does not work.  It may be that your Units setting is trouble, in which case we can add LISP to fix it.  What degree units do you use?  The feet and inches is there because the command (rtos Llen) converts the line length (Llen) from a real number to a string (rtos).  The default Units (Architectural, etc) determine the format of the resulting string.  This was the easy way!!  When I catch up with work etc I will modify the LISP to strip our the feet and inch marks, I suspect with the "subst" function.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources