Community
AutoCAD Forum
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

How to display line length and angle bearing?

6 REPLIES 6
Reply
Message 1 of 7
mk9023
8057 Views, 6 Replies

How to display line length and angle bearing?

Untitled3.png
Like in this picture?

6 REPLIES 6
Message 2 of 7
Patchy
in reply to: mk9023

Use Field or better yet, learn to use autolisp.

 

Use Field 1.PNG

Message 3 of 7
3wood
in reply to: mk9023

You can try ADDLINES.vlx.

But it adds bearing and length in one text objects.

 

Message 4 of 7
beyoungjr
in reply to: 3wood

I've used a few Lisp routines in years' past to label my distances and bearings but they all used standard text.  I ran across the following routine which uses Mtext but it references the output of the Distance and Angle commands and is dependent upon the drawing units settings.  The angle reports with a "d" for degres and the length reports as inches with 2 decimal places.

 

I start with an architectural (imperial) template.  You can draw a 25' line on an angle and test the code.

 

Any ideas on how to get the inches to report as feet with 2 decimals and a foot symbol AND the degrees symbol in place of the "d" for degrees?

 

(defun c:brg69(/ om dsc an ent p1 p2 p3 ang dist lf1 lf2 f1 f2
                mtxt dist1 dist2 ht lp1 lp2 lp3 lp4)
(setq dsc (getvar "dimscale"))
(setq ht (* 0.25 dsc))  ;;; <<< - sets text size of note
(setq an (getvar "aunits"))
(setq ln (getvar "lunits"))
(setq anp (getvar "auprec"))
(setq lnp (getvar "luprec"))
(setvar "lunits" 4)
(setvar "luprec" 2)
(setvar "aunits" 4)
(setvar "auprec" 6)
(setq ent (entget (car (entsel "\nSelect Line: "))))
(setq p1 (cdr (assoc 10 ent)))
(setq p2 (cdr (assoc 11 ent)))
(setq ang (angtos (angle p1 p2)))
(setq dist (rtos (distance p1 p2) 2))
(setq mtxt (strcat dist "\\P" ang))
(setq dist1 (* dsc 2))
(setq dist2 (* dsc 1))
(setq lp1 (getpoint"\nSelect First Leader Point or Midpoint of Line: "))
(setq lp2 (getpoint lp1 "\nSelect Second Leader Point or Midpoint of Line: "))
(command"line" lp1 lp2 "")
(setq lp3 (getpoint lp2 "\nSelect Leader Leg or Text Direction: "))
(command "erase" "l" "")
(setq lp4 (polar lp2 (angle lp2 lp3) dist1))
(setq p3 (polar lp2 (angle lp2 lp3) dist2))
(command"leader" lp1 lp2 lp4 "" "" "n" "")
(setvar "aunits" 0)
(setq lf1 (car lp2))
(setq lf2 (car lp3))
(setq f1 (cadr lp2))
(setq f2 (cadr lp3))
(command"mtext" p3 "r" (atof(angtos (angle p1 p2)))  "h" ht "j" "mc" p3 mtxt "")
(if 
  (or
   (> f1 f2)
   (> lf1 lf2)
   (/= f1 f2)
   (= lf1 lf2)
  ) 
 (command "rotate" "l" "" p3 "180")
)
(if (< f1 f2)(command"undo" "1"))  
(setvar "aunits" an)
(setvar "auprec" anp)
(setvar "lunits" ln)
(setvar "luprec" lnp)
(princ)
)

 

 

 

Thanks in advance,

Blaine

 

 

 


Blaine Young
Senior Engineering Technician, US Army

Message 5 of 7
Kent1Cooper
in reply to: beyoungjr


@beyoungjr wrote:

.... 

Any ideas on how to get the inches to report as feet with 2 decimals and a foot symbol AND the degrees symbol in place of the "d" for degrees?

.... 


(setq ang (vl-string-subst "%%d" "d" (angtos (angle p1 p2))))
(setq dist (strcat (rtos (/ (distance p1 p2) 12) 2) "'"))

 

You may need to add the line:

(vl-load-com)

if something else hasn't done that for you.  It can go at the very top or the very bottom [it could go inside the (defun) function, but then it will be invoked every time you call the command, whereas it needs to be invoked only once, when the file is loaded].

Kent Cooper, AIA
Message 6 of 7
beyoungjr
in reply to: Kent1Cooper

Kent1Cooper, you're the tops!  I've been on ACAD of and on since '83 in high school but never took the initiative to learn LISP (sure wish I had).

The code works perfectly!

 

If anyone knows of a good lisp for survey dimensioning of curves let me know.

 

I've messed with about a dozen OK text routines/macros over the years but they always need further tweaking for data corrections, placement, or orientation.  The Bearing and Distance routine that Kent1Cooper assisted me with is great.  Teaching CAD101 & CAD102 at Community College and this will sure speed up my teaching for plats and students project time.

 

Thanks K1C

 


Blaine Young
Senior Engineering Technician, US Army

Message 7 of 7
Kent1Cooper
in reply to: beyoungjr


@beyoungjr wrote:

Kent1Cooper, you're the tops! ....

 

If anyone knows of a good lisp for survey dimensioning of curves let me know.

 

I've messed with about a dozen OK text routines/macros over the years but they always need further tweaking for data corrections, placement, or orientation.  ....


Thank you.  Attached is what I use for drawing-and-marking-at-the-same-time, or marking-already-drawn, Lines and Arcs in property boundaries.  How it compares to what Civil overlay programs give you, I don't know.  It may well not format things quite the way you prefer, but such things are adjustable.  Less easily adjustable is that for Lines, it puts the bearing at one end and the distance at the other, but maybe that doesn't matter if you're looking for the parts about Arcs.  See descriptions at the top of the file, and of what each command's name stands for at the (defun C:... lines.

Kent Cooper, AIA

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost