Beruflich Dokumente
Kultur Dokumente
;; Title
: Scale bar
;; Purpose : To Place Scale Bar
;; Written : Bijoy manoharan
;; Web page : www.cadlispandtips.com
;; Command : sb & sbs
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;------------------sub function error-----------------------(defun trap1 (errmsg)
(setvar "clayer" clay)
(setvar "dimzin" di)
(command "undo" "end")
(setq *error* temperr)
(prompt "\n? Bijoy manoharan 2011 www.cadlispandtips.com")
(princ)
) ;defun
;;---------------------Create Blocks--------------------------(defun SBC(/ osm ad aq ssblk x y z )
(setq osm (getvar "OSMODE"))
(setq ad (getvar "attdia"))
(setq aq (getvar "attreq"))
(setvar "OSMODE" 0)
(setvar "attdia" 0)
(setvar "attreq" 1)
(if (not (tblsearch "block" "Scale-B"))
(progn
(setq ssblk (ssadd))
; Set Dimensions
(setq X 100) ; set horizontal dimension
(setq Y 2) ; set Vertical dimension
; Draw Function
(setq Z 0)
; Rectangle
(command
(setq
(command
(setq
; Soild Hatches
(command "SOLID" (list z z z)(list z (* y 0.5) z)(list
t (* x 0.02) (* y 0.5) z) "")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.02) (* y 0.5) z)(list (*
* x 0.04) (* y 0.5) z)(list (* x 0.04) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.04) (* y 0.5) z)(list (*
* x 0.06) (* y 0.5) z)(list (* x 0.06) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.06) (* y 0.5) z)(list (*
* x 0.08) (* y 0.5) z)(list (* x 0.08) y z)"")
(* x 0.02) z z)(lis
x 0.02) y z)(list (
x 0.04) z z)(list (
x 0.06) y z)(list (
*
x
*
x
x
x
x
*
; Lines
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
z z)(list (
z)(list (*
z z)(list (
z)(list (*
z)(list (*
z)(list (*
z)(list (*
z)(list x (
z z) "")
z z) "")
z z) "")
z z) "")
z) "")
z z) "")
z) "")
z) "")
z) "")
z) "")
z) "")
z) "")
z) "")
z) "")
; Attribute texts
(if (not (tblsearch "style" "Gen-Text")) (command "-style" "Gen-Text" "Ari
al.ttf" 2.5 "1" 0 "n" "n"))
) ;defun
;---------------------------------Sub function Scale-B end------------------------------(defun CSBS(/ osm ad aq ssblk x y z )
(setq osm (getvar "OSMODE"))
(setq ad (getvar "attdia"))
(setq aq (getvar "attreq"))
(setvar
(setvar
(setvar
(setvar
"OSMODE"
"dimzin"
"attdia"
"attreq"
0)
8)
0)
1)
; Soild Hatches
(command "SOLID" (list z z z)(list z (* y 0.5) z)(list (* x 0.02) z z)(lis
t (* x 0.02) (* y 0.5) z) "")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.02) (* y 0.5) z)(list (* x 0.02) y z)(list (
* x 0.04) (* y 0.5) z)(list (* x 0.04) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.04) (* y 0.5) z)(list (* x 0.04) z z)(list (
* x 0.06) (* y 0.5) z)(list (* x 0.06) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.06) (* y 0.5) z)(list (* x 0.06) y z)(list (
* x 0.08) (* y 0.5) z)(list (* x 0.08) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.08) (* y 0.5) z)(list (* x 0.08) z z)(list (
* x 0.1) (* y 0.5) z)(list (* x 0.1) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.1) (* y 0.5) z)(list (* x 0.1) y z)(list (*
x 0.15) (* y 0.5) z)(list (* x 0.15) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.15) (* y 0.5) z)(list (* x 0.15) z z)(list (
* x 0.2) (* y 0.5) z)(list (* x 0.2) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.2) (* y 0.5) z)(list (* x 0.2) y z)(list (*
x 0.3) (* y 0.5) z)(list (* x 0.3) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
z z) "")
z z) "")
z z) "")
z z) "")
z) "")
z z) "")
z) "")
z) "")
z) "")
; Attribute texts
(if (not (tblsearch "style" "Gen-Text")) (command "-style" "Gen-Text" "Ari
al.ttf" 2.5 "1" 0 "n" "n"))
(Command "-attdef" ""
ist z (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
(+ y 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
y 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
0.1) (+ y 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
0.2) (+ y 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
0.3) (+ y 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
0.4) (+ y 1) z) "0")
(setq ssblk (ssadd
(setq
(Command
(Command
(Command
(Command
) ;progn
) ;if
;;;--- to disable allow explod----(vl-load-com)
(setq BLOCKS
(vla-get-Blocks
(vla-get-activedocument
(vlax-get-acad-object)
)
)
BLK (vla-Item BLOCKS "Scale-S")
)
(vla-put-explodable (vla-Item BLOCKS "Scale-S") :vlax-false)
;;;--- end to disable allow explod----(setvar "OSMODE" osm)
(setvar "attdia" ad)
(setvar "attreq" aq)
(princ)
) ;defun
;-----------------------------Sub function Scale-S end-----------------------------(defun CHVS(/ osm ad aq ssblk x y z )
(setq osm (getvar "OSMODE"))
(setq ad (getvar "attdia"))
(setq aq (getvar "attreq"))
(setvar
(setvar
(setvar
(setvar
"OSMODE"
"dimzin"
"attdia"
"attreq"
0)
8)
0)
1)
; Soild Hatches
(command "SOLID" (list z z z)(list z (* y 0.5) z)(list (* x 0.02) z z)(lis
t (* x 0.02) (* y 0.5) z) "")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.02) (* y 0.5) z)(list (* x 0.02) y z)(list (
* x 0.04) (* y 0.5) z)(list (* x 0.04) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.04) (* y 0.5) z)(list (* x 0.04) z z)(list (
* x 0.06) (* y 0.5) z)(list (* x 0.06) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.06) (* y 0.5) z)(list (* x 0.06) y z)(list (
* x 0.08) (* y 0.5) z)(list (* x 0.08) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.08) (* y 0.5) z)(list (* x 0.08) z z)(list (
* x 0.1) (* y 0.5) z)(list (* x 0.1) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.1) (* y 0.5) z)(list (* x 0.1) y z)(list (*
x 0.15) (* y 0.5) z)(list (* x 0.15) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.15) (* y 0.5) z)(list (* x 0.15) z z)(list (
* x 0.2) (* y 0.5) z)(list (* x 0.2) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.2) (* y 0.5) z)(list (* x 0.2) y z)(list (*
x 0.3) (* y 0.5) z)(list (* x 0.3) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.3) (* y 0.5) z)(list (* x 0.3) z z)(list (*
x 0.4) (* y 0.5) z)(list (* x 0.4) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.4) (* y 0.5) z)(list (* x 0.4) y z)(list (*
x 0.6) (* y 0.5) z)(list (* x 0.6) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.6) (* y 0.5) z)(list (* x 0.6) z z)(list (*
x 0.8) (* y 0.5) z)(list (* x 0.8) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.8) (* y 0.5) z)(list (* x 0.8) y z)(list x (
* y 0.5) z)(list x y z)"")
(setq ssblk (ssadd (entlast) ssblk))
; Lines
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
z z) "")
z z) "")
z z) "")
z z) "")
z) "")
z z) "")
z) "")
z) "")
z) "")
z) "")
z) "")
(setq
(command
(setq
(command
(setq
(command
(setq
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
(entlast)
(* x 0.7)
(entlast)
(* x 0.8)
(entlast)
(* x 0.9)
(entlast)
ssblk))
y z)(list (* x 0.7) z z) "")
ssblk))
y z)(list (* x 0.8) z z) "")
ssblk))
y z)(list (* x 0.9) z z) "")
ssblk))
; Attribute texts
(if (not (tblsearch "style" "Gen-Text")) (command "-style" "Gen-Text" "Ari
al.ttf" 2.5 "1" 0 "n" "n"))
(Command "-attdef" "" "1:1000" "Horizontal Scale" "(1:1000 H)" "S" "Gen-Te
xt" "J" "BR" (list (- z 2) (+ y 0.26) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "HL" "HL" "100m" "S" "Gen-Text" "J" "C" (list x (+ y
1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "0" "HL x 0.0" "0" "S" "Gen-Text" "J" "C" (list z (+
y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "1" "HL x 0.1" "10" "S" "Gen-Text" "J" "C" (list (*
x 0.1) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "2" "HL x 0.2" "20" "S" "Gen-Text" "J" "C" (list (*
x 0.2) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "3" "HL x 0.3" "30" "S" "Gen-Text" "J" "C" (list (*
x 0.3) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "4" "HL x 0.4" "40" "S" "Gen-Text" "J" "C" (list (*
x 0.4) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "5" "HL x 0.6" "60" "S" "Gen-Text" "J" "C" (list (*
x 0.6) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "6" "HL x 0.8" "80" "S" "Gen-Text" "J" "C" (list (*
x 0.8) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" ""
"J" "TR" (list (- z 2) (- z
(setq ssblk (ssadd
(Command "-attdef" ""
1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
(- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.1) (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.2) (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.3) (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.4) (- z 1) z) "0")
(entlast) ssblk))
"15" "VL x 0.6" "6" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))
"16" "VL x 0.8" "8" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))
"OSMODE"
"dimzin"
"attdia"
"attreq"
0)
8)
0)
1)
; Set Dimensions
(setq X 100) ; set horizontal dimension
(setq Y 2) ; set Vertical dimension
; Draw Function
(setq Z 0)
; Rectangle
(command
(setq
(command
(setq
; Soild Hatches
(command "SOLID" (list z z z)(list z (* y 0.5) z)(list (* x 0.02) z z)(lis
t (* x 0.02) (* y 0.5) z) "")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.02) (* y 0.5) z)(list (* x 0.02) y z)(list (
* x 0.04) (* y 0.5) z)(list (* x 0.04) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.04) (* y 0.5) z)(list (* x 0.04) z z)(list (
* x 0.06) (* y 0.5) z)(list (* x 0.06) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.06) (* y 0.5) z)(list (* x 0.06) y z)(list (
* x 0.08) (* y 0.5) z)(list (* x 0.08) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.08) (* y 0.5) z)(list (* x 0.08) z z)(list (
* x 0.1) (* y 0.5) z)(list (* x 0.1) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.1) (* y 0.5) z)(list (* x 0.1) y z)(list (*
x 0.15) (* y 0.5) z)(list (* x 0.15) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.15) (* y 0.5) z)(list (* x 0.15) z z)(list (
* x 0.2) (* y 0.5) z)(list (* x 0.2) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.2) (* y 0.5) z)(list (* x 0.2) y z)(list (*
x 0.3) (* y 0.5) z)(list (* x 0.3) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.3) (* y 0.5) z)(list (* x 0.3) z z)(list (*
x 0.4) (* y 0.5) z)(list (* x 0.4) z z)"")
(setq ssblk (ssadd (entlast) ssblk))
(command "SOLID" (list (* x 0.4) (* y 0.5) z)(list (* x 0.4) y z)(list (*
x 0.5) (* y 0.5) z)(list (* x 0.5) y z)"")
(setq ssblk (ssadd (entlast) ssblk))
; Lines
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
(command
(setq
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
z z) "")
z z) "")
z z) "")
z z) "")
z) "")
z z) "")
(command
(setq
(command
(setq
(command
(setq
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
"LINE" (list
ssblk (ssadd
(* x 0.2)
(entlast)
(* x 0.3)
(entlast)
(* x 0.4)
(entlast)
; Attribute texts
(if (not (tblsearch "style" "Gen-Text")) (command "-style" "Gen-Text" "Ari
al.ttf" 2.5 "1" 0 "n" "n"))
(Command "-attdef" "" "1:1000" "Horizontal Scale" "(1:1000 H)" "S" "Gen-Te
xt" "J" "BR" (list (- z 2) (+ y 0.26) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "HL" "HL" "50m" "S" "Gen-Text" "J" "C" (list (* x 0.
5) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "0" "HL x 0.0" "0" "S" "Gen-Text" "J" "C" (list z (+
y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "1" "HL x 0.2" "10" "S" "Gen-Text" "J" "C" (list (*
x 0.1) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "2" "HL x 0.4" "20" "S" "Gen-Text" "J" "C" (list (*
x 0.2) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "3" "HL x 0.6" "30" "S" "Gen-Text" "J" "C" (list (*
x 0.3) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" "" "4" "HL x 0.8" "40" "S" "Gen-Text" "J" "C" (list (*
x 0.4) (+ y 1) z) "0")
(setq ssblk (ssadd (entlast) ssblk))
(Command "-attdef" ""
"J" "TR" (list (- z 2) (- z
(setq ssblk (ssadd
(Command "-attdef" ""
5) (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
(- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.1) (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.2) (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.3) (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.4) (- z 1) z) "0")
(setq ssblk (ssadd
L
a
b
c
d
e
f
g
(rtos
0)
(rtos
(rtos
(rtos
(rtos
(rtos
(rtos
hsa
hsa
hsa
hsa
hsa
hsa
0.01)2
0.02)2
0.03)2
0.04)2
0.06)2
0.08)2
1))
1))
1))
1))
1))
1))
(SBC)
(if (not (= pt nil)) (command "-insert" "Scale-B" pt "1" "1" "0" ht L
t a b c d e f g))
(setq ptlist (append ptlist (list pt))) ; to stop while command
) ;progn
) ;while
(princ)
) ;defun
;-------------------------------Main Function SB1 end------------------------(defun SBS1(/ ht L Lt a b c d e pt ptlist)
(setq
(setq
(setq
(setq
(setq
(setq
L
a
b
c
d
e
(rtos
0)
(rtos
(rtos
(rtos
(rtos
hsa
hsa
hsa
hsa
0.01)2
0.02)2
0.03)2
0.04)2
1))
1))
1))
1))
2 1))
1))
1))
1))
1))
2 1))
1))
1))
1))
1))
) ;defun
(defun C:SB(/ clay di df-hs hs hsa df-vs vs vsa)
; store current system variables
(setq clay (getvar "clayer"))
(setq di (getvar "dimzin"))
(setq temperr *error*)
(setq *error* trap1)
; set system variables
(setvar "cmdecho" 0)
(command "undo" "group")
(setvar "dimzin" 8)
(setvar "blipmode" 0)
(setvar "tilemode" 0)
(setvar "tilemode" 0)
(command "_.pspace")
; variable input values
(if (not df-hs) (setq df-hs 1000.0))