PDA

View Full Version : Help with modifying a LISP routine from CADalyst


mwilson
2006-12-15, 04:00 PM
This is a lisp routine that I got from the cadalyst
Web Site. Everything works fine, except I need
to be able to place the text on the drawing instead
of on the command line. Any help would be appreciated.

;TIP1052C.LSP: PNTGRADE.LSP Utilities for Civil Engineers (C)1994, Jeff Reimert

Sorry for the *edit* but I believe it would be best if this code was *not* posted on the AUGI web site, unless the author has given their permission. I would recommend you provide a link to the file instead.

AUGI can not take any chances with regard to Copyright infringements that may exist. It would be good manners to obtain the author's permission before posting their work.

Thanks for your understanding,

Richard
Forum Moderator

Lions60
2006-12-15, 05:24 PM
Here you go this prints the tex to the screen. The current precision is to 2 decimal places but that can be changed. (if c (mtxt (rtos c 2 2) pt2)) By changing the variable in red it sets the precision.


;========ERROR HANDLER===========
(defun pag_err (MSG)
(alert(strcat "Error!: " MSG))
(setq *error* OLDERR)
(setvar"cmdecho" 1)
(princ)
)
;===============MAIN PROGRAM===========
(defun C:PAG (/ PT1 PT2 EL1 G D1 M C OLDERR)
(setq OLDERR *error*)
(setq *error* PAG_ERR)
(setvar"cmdecho" 0)
(initget 1)
(setq PT1(getpoint "\nSelect 1st Known Point: "))
(initget 1)
(setq EL1(getreal "\nEnter the Elevation :"))
(initget 1)
(setq PT2(getpoint "\nSelect point of Unknown Elevation: "))
(initget 1)
(setq G(getreal "\nEnter % of Grade in Decimal Form: "))
;==calculations===========
(setq D1(distance PT1 PT2)
M(* G D1)
c(atof(rtos(+ M el1) 2 2)));setq
(if c (mtxt (rtos c 2 2) pt2))
);; end of defun
;=========================
(defun mtxt ( mytext mypoint )

(entmake
(list
'(0 . "TEXT")
'(67 . 0)
'(100 . "AcDbText")
(cons 10 mypoint)
'(40 . 3.5)
(cons 1 mytext)
'(50 . 0.0)
'(41 . 1.0)
'(51 . 0.0)
'(71 . 0)
'(72 . 1)
(cons 11 mypoint)
'(73 . 2)
)
)
(setq *error* OLDERR)
(setvar "cmdecho" 1)
(princ)
)
;==============================================================
(princ "\nPNTGRADE.LSP loaded... Start with PAG")
(princ); end pntgrade.lsp