DD,
Thank you for you continued assistance. I am trying to assist another drafter in the office speed up the work flow in his department. I spend a good part of the day yesterday analyzing his problem and I believe I have come up with a more proper lisp solution than the one I posted originally. I then spent the evening learning the basics of list processing. Hopefully I will be here helping others some day but it may be a while.. There is so much to learn!
I am not sure if I should create another post or even if this is too much to ask here. So, please feel free to let me know if it is but I'll lay it out. You don't know if you don't try, right?
So, here is the work I would like to create a lisp to preform;
Drafter must draw PLINE from equip to its termination.
Drafter finds PLINE distance, rounds that value to nearest multiple of 5
Drafter put rounded value into attribute of block1 (SOC SVC FOOTAGE)
Drafter adds 15 to rounded value and put sum into attribute of either block2 (svcdir_right-2006) or block3 (svcdir_left-2006)
This must be done for hundreds of lots on every job of this type.
My solution would be one routine that does all of this by Frankensteining a few lisps I have found together.
I found this code (Post on cadtutor) written by Lee Mac and modified by sadhu:
(defun c:cdt (/ *error* Round DLST PT PTLST TOT)
;; Lee Mac ~ 01.03.10
(SETQ CLY (GETVAR "CLAYER"))
(SETQ OSM (GETVAR "OSMODE"))
(SETQ OTM (GETVAR "ORTHOMODE"))
(setvar "orthomode" 0)
(setvar "osmode" 0)
[color=red](defun LWPoly (lst)
(entmakex (append (list (cons 0 "LWPOLYLINE")
(cons 100 "AcDbEntity")
(cons 100 "AcDbPolyline")
(cons 90 (length lst))
(cons 70 0))
(mapcar (function (lambda (p) (cons 10 p))) lst))))[/color]
(defun Round (num dp / fac rm)
(setq fac (float (expt 10 dp))
rm (rem (setq num (* fac num)) 1))
(/ (cond ( (zerop rm) (fix num))
( (< 0.5 rm) (1+ (fix num)))
( (+ (/ 5 fac) (fix num)))) fac))
(if (car (setq ptLst (list (setq pt3 (getpoint "\nSpecify First Point: ")))))
(progn
(while (setq pt (getpoint "\nSpecify Next Point: " (car ptLst)))
(mapcar
(function
(lambda (from to)
(grdraw from to 3 1)))
(reverse (setq ptLst (cons pt ptLst)))
(cdr (reverse ptLst)));mapcar
(setq dLst (cons (Round (distance (car ptlst) (cadr ptlst)) 1) dLst))
(princ (strcat "\n<< Distance: " (rtos (car dLst)) " -- "
"Cumulative: " (setq tot (rtos (apply (function +) dLst) 2 2)) " >>"))
) ;while
[b][color=red] (LWPoly ptlst) [/color][/b]
(if (setq pt (getpoint "\nSpecify Point for Text: "))
(entmakex (list (cons 0 "MTEXT")
(cons 100 "AcDbEntity")
(cons 100 "AcDbMText")
(cons 8 "RH_FDP")
(cons 10 pt)
(cons 1 tot)
(cons 40 0.1)
)
)
);if
);progn
);if
(princ (strcat "\nDistanza : " tot " **"))
(redraw)
(SETVAR "CLAYER" CLY)
(SETVAR "OSMODE" OSM)
(SETVAR "ORTHOMODE" OTM)
(princ))
This prompts the user to draw a PLINE using entmakex, does a bit of rounding to the value of the PLINE's length and then places that value into a TEXT the user selects the insertion point of. Almost perfectly does most of the job but I think a few tweaks/additions to it would do the trick.
The other bit I would like to incorporate into this is the lips I had originally posted (To save space I won't repost it)
So that the rounded value can be placed into a block attribute. Only, LM's code rounds to the nearest .05 and I need it to 5. Also instead of putting the rounded value into a TEXT entity I would like to insert block1 with that value as it's attribute. Then add 15 to that rounded value and insert another block with the choice of either block2 or block3 with that sum as is attribute's value. The cherry on top would be for the lisp to repeat.
This may be a bit of a tall order. So, I will understand if it would take too much time to put together. Any assistance is greatly appreciated.
-Matthew