You are on page 1of 16

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

;; 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

"RECTANG" (list z z z)(list x y z))


ssblk (ssadd (entlast) ssblk))
"LINE" (list z (* y 0.5) z)(list x (* y 0.5) z) "")
ssblk (ssadd (entlast) ssblk))

; 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
*

(setq ssblk (ssadd (entlast) ssblk))


(command "SOLID" (list (* x 0.08) (* y 0.5) z)(list (* x 0.08)
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
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)
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
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
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
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
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
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
(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

(* x 0.02) y z)(list (* x 0.02)


(entlast) ssblk))
(* x 0.04) y z)(list (* x 0.04)
(entlast) ssblk))
(* x 0.06) y z)(list (* x 0.06)
(entlast) ssblk))
(* x 0.08) y z)(list (* x 0.08)
(entlast) ssblk))
(* x 0.1) y z)(list (* x 0.1) z
(entlast) ssblk))
(* x 0.15) y z)(list (* x 0.15)
(entlast) ssblk))
(* x 0.2) y z)(list (* x 0.2) z
(entlast) ssblk))
(* x 0.3) y z)(list (* x 0.3) z
(entlast) ssblk))
(* x 0.4) y z)(list (* x 0.4) z
(entlast) ssblk))
(* x 0.5) y z)(list (* x 0.5) z
(entlast) ssblk))
(* x 0.6) y z)(list (* x 0.6) z
(entlast) ssblk))
(* x 0.7) y z)(list (* x 0.7) z
(entlast) ssblk))
(* x 0.8) y z)(list (* x 0.8) z
(entlast) ssblk))
(* x 0.9) y z)(list (* x 0.9) z
(entlast) ssblk))

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"))

(Command "-attdef" ""


ist z (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
) 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
(Command "-attdef" ""
0.6) (+ y 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
0.8) (+ y 1) z) "0")
(setq ssblk (ssadd
(setq
(Command
(Command
(Command
(Command

"1:1000" "Scale" "1:1000" "S" "Gen-Text" "J" "TL" (l


(entlast) ssblk))
"L" "L" "100m" "S" "Gen-Text" "J" "C" (list x (+ y 1
(entlast) ssblk))
"0" "L x 0.0" "0" "S" "Gen-Text" "J" "C" (list z (+
(entlast) ssblk))
"1" "L x 0.1" "10" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))
"2" "L x 0.2" "20" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))
"3" "L x 0.3" "30" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))
"4" "L x 0.4" "40" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))
"5" "L x 0.6" "60" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))
"6" "L x 0.8" "80" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))

ssblk (ssadd (entlast) ssblk))


"CHPROP" ssblk "" "LA" "0" "")
"CHPROP" ssblk "" "LW" "0.13" "")
"CHPROP" ssblk "" "C" "7" "")
"CHPROP" ssblk "" "LT" "Continuous" "")

(command "-BLOCK" "Scale-B" (list (* x 0.5) z z) ssblk "") ; create block


) ;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-B")
)
(vla-put-explodable (vla-Item BLOCKS "Scale-B") :vlax-false)
;;;--- end to disable allow explod----(setvar "OSMODE" osm)
(setvar "attdia" ad)
(setvar "attreq" aq)
(princ)

) ;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)

(if (not (tblsearch "block" "Scale-S"))


(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

"RECTANG" (list z z z)(list (* x 0.5) y z))


ssblk (ssadd (entlast) ssblk))
"LINE" (list z (* y 0.5) z)(list (* x 0.5) (* y 0.5) z) "")
ssblk (ssadd (entlast) ssblk))

; 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
(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

(* x 0.02) y z)(list (* x 0.02)


(entlast) ssblk))
(* x 0.04) y z)(list (* x 0.04)
(entlast) ssblk))
(* x 0.06) y z)(list (* x 0.06)
(entlast) ssblk))
(* x 0.08) y z)(list (* x 0.08)
(entlast) ssblk))
(* x 0.1) y z)(list (* x 0.1) z
(entlast) ssblk))
(* x 0.15) y z)(list (* x 0.15)
(entlast) ssblk))
(* x 0.2) y z)(list (* x 0.2) z
(entlast) ssblk))
(* x 0.3) y z)(list (* x 0.3) z
(entlast) ssblk))
(* x 0.4) y z)(list (* x 0.4) z
(entlast) ssblk))

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

