马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
平法梁重编号程式源码公开
对话框下载:http://blog.mystruc.com/read.php/36.htm

- ;|file:beamresort.lsp
- -------------------------------------------------------------------------------------------------
- Copyright (c) 2006 杨百朋, Eric Sure, [url]www.mystruc.com[/url]
- This software is provided 'as-is', without any express or implied warranty.
- In no event will the authors be held liable for any damages arising from the use of this software.
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it freely,
- subject to the following restrictions:
- 1. The origin of this software must not be misrepresented;
- you must not claim that you wrote the original software.
- If you use this software in a product,
- an acknowledgment in the product documentation would be appreciated but is not required.
- 2. Altered source versions must be plainly marked as such,
- and must not be misrepresented as being the original software.
- 3. Redistributions of source code must retain the above copyright notice,
- this list of conditions and the following disclaimer.
- 4. Redistributions in binary form must reproduce the above copyright notice,
- this list of conditions and the following disclaimer in the documentation
- and/or other materials provided with the distribution.
- 5. This notice may not be removed or altered from any source distribution.
- -------------------------------------------------------------------------------------------------
- edited at 23:47 2006-06-21 by Eric Sure
- |;
- (defun c:fe_be ( / dcl_id
- KL KL1 KL2 WKL WKL1 WKL2 KZL KZL1 KZL2 L L1 L2 XL XL1 XL2 JSL JSL1 JSL2
- mode_resortx mode_resorty RESORT RESORT1 resort_mode mode_sortxy)
-
- (my-cmdbegin 65)
- (princ "Welcome to visit [url]http://www.mystruc.com,the[/url] codes by Eric Sure")
- (setq dcl_id (load_dialog "beamresort.dcl"))
- (if (not (new_dialog "dcl_beamresort" dcl_id)) (exit))
- (defun mode_resort()
- (if (= RESORT 1)
- (progn
- (mode_tile "resort1" 0)
- (if (= RESORT1 1)
- (progn
- (mode_tile "xysort" 1)
- (mode_tile "xresort" 1)
- (mode_tile "yresort" 1))
- ;else
- (progn
- (mode_tile "xysort" 0)
- (mode_tile "xresort" 0)
- (mode_tile "yresort" 0))
- )
- )
- ;else
- (progn
- (mode_tile "resort1" 1)
- (mode_tile "xysort" 1)
- (mode_tile "xresort" 1)
- (mode_tile "yresort" 1))
- )
-
- )
-
- (defun choose_resort ( resortmode )
- (setq RESORT (atoi resortmode)
- RESORT1 (atoi resortmode)
- ;mode_resortx (atoi resortmode)
- ;mode_resorty (atoi resortmode)
- )
- )
- (defun choose_resort1 ( resortmode )
- (setq RESORT1 (atoi resortmode)
- ;mode_resortx (atoi resortmode)
- ;mode_resorty (atoi resortmode)
- )
- )
-
- (defun choose_sortxy ( resortmode )
- (cond
- ((= resortmode "xtoy")(setq mode_sortxy 64))
- ((= resortmode "ytox")(setq mode_sortxy 128))
- )
-
- )
-
- (defun choose_resortx ( resortmode )
- (cond
- ((= resortmode "xminmax")(setq mode_resortx 2))
- ((= resortmode "xmaxmin")(setq mode_resortx 4))
- )
-
- )
- (defun choose_resorty ( resortmode )
- (cond
- ((= resortmode "yminmax")(setq mode_resorty 8))
- ((= resortmode "ymaxmin")(setq mode_resorty 16))
- )
- )
-
- (set_tile "KL1" "KL") (setq KL1 "KL")
- (set_tile "WKL1" "WKL")(setq WKL1 "WKL")
- (set_tile "KZL1" "KZL")(setq KZL1 "KZL")
- (set_tile "L1" "L") (setq L1 "L")
- (set_tile "XL1" "XL") (setq XL1 "XL")
- (set_tile "JSL1" "JSL")(setq JSL1 "JSL")
-
- (set_tile "KL2" "KL") (setq KL2 "KL")
- (set_tile "WKL2" "WKL")(setq WKL2 "WKL")
- (set_tile "KZL2" "KZL")(setq KZL2 "KZL")
- (set_tile "L2" "L") (setq L2 "L")
- (set_tile "XL2" "XL") (setq XL2 "XL")
- (set_tile "JSL2" "JSL")(setq JSL2 "JSL")
-
- (set_tile "KL" "1")(setq KL 1)
- (set_tile "WKL" "1")(setq WKL 1)
- (set_tile "KZL" "1")(setq KZL 1)
- (set_tile "L" "1")(setq L 1)
- (set_tile "XL" "1")(setq XL 1)
- (set_tile "JSL" "1")(setq JSL 1)
- (set_tile "resort" "1") (setq RESORT 1)
- (set_tile "resort1" "1")(setq RESORT1 1)
- (set_tile "xtoy" "1")(setq mode_sortxy 64)
- (set_tile "xminmax" "1") (setq mode_resortx 2)
- (set_tile "yminmax" "1") (setq mode_resorty 8)
- (mode_resort)
- ;(mode_tile "xresort" 1)
- (action_tile "KL1" "(setq KL1 $value)")
- (action_tile "WKL1" "(setq WKL1 $value)")
- (action_tile "KZL1" "(setq KZL1 $value)")
- (action_tile "L1" "(setq L1 $value)")
- (action_tile "XL1" "(setq XL1 $value)")
- (action_tile "JSL1" "(setq JSL1 $value)")
- (action_tile "KL2" "(setq KL2 $value)")
- (action_tile "WKL2" "(setq WKL2 $value)")
- (action_tile "KZL2" "(setq KZL2 $value)")
- (action_tile "L2" "(setq L2 $value)")
- (action_tile "XL2" "(setq XL2 $value)")
- (action_tile "JSL2" "(setq JSL2 $value)")
-
- (action_tile "KL" "(setq KL (atoi $value))")
- (action_tile "WKL" "(setq WKL (atoi $value))")
- (action_tile "KZL" "(setq KZL (atoi $value))")
- (action_tile "L" "(setq L (atoi $value))")
- (action_tile "XL" "(setq XL (atoi $value))")
- (action_tile "JSL" "(setq JSL (atoi $value))")
- (action_tile "resort" "(choose_resort $value)(mode_resort)")
- (action_tile "resort1" "(choose_resort1 $value)(mode_resort)")
- (action_tile "xysort" "(choose_sortxy $value)")
- (action_tile "xresort" "(choose_resortx $value)")
- (action_tile "yresort" "(choose_resorty $value)")
-
-
- (action_tile "accept" "(done_dialog)")
- (action_tile "cancel" "(exit)")
- (start_dialog)
-
- (setq ss (ssget ' ((0 . "TEXT"))))
-
- (setq resort_mode 0)
- ;(princ "=")(princ RESORT)(princ RESORT1)(princ ";")(princ mode_resortx)(princ mode_resorty)
- (if (= 1 RESORT)
- (if (= 1 RESORT1)
- (setq resort_mode 1)
- (progn
- (if mode_resortx (setq resort_mode (+ resort_mode mode_resortx)))
- (if mode_resorty (setq resort_mode (+ resort_mode mode_resorty)))
- (setq resort_mode (+ resort_mode mode_sortxy))
- )
- )
- (setq resort_mode 0)
- )
- ;(princ "mode:") (princ resort_mode)
- (if (= KL 1)
- (beamresort ss KL1 KL2 resort_mode))
- (if (= WKL 1)
- (beamresort ss WKL1 WKL2 resort_mode))
- (if (= KZL 1)
- (beamresort ss KZL1 KZL2 resort_mode))
- (if (= L 1)
- (beamresort ss L1 L2 resort_mode))
- (if (= XL 1)
- (beamresort ss XL1 XL2 resort_mode))
- (if (= JSL 1)
- (beamresort ss JSL1 JSL2 resort_mode))
-
-
- (unload_dialog dcl_id)
- (my-cmdend 65)
- )
- ;--- end interface------
- ;|
- 梁代号替换,按原序重排
- |;
- (defun beamresort( Seletionset Beamheader BeamheaderNew SortType / Rexp ss1 lst1 i j en str str1 str2 n SortType1
- ss1x ss1y lst1x lst1y sslst1x sslst1y x)
- (setq Beamheader (strcase Beamheader)
- BeamheaderNew (strcase BeamheaderNew))
- (setq Rexp (strcat Beamheader "*")
- Startpos (+ 1 (strlen Beamheader)))
- (setq ss1 (ssadd);梁号字符串选择集
- lst1 '()
- i -1)
- ;形成梁号字符串选择集ss1
- (repeat (sslength Seletionset)
- (setq en (ssname Seletionset (setq i (1+ i))))
- (setq str (dxf_read 1 en))
- (if (wcmatch str Rexp)
- (setq ss1 (ssadd en ss1))
- )
- )
- (if ss1
- (cond
- ((= SortType 0) ;不排序
- (setq i -1)
- (repeat (sslength ss1)
- (setq en (ssname ss1 (setq i (1+ i))))
- (setq str (dxf_read 1 en))
- (setq n (get_beam_no str Beamheader))
- (setq str1 (strcat BeamheaderNew (itoa n)))
- (setq str2 (strcat Beamheader (itoa n)))
- (setq str1 (vl-string-subst str1 str2 str))
- (dxf_replace 1 str1 en)
- ))
- ((= SortType 1) ;原序重排
- ;形成梁号排序列表lst1
- (setq i -1)
- (repeat (sslength ss1)
- (setq en (ssname ss1 (setq i (1+ i))))
- (setq str (dxf_read 1 en))
- (setq lst1 (cons (get_beam_no str Beamheader) lst1))
- )
- ;梁号排序
- (if (> (length lst1) 0)
- ;按原序
- (setq lst1 (vl-sort lst1
- (function (lambda (i j) (< i j) ) )) ;从小到大
- )
- )
- ;从1开始编号
- (beamresortmain ss1 lst1 1))
- (T
- ;形成X向(文字90度)梁号选择集ss1x和Y向(文字0度)梁号选择集ss1y
- (setq ss1x (ssadd)
- ss1y (ssadd))
- (setq i -1)
- (repeat (sslength ss1)
- (setq en (ssname ss1 (setq i (1+ i))))
- (setq ang (dxf_read 50 en))
- (if (and (< (* pi 0.25) ang) (> (* pi 1.5) ang))
- (setq ss1x (ssadd en ss1x))
- (setq ss1y (ssadd en ss1y))
- )
- )
- (setq SortType1 (logand 63 SortType))
- (cond
- ((= SortType1 10) ;左->右,下->上
- ;对选择集ss1x和ss1y进行排序
- (setq sslst1x (fevl-sort-text ss1x 4))
- (setq sslst1y (fevl-sort-text ss1y 2)))
- ((= SortType1 12) ;右->左,下->上
- ;对选择集ss1x和ss1y进行排序
- (setq sslst1x (fevl-sort-text ss1x 3))
- (setq sslst1y (fevl-sort-text ss1y 2)))
- ((= SortType1 18) ;左->右,上->下
- ;对选择集ss1x和ss1y进行排序
- (setq sslst1x (fevl-sort-text ss1x 4))
- (setq sslst1y (fevl-sort-text ss1y 1)))
- ((= SortType1 20) ;右->左,上->下
- ;对选择集ss1x和ss1y进行排序
- (setq sslst1x (fevl-sort-text ss1x 3))
- (setq sslst1y (fevl-sort-text ss1y 1)))
- )
- ;形成X和Y向梁号排序列表lst1x和lst1y
- (setq lst1x '()
- lst1y '()
- )
- (foreach x sslst1x
- (progn
- (setq en (cdr x))
- (setq str (dxf_read 1 en))
- (setq str (get_beam_no str Beamheader))
- (if (not (member str lst1x))
- (setq lst1x (cons str lst1x))
- )
- )
- )
- (foreach x sslst1y
- (progn
- (setq en (cdr x))
- (setq str (dxf_read 1 en))
- (setq str (get_beam_no str Beamheader))
- (if (not (member str lst1y))
- (setq lst1y (cons str lst1y))
- )
- )
- )
- (setq lst1x (reverse lst1x)
- lst1y (reverse lst1y))
-
- ;从1开始编号
- (setq SortType1 (logand 224 SortType))
- (cond
- ((= SortType1 64)
- (beamresortmain ss1x lst1x 1)
- (beamresortmain ss1y lst1y (+ 1 (length lst1x))))
- ((= SortType1 128)
- (beamresortmain ss1y lst1y 1)
- (beamresortmain ss1x lst1x (+ 1 (length lst1y))))
- )
-
- );end T
- );end cond
- );end if ss1
- )
- ;;;;;;;;;;;;;;
- (defun beamresortmain ( sset lstnsort nstart / i j en str str1 str2 n )
- (if (> (length lstnsort) 0)
- (progn
- ;梁号重排
- (setq i -1)
- (repeat (sslength sset)
- (setq en (ssname sset (setq i (1+ i))))
- (setq str (dxf_read 1 en))
- ;(setq str (my-string-delete-space str));剔除空格
- (setq n (get_beam_no str Beamheader))
- (setq j -1)
- (repeat (length lstnsort)
- (setq j (1+ j))
- (if (= n (nth j lstnsort))
- (progn
- (setq str1 (strcat BeamheaderNew (itoa (+ j nstart))))
- (setq str2 (strcat Beamheader (itoa n)))
- (setq str1 (vl-string-subst str1 str2 str))
- (dxf_replace 1 str1 en)
- )
- )
- )
- )
- )
- )
- )
- ;取得梁号
- (defun get_beam_no ( string Beamheader / n )
- (setq n (vl-string-position 40 string))
- (if (>= n 0) (setq string (substr str (+ (strlen Beamheader) 1) n)))
- (atoi string)
- )
|