home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Share Gallery 1
/
share_gal_1.zip
/
share_gal_1
/
GR
/
GR505.ZIP
/
LSP.EXE
/
KRAMER.LSP
< prev
next >
Wrap
Text File
|
1989-09-10
|
12KB
|
304 lines
; Dear AutoCAD User;
;
; Below are a set of My favorite macros from the CADENCE series.
; I recommend that they be separated into different files after
; downloading from the BBS. Best of luck and keep on PUDDERING!
;
; Bill Kramer Feb. 1987
;
; =================================================================
; Side View Macro SIDEVIEW.LSP
; by: Bill Kramer CADENCE Vol1 #3 Sept 86
;
; Functions: SVSTRT Initialize Siew View
; SVZSET Set up the Z values for the side view
; SVLINE Draw lines on top and side view
;==================================================================
(prompt "\nLoading SIDEVIEW Macros. (c)1986 Kramer Consulting, Inc.")
(defun c:svstrt ()
(setq zbase (getreal "\nY axis value for Z=0 <0.0>: "))
(if (null zbase) (setq zbase 0.0))
(setvar "CMDECHO" 0)
)
; -----------------------------------------------------------------
(defun c:svzset ()
(setq tz (getreal "\nStarting Elevation bottom:")) ; Z1 value?
(cond ((null tz) ; No entry, use CP or ZBASE values.
(if (null cp) ; Current point equal to nil?
(setq pp (list zbase zbase)) ; Use base value.
(setq pp cp) ; Set elevations from current point.
)
)
(t ; User entry made, ask for Z2 value.
(setq pp (+ tz zbase)) ; Add offset to entry, put in PP.
(setq tz (getreal "\nStarting Elevation top:"))
(if (null tz); No Input read?
(setq pp (list pp pp)) ; Use Bottom entry.
(setq pp (list pp (+ tz zbase))) ;Add offset
)
)
)
(setq tz (getreal "\nEnding Elevation bottom:"))
(cond ((null tz) ; No user entry made, use previous point.
(setq cp pp)
)
(t ; User made entry.
(setq cp (+ tz zbase)) ; Add offset and save in CP.
(setq tz (getreal "\nEnding Elevation top:"))
(if (null tz) ; No input read?
(setq cp (list cp cp)) ;Use bottom value for top.
(setq cp (list cp (+ tz zbase))) ; Add offset.
)
)
)
)
; ----------------------------------------------------------------
(defun c:svline ()
(setq pp (list pp (getpoint "\nStarting Point:")))
(if (eq (cadr pp) nil) ; No input read?
(setq pp (list (car pp) (getvar "LASTPOINT"))) ; Use last point
)
(setq cp (list cp (getpoint (cadr pp) "\nTo Point:"))) ; Build Current point
(while (not (eq (cadr cp) nil)) ; As long as points are entered.
(if (= (caadr pp) (caadr cp))
(prompt "No change in X") ; No change in X, do not draw side view.
(command "line" (list (caadr pp) (caar pp)) ; Draw side view
(list (caadr pp) (cadar pp)) ; Otherwise.
(list (caadr cp) (cadar cp))
(list (caadr cp) (caar cp))
"c"
)
)
(command "line" (cadr pp) (cadr cp) "") ; Line command for top view.
(setq pp cp) ; Set current point into previous point.
(setq cp (list (car cp) (getpoint (cadr pp) "\nTo Point:")))
)
(setq pp (car pp)) ; Set lists to Z vector data only.
(setq cp (car cp))
)
(prompt "\nFunctions loaded, use SVSTRT to establish initial")
(prompt "\nvariable settings. Use SVZSET to set side view z")
(prompt "\nvalues. Use SVLINE to draw on top view and side view! ")
;
; ----------------------< Cut >------------------------------------
;
; =================================================================
; SPSINP Spread Sheet Interface Macro. by Bill Kramer 1986
; CADENCE Magazine October 1986
;
; Read a text file, character by character, building a set of
; columns from the data. Numeric data is expected to be found
; in the comma delimitted format.
;
; Variables Used
;
; COLMS List (Real) Location of decimal point in
; column.
; YY Real Current row location
; FH File Pointer Input file handle
; FNAM String File name
; CH Integer Character read in from file
; TH Real Text Heigh
; TV Real Text Vertical Spacing Distance
; FLAG Integer Header/Trailer flip-flop
; NN Integer Current Column Number
; NX Integer Max column number
; HD String Header (before decimal)
; TR String Trailer (after decimal)
; ====================================================================
; Function SPSTXT, outputs text strings HD and TR.
;
(defun spstxt ()
(setq flag 1) ; Reset Flip/Flop flag for definition of header/trailer.
(setq mmm (* th 0.25)) ; Space between decimal and header number.
(setq tx (- (nth nn colms) mmm))
(command ; Right justify text to just left of decimal location.
"text" "r" (list tx yy) th 0.0
hd
)
(setq tx (+ tx mmm))
(command
"text" (list tx yy) th 0.0
(strcat "." tr)
)
(setq hd "") (setq tr "")(setq nn (1+ nn))
)
; ---------------------------------------------
; Function SPSINP (AutoCAD Macro)
; ---------------------------------------------
(defun c:spsinp ()
(setvar "CMDECHO" 0) ; Turn off command echos
(setq colms (list 0.0)) ; Initialize list of column settings.
(setq hd "") (setq tr "") ; Initialize character string variables.
(setq nx (getint "\nNumber of Columns:"))
(if (not (null nx))
(progn
(prompt "\nShow the Column X locations:")
(repeat nx
(setq colms (cons (car (getpoint)) colms))
)
(setq colms (cdr (reverse colms)))
(setq yy (cadr (getpoint "\nStarting Y Coordinate:")))
(setq th (getreal "\nText Height:"))
(setq tv (getreal "\nVertical Spacing:"))
(setq fnam (getstring "\nName of File:"))
(setq fh (open fnam "r"))
(setq ch 1)(setq nn 0)(setq flag 1)
(if (null fh) (prompt "\nFile not found"))
(while
(not (null fh))
(setq ch (read-char fh))
(cond
((= ch 44) ; Comma ","
(spstxt) ; End of column data, output text.
(if (= nn nx)
(progn
(setq nn 0)
(setq yy (- yy tv))
)
)
)
((= ch 46) ; Period "."
(setq flag 2) ; Remaining characters in trailer.
)
((= ch 10) ; Return, end of line.
(spstxt) ; End of column data, output text.
(setq yy (- yy tv)) ; Prepare for next line.
(setq nn 0)
)
((= ch nil) ; End of file read?
(close fh)
(setq fh nil)
)
((/= ch 32) ; Not a space, add to string.
(if (= flag 1) ; Add to header or trailer?
(setq hd (strcat hd (chr ch)))
(setq tr (strcat tr (chr ch)))
)
)
) ; End of Conditional Test of CH value.
) ; End of While Loop
) ; End of PROGN
) ; End of IF test for column numbers****
;
; ----------------------< Cut >------------------------------------
;
; --------------------------------------------------------
;
; Setpath & Animate Bill Kramer
; CADENCE Magazine January 1987
;
; Define a path (sequence of lines) for a block to
; move along in "real time".
;
(defun c:setpath ()
(prompt "Define a set of two or more points:")
(setq path-list nil)
(setq p1 (getpoint "\nStarting point:"))
(setq path-list (list p1))
(while (not (null (setq p1 (getpoint p1 "\nTo point:"))))
(setq path-list (cons p1 path-list)))
(setq path-list (reverse path-list))
(setq bname (car (entsel "\nSelect block to move:")))
(setq sdst (getdist "\nIncremental distance to move:")))
(defun c:animate ()
(setq elist (entget bname))
(foreach pnt path-list
(setq elist (moveit elist pnt))))
(defun moveit (elist topnt)
(setq dst (distance (cdr (assoc 10 elist)) topnt))
(setq ang (angle (cdr (assoc 10 elist)) topnt))
(setq dp (polar '(0 0) ang sdst))
(setq pdst 0.0)
(while (< (setq pdst (+ pdst sdst)) dst)
(setq elist (entmod
(subst
(cons 10
(mapcar '(lambda (a b) (+ a b))
(cdr (assoc 10 elist)) dp))
(assoc 10 elist)
elist))))
(entmod (subst (cons 10 topnt)
(assoc 10 elist) elist)))
;
; ----------------------< Cut >------------------------------------
;
; ================================================================
; Global Text Change Command Bill Kramer
;
; Edit text generation characteristics in graphics editor.
;
; CADENCE Tutorial Application #8
;
; Variables:
; S1 Selection set
; User User entry string
; Elist Entity list (from selection set accessing)
; New New variable data from user
;
; ================================================================
(defun c:GTCHANGE ()
(setq S1 nil) (gc) ; Clear Selection set for use.
(prompt "\nSelect text objects:")
(setq S1 (ssget))
(ss-sieve S1 "TEXT") ; Utility routine from Listing 2.
(setq User "Go")
(while (/= User "Exit")
(setq User
(strcase
(getstring "\nChange: Style/Height/Oblq angle/Rot angle/ <eXit>:")))
(if (> (strlen User) 1) (setq User (substr User 1 1)))
(cond
((and (/= User "X") (/= User ""))
(setq Code
(cond
((= User "S") 7)
((= User "H") 40)
((= User "O") 51)
((= User "R") 50)
(t nil)))
(cond
((boundp 'Code)
(setq New (getstring "\nNew value:"))
(if (> Code 20) (setq New (atof New)))
(if (and (> Code 49) (< Code 60))
(setq New (* (/ New 180.0) pi)))
(setq CNT -1)
(repeat (sslength S1)
(setq Elist (entget (ssname S1 (setq CNT (1+ CNT)))))
(entmod
(cond
((null (assoc Code Elist))
(append Elist (list (cons Code New))))
(t
(subst (cons Code New) (assoc Code Elist) Elist)
)
)
)
)
)
(t (prompt "\nEntry invalid:")))
)
(t
(setq User "Exit")))))
; ===============================================================
;
; Removes entities from selection set that are not equal to the
; entity type name passed as parameter two.
;
; (ss-sieve S1 Screen) Programming Utility Routine
;
; Variables:
; S1 Selection set
; Screen String of entity type to keep {eg: TEXT, LINE,...}
; CNT Index into selection set
; Elist Current entity list
; ===============================================================
(defun ss-sieve (S1 Screen)
(setq CNT (sslength S1))
(while (> CNT 0)
(setq Elist (entget (ssname S1 (setq CNT (1- CNT)))))
(cond
((/= (cdr (assoc 0 Elist)) Screen)
(ssdel (ssname S1 CNT) S1)))))