"1:1000" "Scale" "1:1000" "S" "Gen-Text" "J" "TL" (l


(entlast) ssblk))
"L" "L" "50m" "S" "Gen-Text" "J" "C" (list (* x 0.5)
(entlast) ssblk))
"0" "L x 0.0" "0" "S" "Gen-Text" "J" "C" (list z (+
(entlast) ssblk))
"1" "L x 0.2" "10" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))
"2" "L x 0.4" "20" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))
"3" "L x 0.6" "30" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))
"4" "L x 0.8" "40" "S" "Gen-Text" "J" "C" (list (* x
(entlast) ssblk))

ssblk (ssadd (entlast) ssblk))


"CHPROP" ssblk "" "LA" "0" "")
"CHPROP" ssblk "" "LW" "0.13" "")
"CHPROP" ssblk "" "C" "7" "")
"CHPROP" ssblk "" "LT" "Continuous" "")

(command "-BLOCK" "Scale-S" (list (* x 0.25) z z) ssblk "") ; create block

) ;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)

(if (not (tblsearch "block" "Scale-HV"))


(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

"RECTANG" (list z z z)(list x y z))


ssblk (ssadd (entlast) ssblk))
"LINE" (list z (* y 0.5) z)(list x (* y 0.5) z) "")
ssblk (ssadd (entlast) ssblk))

; 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

(* x 0.02) y z)(list (* x 0.02)


(entlast) ssblk))
(* x 0.04) y z)(list (* x 0.04)
(entlast) ssblk))
(* x 0.06) y z)(list (* x 0.06)
(entlast) ssblk))
(* x 0.08) y z)(list (* x 0.08)
(entlast) ssblk))
(* x 0.1) y z)(list (* x 0.1) z
(entlast) ssblk))
(* x 0.15) y z)(list (* x 0.15)
(entlast) ssblk))
(* x 0.2) y z)(list (* x 0.2) z
(entlast) ssblk))
(* x 0.3) y z)(list (* x 0.3) z
(entlast) ssblk))
(* x 0.4) y z)(list (* x 0.4) z
(entlast) ssblk))
(* x 0.5) y z)(list (* x 0.5) z
(entlast) ssblk))
(* x 0.6) y z)(list (* x 0.6) z

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")

"1:100" "Vertical Scale" "(1:100 V)" "S" "Gen-Text"


1) z) "0")
(entlast) ssblk))
"VL" "VL" "10m" "S" "Gen-Text" "J" "TC" (list x (- z
(entlast) ssblk))
"10" "VL x 0.0" "0" "S" "Gen-Text" "J" "TC" (list z
(entlast) ssblk))
"11" "VL x 0.1" "1" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))
"12" "VL x 0.2" "2" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))
"13" "VL x 0.3" "3" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))
"14" "VL x 0.4" "4" "S" "Gen-Text" "J" "TC" (list (*

(setq ssblk (ssadd


(Command "-attdef" ""
x 0.6) (- z 1) z) "0")
(setq ssblk (ssadd
(Command "-attdef" ""
x 0.8) (- z 1) z) "0")
(setq ssblk (ssadd
(setq
(Command
(Command
(Command
(Command

(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))

ssblk (ssadd (entlast) ssblk))


"CHPROP" ssblk "" "LA" "0" "")
"CHPROP" ssblk "" "LW" "0.13" "")
"CHPROP" ssblk "" "C" "7" "")
"CHPROP" ssblk "" "LT" "Continuous" "")

(command "-BLOCK" "Scale-HV" (list (* x 0.5) z z) ssblk "") ; create block


) ;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-HV")
)
(vla-put-explodable (vla-Item BLOCKS "Scale-HV") :vlax-false)
;;;--- end to disable allow explod----(setvar "OSMODE" osm)
(setvar "attdia" ad)
(setvar "attreq" aq)
(princ)
) ;defun
;-------------------------Sub function Scale-HV end------------------------------(defun CHVSS(/ 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)

(if (not (tblsearch "block" "Scale-HV-S"))


(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

"RECTANG" (list z z z)(list (* x 0.5) y z))


ssblk (ssadd (entlast) ssblk))
"LINE" (list z (* y 0.5) z)(list (* x 0.5) (* y 0.5) z) "")
ssblk (ssadd (entlast) ssblk))

; 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

(* x 0.02) y z)(list (* x 0.02)


(entlast) ssblk))
(* x 0.04) y z)(list (* x 0.04)
(entlast) ssblk))
(* x 0.06) y z)(list (* x 0.06)
(entlast) ssblk))
(* x 0.08) y z)(list (* x 0.08)
(entlast) ssblk))
(* x 0.1) y z)(list (* x 0.1) z
(entlast) ssblk))
(* x 0.15) y z)(list (* x 0.15)
(entlast) ssblk))

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)

