Grossa Speaks Final

コンピュータに関するテーマを
気の向くまま取り上げています。
(時々雑談...)

DenSien InsertBlock.lsp その1 (少し長い)

2010年05月14日 | CAD
;***************************************

;***************************************

;;DenSien(電気図作成支援アプリケーション)

;;File Name "InsertBLK.lsp"

;;Command Name "ibl"

;;

;;By Kim Grossa

;;Ver1.0 April ,2010

;;

;;Action "ブロック挿入"

;;

;;;;How to Use

;;(1)InsertBLK.dclを使用

;;(2)DOSLib.drxを使用しない

;; (BricsCadVersion8用のDOSLibがサポートされなくなったため)

;;

;;

;;

;;THANKS To

;;http://www.afralisp.net/

;;http://www.jefferypsanders.com/autolisp.html

;;http://web2.airmail.net/terrycad/Tutorials/MyDialogs.htm

;;http://en.wiki.mcneel.com/default.aspx/McNeel/DOSLib.html

;***************************************

;***************************************

;

;-----Start of File-----



;------------------

;初期設定 InitSet

;------------------

(defun InitSet()

(setq SIENDIR "C:\\Program Files\\Bricsys\\Bricscad\\")

(setq DENBURODIR (strcat SIENDIR "DenSien\\DenBuroV1_1\\"))

(setq INSNAME "") ;;インサートするブロック名の初期値

(setq QUITFLAG 99) ;;終了フラグの初期値

(setq SECNUM 1) ;;セクション番号の初期値

(setq SECLIMIT 1) ;;最大セクション番号の初期値

(setq UNITAMU 10) ;;sldファイルの表示単位

(setq sStr "1") ;;ポップアップリストの項目の初期値

(setq fFileNum 1) ;;ファイル数フラグの初期値

(setq blknum 0) ;;ブロック番号の初期値

(setq fSel 0) ;;ブロック選択フラグの初期値

(setq SELBLK NIL) ;;選択されたブロックの初期値

(setq StScale "1:50") ;;尺度の初期値 1:50

(setq ascale "50") ;;尺度の初期値 50(1に対して)

(setq fOrth 1) ;;直行モードフラグの初期値

(setvar "ORTHOMODE" 1);;直行モードをON

);defun





;-----------------------

;DListの作成 MakeDList

;-----------------------

(defun MakeDList()

(setq DirList (vl-directory-files DENBURODIR "*.*" -1)) ;;-1 フォルダのみ 0 ファイル、フォルダ 1 ファイルのみ

(setq DirList (cdr DirList)) ;リストの1行目を取り除く

);defun





;-------------------------------------

;ポップアップリストの設定 SetPopList

;-------------------------------------

(defun SetPopList(/ f fsname txtsLine)

;ディレクトリー(フォルダ)の設定

; DListの初期値 "  S21一般配線" ;sStr=1

; "S31機器" ;sStr=2

; "S41一般用照明" ;sStr=3

; "S41防災用照明" ;sStr=4

; "S42コンセント" ;sStr=5

; "S43点滅器" ;sStr=6

; "S44開閉器_計器" ;sStr=7

; "S45配電盤_分電盤等" ;sStr=8

; "S51情報" ;sStr=9

; "S51電話" ;sStr=10

; "S52ナースコール" ;sStr=11

; "S52警報_呼出_表示" ;sStr=12

; "S53電気時計" ;sStr=13

; "S54インターホン" ;sStr=14

; "S54拡声_映像" ;sStr=15

; "S55テレビ共同受信" ;sStr=16

; "S56駐車場管制" ;sStr=17

; "S61自動火災報知" ;sStr=18

; "S62共同住宅用警報" ;sStr=19

; "S63非常警報" ;sStr=20

; "S64消火" ;sStr=21

; "S65自動閉鎖" ;sStr=22

; "S66ガス漏れ警報" ;sStr=23

; "S67無線通信補助" ;sStr=24

; "S68監視カメラ" ;sStr=25

; "S69機械警備" ;sStr=26

; "S70避雷" ;sStr=27

; "S80屋外" ;sStr=28

; "SK1計器" ;sStr=29

; "SK2受変電" ;sStr=30

; "SK3制御盤" ;sStr=31

; "SK4変圧器" ;sStr=32



(setq DList (list "")) ;;ディレクトリのリストをクリア

(MakeDList)

(setq DList DirList)



;尺度の設定

; SListの初期値 "1:50" ;NumScale=1

; "1:100" ;NumScale=2

; "1:200" ;NumScale=3

; "1:500" ;NumScale=4

; "1:1" ;NumScale=5

; "1:2" ;NumScale=6

; "1:5" ;NumScale=7

; "1:10" ;NumScale=8

; "1:20" ;NumScale=9

; "1:30" ;NumScale=10



(setq fsname (strcat DENBURODIR "SList.txt"))



(setq SList (list "")) ;;尺度のリストをクリア

(if(setq h(open fsname "r")) ;;テキストファイルから1行づつ読込む

(while (setq txtsLine(read-line h))

(setq SList(append SList (list txtsLine)))

);while

(progn

(alert "尺度リストがありません。\n 終了します。")

(exit)

);progn

);if

(close h)



);defun





;--------------------------------------------------

;選択されたディレクトリリストの項目を取得 GetItem

;--------------------------------------------------

(defun GetItem()

(setq sStr(get_tile "DList")) ;;リストから選択した項目を取得

);defun





;------------------------------------------

;DWGファイルのリストを取得 GetDWGFileList

;------------------------------------------

(defun GetDWGFileList()

(if (/= sStr "0")

(progn

(setq SelectedDIR (nth (atoi sStr) DList)) ;;ブロックのディレクトリを取得

(setq DWGDir (strcat DENBURODIR SelectedDIR))

(setq dwglocal (vl-directory-files DWGDir "*.dwg" 1)) ;;-1 フォルダのみ 0 ファイル、フォルダ 1 ファイルのみ

);progn

);if

);defun





;------------------------------------------

;SLDファイルのリストを取得 GetSLDFileList

;------------------------------------------

(defun GetSLDFileList()

(if (/= sStr "0")

(progn

(setq SelectedDIR (nth (atoi sStr) DList)) ;;ブロックのディレクトリを取得

(setq SLDDir (strcat DENBURODIR SelectedDIR))

(setq sldlocal (vl-directory-files SLDDir "*.sld" 1)) ;;-1 フォルダのみ 0 ファイル、フォルダ 1 ファイルのみ

);progn

);if

);defun





;--------------------------------------

;DWG,SLDファイルの数を取得 GetFileNum

;--------------------------------------

(defun GetFileNum()

(setq dwgamu (length dwglocal)) ;;dwgファイルの数を取得



(setq sldamu (length sldlocal)) ;;sldファイルの数を取得



(cond

((= sldamu 0)

(alert "SLDファイルがありません。") ;;sldファイルがない場合

(setq fFileNum 99)

)

((= dwgamu 0)

(alert "DWGファイルがありません。") ;;dwgファイルがない場合

(setq fFileNum 99)

)

((/= dwgamu sldamu)

(alert "SLDファイルとDWGファイルの数がちがいます。") ;;dwgファイルとsldファイルの数がちがう場合

(setq fFileNum 99)

)

((= dwgamu sldamu) ;;dwgファイルとsldファイルの数が同じ場合

(setq fFileNum 1)

)

);cond

);defun




最新の画像もっと見る

コメントを投稿