AutoCAD/Q-leadering deltas
Expert: Bill DeShawn - 6/26/2008
QuestionHi Bill,
I work with a lot of easements in final plats of subdivisions and finding the delta for each curve is extremely time consuming. There may be 100 curves on an easement and all need a number, radius, arc length, and delta's. Delta's take the longest to figure out and I didn't know if their was a way to make a quick leader reference to delta information or not. If you could help me with this I would greatly appreciate it. Thanks
Pete
AnswerThere is a way to do it, and it would be good if you knew how to write at least basic AutoLISP. Here is a start:
(defun deltaerr (msg)
(if msg (princ msg))
(if ol (setvar "clayer" ol))
(if ucschg (command "_.ucs" "_p"))
(if olderr (setq *error* olderr))
(command "_.undo" "_end")
(princ)
)
(defun ANGFIX (ANG N / ANG1)
(setq ANG1 (angtos ANG N 4))
(cond
(
(> (strlen ANG1) 1)
(setq COUNT 1)
(repeat (strlen ANG1)
(if (= (substr ANG1 COUNT 1) (chr 100)) (setq DPOS COUNT))
(if (= (substr ANG1 COUNT 1) (chr 39)) (setq APOS COUNT))
(if (= (substr ANG1 COUNT 1) (chr 34)) (setq QPOS COUNT))
(setq COUNT (1+ COUNT))
)
(cond
(
(= (- APOS DPOS) 2)
(setq ANG1 (strcat (substr ANG1 1 DPOS) "0" (substr ANG1 (1- APOS))) APOS (+ APOS 1) QPOS (+ QPOS 1))
)
)
(if (= (- QPOS APOS) 2)
(setq ANG1 (strcat (substr ANG1 1 APOS) "0" (substr ANG1 (1- QPOS))))
)
(setq ANG1 (strcat (substr ANG1 1 (1- DPOS)) "º" (substr ANG1 (1+ DPOS))))
);WHERE DOES THIS START?
(t
(setq ANG1 ANG1)
)
);--- end outer cond
)
(defun c:delta (/ e x etype arcstart cntr arcrad ang1 ang2 arcang pt1 pt2 lchord chrdbrg arcsel raid ucschg)
(command "_.undo" "_g")
(setq olderr *error* *error* loterr)
(if (/= (getvar "worlducs") 1)
(progn
(command "_.ucs" "_w")
(setq ucschg T)
)
)
(graphscr)
(setvar "angdir" 0)
(setvar "OSMODE" 0)
(setq e (car (entsel)))
(setq X (entget E))
(setq etype (cdr (assoc 0 X)))
(if (= "ARC" etype)
(PROGN
(setq arcstart (cdr (assoc 50 arclst)))
(setq arcend (cdr (assoc 51 arclst)))
(setq arcrad (cdr (assoc 40 arclst)))
(setq arcang (- arcend arcstart))
(setq CNTR (cdr (assoc 10 X)))
(setq ARCRAD (cdr (assoc 40 X)))
(setq ANG1 (cdr (assoc 50 X)));arcstart
(setq ANG2 (cdr (assoc 51 X)));arcend
(setq arcang (- ang2 ang1))
(setq PT1 (polar CNTR ANG1 ARCRAD))
(setq PT2 (polar CNTR ANG2 ARCRAD))
(setq LCHORD (distance PT1 PT2))
(setq CHRDBRG (angle PT1 PT2))
(setq ARCSEL X)
(setq RAID (/ ARCRAD 1.0))
(setq arclen (rtos (* arcrad arcang) 2 2))
(cond
(
(< ANG1 ANG2)
(setq ANG (- ANG2 ANG1))
)
(
(> ANG1 ANG2)
(setq ANG (- (* pi 2) (- ANG1 ANG2)))
)
)
(setq C (* pi 2 RAID)
L (* C (/ ANG (* 2 pi)))
)
(princ (strcat "\nDelta = " (angfix ANG 1)". R= " (rtos RAID 2 2) ". L= " arclen "."))
; (command
; "TEXT" PT (angtos ANGT 0) (strcat ". L = " (rtos L 2 2) "'")
; )
; (command "TEXT" PT "" (angtos ANGT 0) (strcat "%%u/%%092%%u = " (angfix ANG 1))
; "TEXT" "" (strcat "R= " (rtos RAID 2 2)"'")
; "TEXT" "" (strcat "L= " (rtos L 2 2) "'")
; )
(princ)
(if ucschg (command "_.ucs" "_p"))
(command "_.undo" "_end")
(princ)
)
(alert "Object must be an arc.")
)
(princ)
)
I'm hoping this doesn't get messed up with the hard returns that AllExperts might force upon the text. Let me know if you understand at least what to do with this code. If not, I'll talk you through it.
Keep the dialog going till you solve the problem.
Bill DeShawn
http://my.sterling.net/~bdeshawn