y z)(list (* x 0.2) z z) "")


ssblk))
y z)(list (* x 0.3) z z) "")
ssblk))
y z)(list (* x 0.4) 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" "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

"1:100" "Vertical Scale" "(1:100 V)" "S" "Gen-Text"


1) z) "0")
(entlast) ssblk))
"VL" "VL" "5m" "S" "Gen-Text" "J" "TC" (list (* x 0.
(entlast) ssblk))
"10" "VL x 0.0" "0" "S" "Gen-Text" "J" "TC" (list z
(entlast) ssblk))
"11" "VL x 0.2" "1" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))
"12" "VL x 0.4" "2" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))
"13" "VL x 0.6" "3" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))
"14" "VL x 0.8" "4" "S" "Gen-Text" "J" "TC" (list (*
(entlast) ssblk))

(setq ssblk (ssadd (entlast) ssblk))


(Command "CHPROP" ssblk "" "LA" "0" "")
(Command "CHPROP" ssblk "" "LW" "0.13" "")

(Command "CHPROP" ssblk "" "C" "7" "")


(Command "CHPROP" ssblk "" "LT" "Continuous" "")
(command "-BLOCK" "Scale-HV-S" (list (* x 0.25) z z) ssblk "") ; create blo
ck
) ;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-HV-S")
)
(vla-put-explodable (vla-Item BLOCKS "Scale-HV-S") :vlax-false)
;;;--- end to disable allow explod----(setvar "OSMODE" osm)
(setvar "attdia" ad)
(setvar "attreq" aq)
(princ)
) ;defun
;--------------------------Sub function Scale-HV-S end---------------;-------------------------------Main Function------------------------(defun SB1(/ ht L Lt a b c d e f g pt ptlist)
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq

L
a
b
c
d
e
f
g

(rtos
0)
(rtos
(rtos
(rtos
(rtos
(rtos
(rtos

(* hsa 0.1) 2 1))


(*
(*
(*
(*
(*
(*

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))

(setq ht (strcat "1:" (rtos hsa)))


(setq Lt (strcat L "m"))
(setq ptlist nil) ; for while command
(while
(progn
(setq PT (getpoint "\nPick Scale Bar location: ")) ;;; input location
(if (not (tblsearch "layer" "Scale bar"))
(command "-LAYER" "N" "Scale bar" "C" "7" "Scale bar" "LT" "Contin
uous" "Scale bar""LW" "0.00" "Scale bar" ""))
(command "CLAYER" "Scale bar")

(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 0.05) 2 1))


(*
(*
(*
(*

hsa
hsa
hsa
hsa

0.01)2
0.02)2
0.03)2
0.04)2

1))
1))
1))
1))

(setq ht (strcat "1:" (rtos hsa)))


(setq Lt (strcat L "m"))
(setq ptlist nil) ; for while command
(while
(progn
(setq PT (getpoint "\nPick Scale Bar location: ")) ;;; input location
(if (not (tblsearch "layer" "Scale bar"))
(command "-LAYER" "N" "Scale bar" "C" "7" "Scale bar" "LT" "Contin
uous" "Scale bar""LW" "0.00" "Scale bar" ""))
(command "CLAYER" "Scale bar")
(CSBS)
(if (not (= pt nil)) (command "-insert" "Scale-S" pt "1" "1" "0" ht L
t a b c d e))
(setq ptlist (append ptlist (list pt))) ; to stop while command
) ;progn
) ;while
(princ)
) ;defun
;-------------------------------Main Function SBS1 end------------------------(defun HVS1(/ hht hl hlt a b c d e f g vht vl vlth i j k l m n pt ptlist)
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq

HL (rtos (* hsa 0.1) 2 1))


a 0)
b (rtos (* hsa 0.01)2 1))
c (rtos (* hsa 0.02)2 1))
d (rtos (* hsa 0.03)2 1))
e (rtos (* hsa 0.04)2 1))
f (rtos (* hsa 0.06)2 1))
g (rtos (* hsa 0.08)2 1))

(setq hht (strcat "(1:" (rtos hsa) " H)"))


(setq HLt (strcat HL "m"))
(setq
(setq
(setq
(setq
(setq
(setq
(setq
(setq

VL (rtos (* vsa 0.1) 2 1))


h 0)
i (rtos (* vsa 0.01)2 1))
j (rtos (* vsa 0.02)2 1))
k (rtos (* vsa 0.03)2 1))
l (rtos (* vsa 0.04)2 1))
m (rtos (* vsa 0.06)2 1))
n (rtos (* vsa 0.08)2 1))

