Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations GregLocock on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

LISP Routine

Status
Not open for further replies.

MTuWThFriFriFri

Mechanical
Dec 10, 2004
9
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

 
Replies continue below

Recommended for you

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)
)
 
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
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor