Author Topic: (program) Line labeler  (Read 13366 times)

0 Members and 1 Guest are viewing this topic.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(program) Line labeler
« on: June 10, 2004, 01:17:51 PM »
Sort of a beta version, I'm adding other functions related to labeling lines to it.
Code: [Select]

;;; FUNCTION
;;; labels lines with bearing and distance in dtext, and gives you a chance
;;; to edit the text at the end
;;; uses current text style and layer
;;;
;;; ARGUMENTS
;;;
;;; USAGE
;;;
;;; PLATFORMS
;;; 2000+
;;;
;;; AUTHOR
;;; Copyright© 2004 Mark S. Thomas
;;; mark.thomas@theswamp.org
;;;
;;; VERSION
;;; 1.0 Thu Jun 10, 2004 12:59:40

; Degree to Radian conversion
(defun MST-dtr (x)
  (/ (* x pi) 180.0)
  )

; Radian to Degree conversion
(defun MST-rtd (x)
  (/ (* x 180.0) pi)
  )
;
;   ,-----------------------------------------------,
;   |                   MID POINT                   |
;   '-----------------------------------------------'
;
(defun midpt (p1 p2)
    (mapcar
      '(lambda (x y) (/ (+ x y) 2.0)) p1 p2
      )
    )
;
;   ,-----------------------------------------------,
;   |                VARIANT TO LIST                |
;   '-----------------------------------------------'
;
(defun var2lst (var)
  (if (= (type var) 'VARIANT)
    (vlax-safearray->list
      (vlax-variant-value var)
      )
    )
  )
;
;   ,-----------------------------------------------,
;   |               MST-entsel-name                 |
;   '-----------------------------------------------'
;
;;; example: (setq CirObj (MST-entsel-name "\nSelect A Circle..." "AcDbCircle"))
;;; traps any errors in the function
(defun MST-entsel-name (msg objname / ent obj)
  (setq ent (vl-catch-all-apply 'entsel (list msg)))
  (if (and ent (not (vl-catch-all-error-p ent)))
    (progn
      (setq obj (vlax-ename->vla-object (car ent)))
      (if (/= (vla-get-ObjectName obj) objname)
        (setq obj nil)
        )
      )
    ); if
  obj
  ); defun
;
;   ,-----------------------------------------------,
;   |                 MST-release                   |
;   '-----------------------------------------------'
;
(defun MST-release (obj /)
  (if
    (= (type obj) 'VLA-OBJECT)
    (if (not (vlax-object-released-p obj))
      (vlax-release-object obj)
      )
    )
  )
(defun MST-get-txt-style ()
  (vla-get-ActiveTextStyle
    (vla-get-activedocument
      (vlax-get-acad-object)
      )
    )
  )

(defun MST-get-mspace ()
  (vla-get-modelspace
    (vla-get-activedocument
      (vlax-get-acad-object)
      )
    )
  )
;
;   ,-----------------------------------------------,
;   |                MAIN FUNCTION                  |
;   '-----------------------------------------------'
;
(defun LineLabel (/ th *error* ent lineObj lenD
                    ang bear mp txtrot p1 p2 len)

  ; error function
  (defun *error* (msg)
    (if
      (not
        (member msg '("console break" "Function cancelled" "quit / exit abort")))
      (princ (strcat "\nError: " msg))
      ); if
    (princ)
    );end error function

  (setq th (vla-get-height (MST-get-txt-style)))

  (if
    (<= th 0.0)
    (setq th (getvar' textsize))
    )

  (if
    (not
      (setq lineobj (MST-entsel-name "\nSelect line to be measured..." "AcDbLine"))
      )
    (exit)
    )

  (setq lenD (strcat (rtos (vla-get-length lineobj) 2 2)))
  (setq ang (vla-get-angle lineObj))

  ; determine text rotation
  (cond
    ((and
       (>= ang (* 0.5 pi)) ;between N-0°W
       (< ang (* 0.538889 pi))) ;& N-20°W
     (setq txtrot (- ang pi))
     )
    ((and
       (> ang (* 0.538889 pi)) ;between N-20°W
       (<= ang (* 1.5 pi))) ;& S-0°W
     (setq txtrot (+ ang pi))
     )
    ((and
       (>= ang (* 1.5 pi)) ;between S-0°E
       (< ang (* 1.538889 pi))) ;between S-20°E
     (setq txtrot (- ang pi))
     )
    (T
      (setq txtrot ang)
      )
    ); cond

  (setq bear (vl-string-subst (chr 176) "d" (angtos ang 4 4)))

  ; midpoint of line
  (setq mp (vlax-3d-point
             (midpt
               (var2lst (vla-get-startpoint lineObj))
               (var2lst (vla-get-endpoint lineObj))
               )
             )
        )

  ; offset points
  ; (setq p1
  ;       (vlax-3d-point
  ;         (polar (var2lst mp) (MST-dtr (+ (MST-rtd ang) 90)) (* th 2))
  ;         )
  ;       p2
  ;       (vlax-3d-point
  ;         (polar (var2lst mp) (MST-dtr (- (MST-rtd ang) 90)) (* th 2))
  ;         )
  ;       )

  ; text label bearing
  (if mp
    (setq txtobj
          (vla-addtext
            (MST-get-mspace)
            (strcat bear "  " lenD)
            mp
            th
            )
          )
    )

  (if txtobj
    (progn
      (vlax-put-property txtobj 'Alignment acAlignmentBottomCenter)
      (vlax-put-property txtobj 'TextAlignmentPoint mp)
      (vlax-put-property txtobj 'Rotation txtrot)
      )
    )

  (MST-release txtobj)

  (setq kwd
        (strcase
          (getstring "\nEdit bearing? (Y/N) <No>: ")
          )
        )
  (if kwd
    (if (= kwd "Y")
      (command "_.ddedit" (entlast)"")
      )
    )

  (princ)
  )

(princ "\nUse 'LA' to label LINES")
(defun c:la () (LineLabel))
(princ)

TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(program) Line labeler
« Reply #1 on: June 10, 2004, 02:22:14 PM »
TheSwamp.org  (serving the CAD community since 2003)

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
(program) Line labeler
« Reply #2 on: June 10, 2004, 02:37:34 PM »
Hey Mark -

I just tried it out, but I noticed a few things. :)

1. If you have an orthographic line, the bearing is always coming out like:
E 290 or N 290, etc.. It does not give a N 00d00'00" E 290.00. This is on with LA and LBP, however somethimes LBP will give the ortho bearding. Get what I am saying?

2. I noticed that the program doesn't add a prefix to the length...is it possible to have the program check for your DIMPOST variable, and then add that to the end of the length?

3. I also think that a multiple entity selection would be a great add-on, that way the program does not need to be run for each and every line you have :).

Hope this helps you some.
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(program) Line labeler
« Reply #3 on: June 10, 2004, 02:59:43 PM »
thanks for the feedback rug.
TheSwamp.org  (serving the CAD community since 2003)

Dent Cermak

  • Guest
(program) Line labeler
« Reply #4 on: June 10, 2004, 03:01:33 PM »
I HATE it when people label NORTH as N00d00'00"E!! The CARDINAL directions should ALWAYS be labeled NORTH, EAST, SOUTH, or WEST. Kindly check the National Map Accuracy Standards and most State Survey Minimum Standards. That putting the degrees , minutes and seconds things on the cardinal directions is a "lawyer" thing that just shows their ignorance. Don't copy them. Makes you look bad. The GPS bunch do it too, but they are computer geeks and not surveyors or cartographers. Last PM we had that INSISTED that was right is no longer with us.

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(program) Line labeler
« Reply #5 on: June 10, 2004, 03:41:02 PM »
We use N00°00'00"E also but, the signing surveyor is _always_ right. And I aim to please. :D
TheSwamp.org  (serving the CAD community since 2003)

rugaroo

  • Bull Frog
  • Posts: 378
  • The Other CAD Guy
(program) Line labeler
« Reply #6 on: June 10, 2004, 04:00:37 PM »
Hey, I am not trying to step on your toes there. I only brought that up because of te fact that my client/entity in NY, and most clients/entities here in Vegas will not accept any plans that call lines out as being NORTH, rather than N00d00'00"E (or W, etc.) due to the fact that Clark County Nevada takes a paper copy of every final map/ALTA, etc. and rebuilds it, and then places it within the GIS files. That is here and there, but not every where. Nor am I trying to point at you surveyors and say that us engineers are more right or anything. Just we tend to look at things sometimes as have a million sides, while in reality, there is only one way. Anyways, I figured I would just try to help though. And for the record...Engineers don't know anything, it is always the Designer who does.
LDD06-09 | C3D 04-19 | Infraworks 360 | VS2012-VS2017

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
(program) Line labeler
« Reply #7 on: June 10, 2004, 04:38:31 PM »
An Engineer is a resource for a good Designer.
I drink beer and I know things....

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(program) Line labeler
« Reply #8 on: June 14, 2004, 08:08:50 AM »
TheSwamp.org  (serving the CAD community since 2003)

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(program) Line labeler
« Reply #9 on: June 15, 2004, 11:38:05 AM »
Updated:
added the dimpost variable to the end of the length.
thanks rug.

http://www.theswamp.org/swamp.files/Public/label_line.lsp
TheSwamp.org  (serving the CAD community since 2003)

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
(program) Line labeler
« Reply #10 on: June 15, 2004, 11:58:38 PM »
Dent if'n it ain't N00d00'00"E what IS the freakin' bearing? I suppose it could be just plain "Due North" .... please let me know so I don't break this rule..
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

Dent Cermak

  • Guest
(program) Line labeler
« Reply #11 on: June 16, 2004, 08:28:08 AM »
It is known as a "CARDINAL" direction. The CARDINAL directions are: NORTH, SOUTH, EAST and WEST. You've NEVER seen a map or compass with N00d00'00"E on it, have you. This is the brain child of the new GPS gurus who know NOTHING about cartography. Same IDIOTS that drew up the current Corps of Engineers drafting standards that have been in revision for 8 years now because they are so full of errors. Many state surveying minimum standards do not allow N00d00'00"E label, but call for the cardinal direction. Before all of you clowns tell me that I am full of shit, you better check your state regs. In your case I would call your attention to Chapter 16, Florida Administrative Code, Chapter 61G17-6, Minimumtechnical standards, Page 159, Page 160- 61G17-6.0031, paragraph (1)(d).  :shock:  :twisted:

Slim©

  • Needs a day job
  • Posts: 6566
  • The Dude Abides...
(program) Line labeler
« Reply #12 on: June 16, 2004, 08:58:21 AM »
I know I'm gonna hate myself fer this.

Dent, this time I realy have to agree with you.
I drink beer and I know things....

Mark

  • Custom Title
  • Seagull
  • Posts: 28762
(program) Line labeler
« Reply #13 on: June 16, 2004, 10:02:41 AM »
Quote from: Dent Cermak
Chapter 16, Florida Administrative Code, Chapter 61G17-6, Minimumtechnical standards, Page 159, Page 160- 61G17-6.0031, paragraph (1)(d).


which states:
Quote

61G17-6.0031 Boundary Survey, Map, and Report.
(1) BOUNDARIES OF REAL PROPERTY.
(d) All changes in direction, including curves, shall be shown on the survey map by angles, bearings or azimuths, and will be in the same form as the description or other recorded document referenced on the map.
TheSwamp.org  (serving the CAD community since 2003)

Dent Cermak

  • Guest
(program) Line labeler
« Reply #14 on: June 16, 2004, 10:44:40 AM »
And you won't find a lawyer that will use anything other than the cardinal notations, thus maintaining the original deed bearings precludes the use of N00d00'00"E for the cardinal ordinate NORTH.

PLUS, one of the bibles for cartographers and surveyors is FM 21-26, Dept. of the Army Manual, "Map Reading" which states in chapter 5, Paragraph 5 (4) "The four cardinal cardinal directions are expressed simply as North, South, East and West."

This is a reflection of the differances that you will find between Cartographers  and EIT's. Generally, this discussion deos not occur between cartographers, surveyors and lawyers. We tend to be on the same sheet of music.