(setq vht (strcat "(1:" (rtos vsa) " V)"))


(setq VLt (strcat VL "m"))
(setq ptlist nil) ; for while command
(while
(progn
(setq PT (getpoint "\nPick Scale Bar location: ")) ;;; input location
(if (not (tblsearch "layer" "Scale bar"))
(command "-LAYER" "N" "Scale bar" "C" "7" "Scale bar" "LT" "Contin
uous" "Scale bar""LW" "0.00" "Scale bar" ""))
(command "CLAYER" "Scale bar")
(CHVS)
(if (not (= pt nil)) (command "-insert" "Scale-HV" pt "1" "1" "0" hht
hlt a b c d e f g vht vlt h i j k l m n))
(setq ptlist (append ptlist (list pt))) ; to stop while command
) ;progn
) ;while
(princ)
) ;defun
;-------------------------------Main Function HVS1 end------------------------(defun HVSS1(/ hht hl hlt a b c d e f g vht vl vlth i j k l m n pt ptlist)
(setq
(setq
(setq
(setq
(setq
(setq

HL (rtos (* hsa 0.05)


a 0)
b (rtos (* hsa 0.01)2
c (rtos (* hsa 0.02)2
d (rtos (* hsa 0.03)2
e (rtos (* hsa 0.04)2

2 1))
1))
1))
1))
1))

(setq hht (strcat "(1:" (rtos hsa) " H)"))


(setq HLt (strcat HL "m"))
(setq
(setq
(setq
(setq
(setq
(setq

VL (rtos (* vsa 0.05)


f 0)
g (rtos (* vsa 0.01)2
h (rtos (* vsa 0.02)2
i (rtos (* vsa 0.03)2
j (rtos (* vsa 0.04)2

2 1))
1))
1))
1))
1))

(setq vht (strcat "(1:" (rtos vsa) " V)"))


(setq VLt (strcat VL "m"))

(setq ptlist nil) ; for while command


(while
(progn
(setq PT (getpoint "\nPick Scale Bar location: ")) ;;; input location
(if (not (tblsearch "layer" "Scale bar"))
(command "-LAYER" "N" "Scale bar" "C" "7" "Scale bar" "LT" "Contin
uous" "Scale bar""LW" "0.00" "Scale bar" ""))
(command "CLAYER" "Scale bar")
(CHVSS)
(if (not (= pt nil)) (command "-insert" "Scale-HV-S" pt "1" "1" "0" h
ht hlt a b c d e vht vlt f g h i j))
(setq ptlist (append ptlist (list pt))) ; to stop while command
) ;progn
) ;while
(princ)
) ;defun
;-------------------------------Main Function HVSS1 end------------------------(defun C:SBB(/ 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)
(command "_.pspace")
; variable input values
(if (not df-hs) (setq df-hs 1000.0))

; default horizontal scale

(setq hs (getreal (strcat "\nEnter Horizontal Scale 1:<" (rtos df-hs 2 0)


">: ")))
(if (not hs) (setq hs df-hs) (setq df-hs hs))
(setq hsa (fix hs))
(if (not df-vs) (setq df-vs 0))
; default horizontal Scale
(setq vs (getreal (strcat "\nEnter Vertical Scale 1:<" (rtos df-vs 2 0) "
>: ")))
(if (not vs) (setq vs df-vs) (setq df-vs vs))
(setq vsa (fix vs))
(if(= vs 0) (SB1) (HVS1))
(princ)

) ;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))

; default horizontal Scale

(setq hs (getreal (strcat "\nEnter Horizontal Scale 1:<" (rtos df-hs 2 0)


">: ")))
(if (not hs) (setq hs df-hs) (setq df-hs hs))
(setq hsa (fix hs))
(if (not df-vs) (setq df-vs 0))
; default horizontal Scale
(setq vs (getreal (strcat "\nEnter Vertical Scale 1:<" (rtos df-vs 2 0) "
>: ")))
(if (not vs) (setq vs df-vs) (setq df-vs vs))
(setq vsa (fix vs))
(if(= vs 0) (SBS1) (HVSS1))
(princ)
) ;defun
(princ "\nScale Bar Lisp | ? Bijoy manoharan 2011 | www.cadlispandtips.com |")
(princ "\nLisp Commands:SB(Half length Scale Bar), SBB(Full Length Scale Bar)")
(princ)
;---------------------------------------End------------------------------------

You might also like