Author Topic: Labels connected to Linework  (Read 5980 times)

0 Members and 1 Guest are viewing this topic.

MSTG007

  • Gator
  • Posts: 2603
  • I can't remeber what I already asked! I need help!
Labels connected to Linework
« Reply #15 on: June 24, 2004, 11:08:38 AM »
nice.....  really nice...

can the line be changed to a Quick Leader?
Civil3D 2020

MSTG007

  • Gator
  • Posts: 2603
  • I can't remeber what I already asked! I need help!
Labels connected to Linework
« Reply #16 on: June 24, 2004, 11:14:47 AM »
but what i just did which works is this...

It labels my line my layer name!

Ex.    LAYER NAME   -  EX-WATER

Then i use find and replace under edit,

EX-  to find

EXISTING  to replace

now with the label I have EXISTING WATER for a label!!!!!

my layer names are

EX-WATER
EX-PAVEMENT
EX-CONCRETE
EX-CONCRETE-WALK
EX-CURB

ETC.
Civil3D 2020

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Labels connected to Linework
« Reply #17 on: June 25, 2004, 02:15:48 PM »
Revised..

Code: [Select]
(defun c:label_prop (/ usercmd useros ent lname pt pt2 offset
                     ofsdir txtjust dwg_ht )
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq useros (getvar "osmode"))
  (setvar "osmode" 0)
  (if (setq ent (entsel "\Select an entity to label."))
    (progn
      (setq pt     (cadr ent)
            lname  (cdr (assoc 8 (entget (car ent)))) ;LAYER NAME
            offset 2 ; amount of box offset from text
      )
      (if (and (member (strcase(substr lname 1 3)) '("EX-" "EX_"))
               (> (strlen lname)3))
        (setq lname (strcat "Existing " (substr lname 4)))
      )
      (if (setq pt2 (getpoint pt "\nSelect Placement Point: "))
        (progn
          (command "_.LINE" pt pt2 "")
          (if (>= (car pt2) (car pt)) ; line is left to right
            (setq txtjust "ML"
                  ofsdir offset
            )
            (setq txtjust "MR"
                  ofsdir  (- offset)
            )
          )
          (setvar "osmode" 0)
          (setq
            dwg_ht
             (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))
             )
          )
          (if (= dwg_ht 0)
            (command "text" "J" txtjust (polar pt2 0 ofsdir) "" 0 lname)
            (command "text" "J" txtjust (polar pt2 0 ofsdir) 0 lname)
          ) ; endif
          (tbox (entlast) offset)
        )
      )
    )
  )
  (setvar "CMDECHO" usercmd)
  (setvar "osmode" useros)
  (princ)
)
;;----------------------------------------------------------------------
;;           Draw a pline box around line text
;;----------------------------------------------------------------------
(defun tbox (te sf / e1 tb ll ur ul lr el pt plw)
  (setq plw (getvar "PlineWid")) ; width of Poly Line
  (if (/= plw 0)
    (progn
      (setq plw (getint (strcat "Enter Pline Width <" (rtos plw) ">:")))
      (if (= plw nil)
        (setq plw 0)
      )
      (setvar "PlineWid" plw)
    )
  )
  (setq e1 (entget te))
  (= (setq typ (cdr (assoc 0 e1))) "TEXT")
  (command "ucs" "Entity" te)
  (setq tb (textbox e1)
        ll (car tb)
        ur (cadr tb)
        ul (list (car ll) (cadr ur))
        lr (list (car ur) (cadr ll))
  )
  (command "._pline" ll lr ur ul "c")
  (setq el (entlast))
  (setq pt (polar ll (angle ll lr) (* (distance ll lr) 2)))
  (command "._offset" sf el pt "")
  (entdel el)
  (command "ucs" "w")
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Labels connected to Linework
« Reply #18 on: June 25, 2004, 03:00:39 PM »
And borrowing from Stig I revised to this:

Code: [Select]
(defun c:label_prop (/ usercmd useros ent lname pt pt2 offset
                     ofsdir txtjust dwg_ht laytag lname)
;; LAYERTRANSVALUES returns an assoc list in
;; the format: (object_layer label text_layer)
(defun layerTransValues ()
  ;;  Tag  Replacement
  '(( "EX_" "Existing")
    ("EX-" "Existing")
    ;; add to list when needed
    ;;  Tag MUST be in upper case
   )
)
;;  ================================
  (setq usercmd (getvar "CMDECHO"))
  (setvar "CMDECHO" 0)
  (setq useros (getvar "osmode"))
  (setvar "osmode" 0)
  (if (setq ent (entsel "\Select an entity to label."))
    (progn
      (setq pt     (cadr ent)
            lname  (cdr (assoc 8 (entget (car ent)))) ;LAYER NAME
            offset 2 ; amount of box offset from text
      )
      ;;  Layer name check  =============
      (foreach laytag (layerTransValues)
        (if (and (= (strcase(substr lname 1 (strlen (car laytag)))) (car laytag))
                 (> (strlen lname)(strlen (car laytag))))
          (setq lname (strcat (cadr laytag) " "
                        (substr lname (1+(strlen (car laytag))))))
      )
        )
      (if (setq pt2 (getpoint pt "\nSelect Placement Point: "))
        (progn
          (command "_.LINE" pt pt2 "")
          (if (>= (car pt2) (car pt)) ; line is left to right
            (setq txtjust "ML"
                  ofsdir offset
            )
            (setq txtjust "MR"
                  ofsdir  (- offset)
            )
          )
          (setvar "osmode" 0)
          (setq
            dwg_ht
             (cdr (assoc 40 (tblsearch "style" (getvar "textstyle")))
             )
          )
          (if (= dwg_ht 0)
            (command "text" "J" txtjust (polar pt2 0 ofsdir) "" 0 lname)
            (command "text" "J" txtjust (polar pt2 0 ofsdir) 0 lname)
          ) ; endif
          (tbox (entlast) offset)
        )
      )
    )
  )
  (setvar "CMDECHO" usercmd)
  (setvar "osmode" useros)
  (princ)
)
;;----------------------------------------------------------------------
;;           Draw a pline box around line text
;;----------------------------------------------------------------------
(defun tbox (te sf / e1 tb ll ur ul lr el pt plw)
  (setq plw (getvar "PlineWid")) ; width of Poly Line
  (if (/= plw 0)
    (progn
      (setq plw (getint (strcat "Enter Pline Width <" (rtos plw) ">:")))
      (if (= plw nil)
        (setq plw 0)
      )
      (setvar "PlineWid" plw)
    )
  )
  (setq e1 (entget te))
  (= (setq typ (cdr (assoc 0 e1))) "TEXT")
  (command "ucs" "Entity" te)
  (setq tb (textbox e1)
        ll (car tb)
        ur (cadr tb)
        ul (list (car ll) (cadr ur))
        lr (list (car ur) (cadr ll))
  )
  (command "._pline" ll lr ur ul "c")
  (setq el (entlast))
  (setq pt (polar ll (angle ll lr) (* (distance ll lr) 2)))
  (command "._offset" sf el pt "")
  (entdel el)
  (command "ucs" "w")
  (princ)
)
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.