Visual LISP, AutoLISP and General Customization
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

how can i merge this lisp commands?

0 REPLIES 0
Reply
Message 1 of 1
agent47x
365 Views, 0 Replies

how can i merge this lisp commands?

i have two lisp the BD.lsp and the BRG.lsp....the BD is for drawing lines by bearing and the BRG is for labeling the lines...

how can i merge this two lisp that create a command like this

command: hotnspicy

text height <5>:----------------------->this option is for the text height of line label

pick a starting point: pick bearings (1/2/3/4) :

degrees:

minutes:

seconds:

distance:

 

BD.lsp

(defun C:BD () (command "layer" "m" "BDRY" "C" "42" "BDRY" "LW" ".7" "BDRY""") (setvar "cmdecho" 0) (initget 1) (setq PT (getpoint "\nPick a starting point: ")) (initget "1 2 3 4") (while (setq BR (getkword "\nPick bearing (1/2/3/4): ")) (setq OPT (strcase BR)) (initget 1) (setq DEG (getstring "\nDegree: ") minx (getstring "\nMinute: ") SEC ()) (setq LEN (getreal "\nDistance: ")) (if (= DEG "") (setq DEG "0")) (if (= minx "") (setq minx "0")) (if (= SEC ()) (setq SEC "0")) (cond ((= "3" OPT) (setvar "angbase" (cvunit 270 "degree" "radian")) (setvar "angdir" 1)) ((= "2" OPT) (setvar "angbase" (cvunit 270 "degree" "radian")) (setvar "angdir" 0)) ((= "4" OPT) (setvar "angbase" (cvunit 90 "degree" "radian")) (setvar "angdir" 0)) ((= "1" OPT) (setvar "angbase" (cvunit 90 "degree" "radian")) (setvar "angdir" 1))) (command "line" PT (strcat "@" (rtos LEN) "<" DEG "d" minx "'" SEC "\"") "") (setvar "angbase" 0) (setvar "angdir" 0) (setvar "cmdecho" 1) (initget "1 2 3 4") (setvar "cmdecho" 1) (setq PT (getvar 'lastpoint)); for next segment to start from (initget "1 2 3 4"); again, for (getkword) in next pass through loop )end while; (princ)) (princ "\nType 'BD' to draw lines with bearings (princ)

 

 

brg.lsp

;;; * distance and bearing label for lines (graphscr) (prompt "\nloading. . . ") ;;; convert radians to degrees (defun rtd (R) (/ (* R 180.0) pi)) (defun C:brg () ;;; input for line notations (setq P1 (getpoint "\nFirst point: ")) (while (setq P2 (getpoint p1 "\nSecond point: ")) (setq T1 "Text Height: : " T3 (getvar "textsize") );setq (terpri) (setq TH (getreal (strcat T1 (rtos T3 2 2) T2))) (if (= TH nil) (setq TH t3)) ;;; determine if bearings are true north, south, east, or west (defun nsew () (if (and (= (car P1) (car P2)) (< (cadr P1) (cadr P2))) (setq BNG "north") );if (if (and (< (car P1) (car P2)) (= (cadr P1) (cadr P2))) (setq BNG "east") );if (if (and (= (car P1) (car P2)) (> (cadr P1) (cadr P2))) (setq BNG "south") );if (if (and (> (car P1) (car P2)) (= (cadr P1) (cadr P2))) (setq BNG "west") );if );defun ;;; place text on line (setq AA (angle P1 P2) DS (distance P1 P2) P3 (polar P1 AA (/ DS 2.0)) AA1 (strcat (rtos (/ DS 12.0) 2 2) "'") );setq ;calculate bearing from coordinates and format for printing (defun bearing () (setq O (- (car P2) (car P1)) T (- (cadr P2) (cadr P1)) AZMTH (/ (* (atan (/ O T)) 180.0) pi) A (abs AZMTH) D (fix A) M (* 60 (- A D)) S (* 60 (- M (fix M))) M (fix M) );setq (if (= "60" (rtos s 2 0)) (setq M (+ 1 m))) (if (= "60" (rtos s 2 0)) (setq S 0)) (if (= "60" (rtos m 2 0)) (setq D (+ 1 d))) (if (= "60" (rtos m 2 0)) (setq M 0)) (if (< (cadr P2) (cadr P1)) (setq G "S") (setq G "N")) (if (< (car P1) (car P2)) (setq H "E") (setq H "W")) (setq BNG (strcat G "" (if (< D 10) (strcat "0" (rtos D 2 0)) (rtos D 2 0)) "%%d" (if (< M 10) (strcat "0" (rtos M 2 0)) (rtos M 2 0)) "'" (if (< S 10) (strcat "0" (rtos S 2 0)) (rtos S 2 0)) "''" "" H)) );setq ;;; bearing and distance on line (if (or (= 0 (- (car P1) (car P2))) (= 0 (- (cadr P1) (cadr P2)))) (nsew) (bearing)) (command "text" "m" (polar P3 (rem (+ AA (* pi 1.5)) (* pi 2.0)) TH) TH (rtd AA) (strcat BNG " " AA1)) (if (or (> (car P1) (car P2)) (= BNG "south")) (command "rotate" "last" "" P3 180.0) );if (command "line" P1 P2 "") (setq P1 P2) ) (princ);end program cleanly );defun

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost