;PKPM配筋归并，速度是比较快的那种，关键是归并对象选择要快。曾经还考虑过沿竖向标高（按WMASS.OUT结果）插入并提示归并，
;代码也不困难，木时间确切说是不想搞，木有什么意思。


;PKPM梁配筋图归并;
(setq liangpeijin (list "wpj_beam" "3"))

(defun c:LGB() (pkpmbeam))

(defun pkpmbeam	( / pickboxwucha_beam guibingn wpjdwgposition pt1 pt10 pt11 pt12 pt13 temppt
					wpjbeam1 wpjbeam2 ptbtemp index n wpjtextent wpjtext wpjtextheight wpjtextangle tmp pt2 pt3
				)
	(princ "\nPKPM梁配筋图归并程序")
	(setq
		GuiBingN (getint "\n请输入要归并的层数:")
		GuiBingN (if GuiBingN (1- GuiBingN) 0)
		PT1 (getpoint "\n请输入首层归并图纸参考坐标特征点:")
		index 1
	)
	(repeat GuiBingN
		(setq
			index (+ index 1)
			TempPT (getpoint (strcat "\n请输入第" (itoa index) "层配筋计算简图定位特征点:"))
			WPJdwgPosition (cons TempPT WPJdwgPosition) ;得到其余层定位特征点;
		)
	)
	(alert "\n层定位已完成,下面输入两点供框选首层配筋图纸.")
	(setq
		WPJdwgPosition (reverse WPJdwgPosition)
		PT10 (getpoint "\n下面输入两点供框选首层配筋图纸,请输入第一点:")
	)
	(if pt10
		(setq PT11 (getcorner pt10 "\n请输入第二点:"))
	)
	(or pt10 (exit))
	(setq WPJBeam1 (ssget "C" PT10 PT11 '((0 . "text") (8 . "21000") (1 . "*-*"))))
	(apply 'mai_create_layer liangpeijin)
	(command ".chprop" WPJBeam1 "" "la" (car liangpeijin) "")
	(command ".zoom" "e")
	(foreach tmp WPJdwgPosition
		(setq
			PtbTemp (PanPtbXYZ (list PT10 PT11) PT1 tmp)
			WPJBeam2 (ssget "C" (car PtbTemp) (cadr PtbTemp)  '((0 . "text") (8 . "21000") (1 . "*-*")))
		)
		(if WPJBeam2
			(progn 
				(command ".copy" WPJBeam2 "" "non" tmp "non" PT1)
				(mai_entmake "line" PtbTemp)
			) 
		) 
	) 
	;end repeat,把后面要归并的梁配筋文字移动到首层位置了;

	(setq
		PickBoxWuCHa_Beam (/ (mai_dxf 40 (ssname WPJBeam1 0)) 3) ;由配筋文字大小得到选择框误差大小;
	)
	(foreach pt1 (mai_ssget_2_list WPJBeam1)
		(setq
			WpjText (mai_dxf 1 pt1)
			pt1 (mapcar 'car (mai_data_entget2pline pt1))
			pt1 (cons (last pt1) pt1)
			pt1 (mai_fence_Offset pt1 PickBoxWuCHa_Beam (mai_divide_point (car pt1) (cadr pt1) 1.5))
			pt2
				(cond
					((wcmatch WpjText "G*") WpjText) ;箍筋;
					((wcmatch WpjText "VT*") WpjText) ;扭筋;
					("*-*-*") ;梁面筋或底筋;
				)
			pt3
				(cond
					((wcmatch WpjText "G*") "AsG") ;箍筋;
					((wcmatch WpjText "VT*") "AsT") ;扭筋;
					("As") ;梁面筋或底筋;
				)
			WPJBeam2 (ssget "cp" pt1 (list (cons 0 "text") (cons 8 "21000") (cons 1 pt2)));取得其它层箍筋;
		)
		(if WPJBeam2 (MAXWpjAs_Beam pt3 WpjTextEnt WPJBeam2)) ;如果有选择到就在选出max值赋予WpjTextEnt
	)
	(princ)
)

;PKPM柱配筋图归并;
(defun c:ZGB() (pkpmcolumn))

(defun PKPMColumn ( / PickBoxWuCHa_Column GuiBingN WPJdwgPosition PT1 PT10 PT11 PT12 PT13 TempPT
					 WPJColumn WPJColumn2 PtbTemp index N WpjTextEnt WpjText WpjTextHeight WpjTextAngle pt2 pt3 pt4 oldcecolor
				  )
	(princ "\nPKPM柱配筋图归并程序")
	(setq
		GuiBingN (getint "\n请输入要归并的层数:")
		index 1
		GuiBingN (if GuiBingN (1- GuiBingN) 0)
		PT1 (getpoint "\n请输入首层归并图纸参考坐标特征点:")
	)
	(repeat GuiBingN
		(setq
			index (+ index 1)
			TempPT (getpoint (strcat "\n请输入第" (itoa index) "层配筋计算简图定位特征点:"))
			WPJdwgPosition (append WPJdwgPosition (list TempPT));得到其余层定位特征点;
		)
	)
	(alert "\n层定位已完成,下面输入两点供框选首层配筋图纸.")
	(setq
		PT10 (getpoint "\n下面输入两点供框选首层配筋图纸,请输入第一点:")
		PT11 (getcorner pt10 "\n请输入第二点:")
		WPJColumn (ssget "C" PT10 PT11 '((0 . "text") (8 . "22000")))
		WPJZHouYaBi (ssget "C" PT10 PT11 '((0 . "text") (8 . "28000")))
	)
	(or GBColor
	;归并颜色;
		(setq
			Oldcecolor (getvar "cecolor")
			GBColor (acad_colordlg 7)
		)
	)
	(mai_create_layer "WPJ_Column" GBcolor)
	(mai_create_layer "WPJ_ZHYB" GBcolor)
	(setvar "cecolor" Oldcecolor)
	(command ".chprop" WPJColumn "" "layer" "WPJ_Column" "")
	(command ".chprop" WPJZHouYaBi "" "layer" "WPJ_ZHYB" "")
	(command ".zoom" "e")
	(foreach index WPJdwgPosition
		(setq
			PtbTemp (PanPtbXYZ (list PT10 PT11) PT1 index)
			WPJColumn2 (ssget "C" (car PtbTemp) (cadr PtbTemp)  '((0 . "text") (8 . "22000,28000")))
		)
		(mai_copy WPJColumn2 index PT1)
		(mai_entmake "line" (list (car PtbTemp) (cadr PtbTemp)))
	)
	;end repeat,把后面要归并的柱配筋文字移动到首层位置了;
	(setq
		PickBoxWuCHa_Column (/ (mai_dxf 40 (entget (ssname WPJColumn 0))) 2);由配筋文字大小得到选择框误差大小;
		;一,处理柱配筋值;
	)
	(foreach index (mai_ssget_2_list WPJColumn)
		(setq
			WpjTextEnt (entget index)
			WpjText (mai_dxf 1 WpjTextEnt)
			WpjTextHeight (mai_dxf 40 WpjTextEnt)
			WpjTextAngle (mai_dxf 50 WpjTextEnt)
			Pt1 (mai_dxf 10 WpjTextEnt)
			Pt2 (mai_dxf 11 WpjTextEnt)
			Pt3 (polar Pt2 (+ WpjTextAngle (/ pi 2)) WpjTextHeight)
			Pt4 (polar Pt1 (+ WpjTextAngle (/ pi 2)) WpjTextHeight)
		)
		(cond
			(	(wcmatch WpjText "G*-*");箍筋;
				(setq
					PickBoxWuCHa_Beam
					PickBoxWuCHa_Column
					WPJColumn2 (ssget "cp" (PickOutRec_Beam Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "22000") (1 . "G*-*")));取得其它层箍筋;
				)
				(if WPJColumn2 (MAXWpjAs_Beam "AsG" WpjTextEnt WPJColumn2));此处柱箍筋分离方法同梁筋;
				(setq WPJColumn2 nil)
			)
		  
			(	(wcmatch WpjText "*.*");角筋以及核心区抗剪箍筋;
				(setq
					PickBoxWuCHa_Beam
					PickBoxWuCHa_Column
					WPJColumn2 (ssget "cp" (PickOutRec_Beam Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "22000") (1 . "*.*")));角筋以及核心区抗剪箍筋;
				)
				(if WPJColumn2 (MAXWpjAs_Clu WpjTextEnt WPJColumn2))
				(setq WPJColumn2 nil)
			)
		  
			(	T      ;柱纵筋;
				(setq WPJColumn2 (ssget "cp" (PickOutRec_Column Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "22000"))))
				(if WPJColumn2 (MAXWpjAs_Clu_ZHJ WpjTextEnt WPJColumn2))
				(setq WPJColumn2 nil)
			)
		)
	)
	;二,处理柱轴压比;
	(foreach index (mai_ssget_2_list WPJZHouYaBi)
		(setq
			WpjTextEnt (entget index)
			WpjText (mai_dxf 1 WpjTextEnt)
			WpjTextHeight (mai_dxf 40 WpjTextEnt)
			WpjTextAngle (mai_dxf 50 WpjTextEnt)
			Pt1 (mai_dxf 10 WpjTextEnt)
			Pt2 (mai_dxf 11 WpjTextEnt)
			Pt3 (polar Pt2 (+ WpjTextAngle (/ pi 2)) WpjTextHeight)
			Pt4 (polar Pt1 (+ WpjTextAngle (/ pi 2)) WpjTextHeight)
			WPJZHouYaBi2 (ssget "cp" (PickOutRec_Beam Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "28000")))
		)
		(if WPJZHouYaBi2 (MAXWpjAs_ZHYB WpjTextEnt WPJZHouYaBi2))
	)
	;(clos)
	;(undo_end)
	(princ)
)

;PKPM墙配筋图归并;
(defun c:QGB() (PKPMWall))

(defun PKPMWall ( / PickBoxWuCHa_Wall GuiBingN WPJdwgPosition PT1 PT10 PT11 PT12 PT13 TempPT pt2 pt3 pt4 oldcecolor
					WPJWall WPJWall2 PtbTemp index N WpjTextEnt WpjText WpjTextHeight WpjTextAngle
				)
	;(svos)
	;(setvar "cmdecho" 0)
	;(undo_begin)
	(princ "\nPKPM墙配筋图归并程序，由TITAN编写.QQ:357574033,EMail:STONEK@21CN.COM")
	(setq
		GuiBingN (getint "\n请输入要归并的层数:")
		index 1
		WPJdwgPosition '()
		GuiBingN (if GuiBingN (1- GuiBingN) 0)
		PT1 (getpoint "\n请输入首层归并图纸参考坐标特征点:")
	)
	(repeat GuiBingN
		(setq
			index (+ index 1)
			TempPT (getpoint (strcat "\n请输入第" (itoa index) "层配筋计算简图定位特征点:"))
			WPJdwgPosition (append WPJdwgPosition (list TempPT))
		);得到其余层定位特征点;
		(alert "\n层定位已完成,下面输入两点供框选首层配筋图纸.")
		(setq
			PT10 (getpoint "\n下面输入两点供框选首层配筋图纸,请输入第一点:")
			PT11 (getcorner pt10 "\n请输入第二点:")
			WPJWall (ssget "C" PT10 PT11 '((0 . "text") (8 . "24000")))
			index 0
		)
		(or GBColor  ;归并颜色;
			(setq
				Oldcecolor (getvar "cecolor")
				GBColor (acad_colordlg 7)
			)
		)
		(mai_create_layer "WPJ_Wall" GBcolor)
		(command ".chprop" WPJWall "" "layer" "WPJ_Wall" "")
		(setvar "cecolor" Oldcecolor)
		(command ".zoom" "e")
		(foreach index WPJdwgPosition
			(setq
				PtbTemp (PanPtbXYZ (list PT10 PT11) PT1 index)
				WPJWall2 (ssget "C" (car PtbTemp) (cadr PtbTemp)  '((0 . "text") (8 . "24000")))
			)
			(mai_copy WPJWall2 index PT1)
			(mai_entmake "line" (list (car PtbTemp) (cadr PtbTemp)))
		);end repeat,把后面要归并的柱配筋文字移动到首层位置了;
		(setq
			PickBoxWuCHa_Wall (/ (mai_dxf 40 (entget (ssname WPJWall 0))) 2);由配筋文字大小得到选择框误差大小;
		)
		(foreach index (mai_ssget_2_list WPJWall)
			(setq
				WpjTextEnt (entget index)
				WpjText (mai_dxf 1 WpjTextEnt)
				WpjTextHeight (mai_dxf 40 WpjTextEnt)
				WpjTextAngle (mai_dxf 50 WpjTextEnt)
				Pt1 (mai_dxf 10 WpjTextEnt)
				Pt2 (mai_dxf 11 WpjTextEnt)
				Pt4 (+ WpjTextAngle (/ pi 2))
				Pt3 (polar Pt2 Pt4 WpjTextHeight)
				Pt4 (polar Pt1 Pt4 WpjTextHeight)
			)
			(cond
				(	(wcmatch WpjText "G*");连梁LL箍筋;
					(setq WPJWallBeam2 (ssget "cp" (PickOutRec_WaLL Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "24000") (1 . "G*"))))
					(if WPJWallBeam2 ;如果有选择到就在选出max值赋予WpjTextEnt;
						(MAXWpjAs_Beam "AsG" WpjTextEnt WPJWallBeam2)
					)
				)
		  
				(	(wcmatch WpjText "*-*-*");梁面筋或底筋;
					(setq WPJWallBeam2 (ssget "cp" (PickOutRec_Wall Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "24000") (1 . "*-*-*"))))
					(if WPJWallBeam2 ;如果有选择到就在选出max值赋予WpjTextEnt;
						(MAXWpjAs_Beam "As" WpjTextEnt WPJWallBeam2)
					)
				)

				(	(wcmatch WpjText "H*");墙H筋;
					(setq WPJWall2 (ssget "cp" (PickOutRec_Wall Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "24000") (1 . "H*"))))
					(if WPJWall2 ;如果有选择到就在选出max值赋予WpjTextEnt;
						(MAXWpjAs_Wall "AsH" WpjTextEnt WPJWall2)
					)
				)
			  
				(	T
					(setq WPJWall2 (ssget "cp" (PickOutRec_Wall Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "24000") (1 . "#*"))))
					(if WPJWall2 (MAXWpjAs_Wall "AsV" WpjTextEnt WPJWall2))
				)
			)
		)
	)
	;(clos)
	;(undo_end)
	(princ)
)
;文件2/3

;PKPM墙边缘构件图归并;
(defun c:BYGJGB() (PKPMWallEdge))

(defun PKPMWallEdge ( / PickBoxWuCHa_Wall GuiBingN WPJdwgPosition PT1 PT10 PT11 PT12 PT13 TempPT oldcecolor pt2 pt3 pt4
						WPJWall WPJWall2 PtbTemp index N WpjTextEnt WpjText WpjTextHeight WpjTextAngle
					)
	;(svos)
	;(setvar "cmdecho" 0)
	;(undo_begin)
	(princ "\nPKPM墙边缘构件图归并程序，由TITAN编写.QQ:357574033,EMail:STONEK@21CN.COM")
	(setq
		GuiBingN (getint "\n请输入要归并的层数:")
		index 1
		;WPJdwgPosition '()
		GuiBingN (if GuiBingN (1- GuiBingN) 0)
		PT1 (getpoint "\n请输入首层归并图纸参考坐标特征点:")
	)
	(repeat GuiBingN
		(setq
			index (+ index 1)
			TempPT (getpoint (strcat "\n请输入第" (itoa index) "层边缘构件计算简图定位特征点:"))
			WPJdwgPosition (append WPJdwgPosition (list TempPT))
		)
	);得到其余层定位特征点;
	(alert "\n层定位已完成,下面输入两点供框选首层边缘构件图纸.")
	(setq
		PT10 (getpoint "\n下面输入两点供框选首层边缘构件图纸,请输入第一点:")
		PT11 (getcorner pt10 "\n请输入第二点:")
		WPJWall (ssget "C" PT10 PT11 '((0 . "text") (8 . "7")))
		index 0
	)
	(or GBColor ;归并颜色;
		(setq
			Oldcecolor (getvar "cecolor")
			GBColor (acad_colordlg 7)
		)
	)
	(mai_create_layer "WPJ_WallEdge" GBcolor)
	(setvar "cecolor" Oldcecolor)
	(command ".chprop" WPJWall "" "layer" "WPJ_WallEdge" "")
	(command ".zoom" "e")
	(foreach index WPJdwgPosition
		(setq
			PtbTemp (PanPtbXYZ (list PT10 PT11) PT1 index)
			WPJWall2 (ssget "C" (car PtbTemp) (cadr PtbTemp)  '((0 . "text") (8 . "7")))
		)
		(mai_copy WPJWall2 index PT1)
		(mai_entmake "line" (list (car PtbTemp) (cadr PtbTemp)))
	);end repeat,把后面要归并的柱配筋文字移动到首层位置了;
	(setq
		WPJWall (mai_ssget_2_list WPJWall)
		PickBoxWuCHa_Wall (/ (mai_dxf 40 (entget (car WPJWall))) 2);由配筋文字大小得到选择框误差大小;
	)
	(foreach index WPJWall
		(setq
			WpjTextEnt (entget index)
			WpjText (mai_dxf 1 WpjTextEnt)
			WpjTextHeight (mai_dxf 40 WpjTextEnt)
			WpjTextAngle (mai_dxf 50 WpjTextEnt)
			Pt1 (mai_dxf 10 WpjTextEnt)
			Pt2 (mai_dxf 11 WpjTextEnt)
			Pt4 (+ WpjTextAngle (/ pi 2))
			Pt3 (polar Pt2 Pt4 WpjTextHeight)
			Pt4 (polar Pt1 Pt4 WpjTextHeight)
		)
		(cond
			(	(wcmatch WpjText "Psv*");边缘构件箍筋;
				(setq WPJWallBeam2 (ssget "cp" (PickOutRec_WaLL Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "7") (1 . "Psv*"))))
				(if WPJWallBeam2 ;如果有选择到就在选出max值赋予WpjTextEnt;
					(MAXWpjAs_WallEdge "Psv" WpjTextEnt WPJWallBeam2)
				)
			)
			  
			(	(wcmatch WpjText "As*");主筋面积;
				(setq WPJWallBeam2 (ssget "cp" (PickOutRec_Wall Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "7") (1 . "As*"))))
				(if WPJWallBeam2 ;如果有选择到就在选出max值赋予WpjTextEnt;
					(MAXWpjAs_WallEdge "As" WpjTextEnt WPJWallBeam2)
				)
			)
			  
			(	(wcmatch WpjText "Ls*");Ls长度;
				(setq WPJWall2 (ssget "cp" (PickOutRec_Wall Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "7") (1 . "Ls*"))))
				(if WPJWall2 ;如果有选择到就在选出max值赋予WpjTextEnt;
					(MAXWpjAs_Wall "Ls" WpjTextEnt WPJWall2)
				)
			)
			  
			(	(wcmatch WpjText "Lc*");Lc长度;
				(setq WPJWall2 (ssget "cp" (PickOutRec_Wall Pt1 Pt2 pt3 pt4) '((0 . "text") (8 . "7") (1 . "Lc*"))))
				(if WPJWall2 (MAXWpjAs_Wall "Lc" WpjTextEnt WPJWall2))
			)
		)
	)
	;(clos)
	;(undo_end)
	(princ)
)

(defun PickOutRec_Beam ( pt10 pt11 pt12 pt13 / pt1 pt2 pt3 pt4 ang1 ang2 );梁筋搜索选择框;
	(setq
		ang1 (angle pt10 pt11)
		ang2 (angle pt11 pt12)
		pt1 (polar (polar pt10 ang1 (* -2 PickBoxWuCHa_Beam)) ang2 (- PickBoxWuCHa_Beam))
		pt2 (polar (polar pt11 ang1 (* 2 PickBoxWuCHa_Beam)) ang2 (- PickBoxWuCHa_Beam))
		pt3 (polar (polar pt12 ang1 (* 2 PickBoxWuCHa_Beam)) ang2 PickBoxWuCHa_Beam)
		pt4 (polar (polar pt13 ang1 (* -2 PickBoxWuCHa_Beam)) ang2 PickBoxWuCHa_Beam)
	)
	(list pt1 pt2 pt3 pt4)
)

(defun PickOutRec_Column ( pt10 pt11 pt12 pt13 / pt1 pt2 pt3 pt4 ang1 ang2 );柱筋搜索选择框;
	(setq
		ang1 (angle pt10 pt11)
		ang2 (angle pt11 pt12)
		pt1 (polar (polar pt10 ang1 (- PickBoxWuCHa_Column)) ang2 (- PickBoxWuCHa_Column))
		pt2 (polar (polar pt11 ang1 PickBoxWuCHa_Column) ang2 (- PickBoxWuCHa_Column))
		pt3 (polar (polar pt12 ang1 PickBoxWuCHa_Column) ang2 PickBoxWuCHa_Column)
		pt4 (polar (polar pt13 ang1 (- PickBoxWuCHa_Column)) ang2 PickBoxWuCHa_Column)
	)
	(list pt1 pt2 pt3 pt4)
)

(defun PickOutRec_WaLL (pt10 pt11 pt12 pt13 / ang1 ang2 pt1 pt2 pt3 pt4);墙筋搜索选择框;
	(setq
		ang1 (angle pt10 pt11)
		ang2 (angle pt11 pt12)
		pt1 (polar (polar pt10 ang1 (* -2 PickBoxWuCHa_WaLL)) ang2 (- PickBoxWuCHa_WaLL))
		pt2 (polar (polar pt11 ang1 (* 2 PickBoxWuCHa_WaLL)) ang2 (- PickBoxWuCHa_WaLL))
		pt3 (polar (polar pt12 ang1 (* 2 PickBoxWuCHa_WaLL)) ang2 PickBoxWuCHa_WaLL)
		pt4 (polar (polar pt13 ang1 (* -2 PickBoxWuCHa_WaLL)) ang2 PickBoxWuCHa_WaLL)
	)
	(list pt1 pt2 pt3 pt4)
)
 
(defun MAXWpjAs_Beam ( WPJType WpjTextEnt WPJBeam2 / As AsLeft AsMidd AsRight
					)
	(setq
		WPJBeam2 (mai_ssget_2_list (FilterOtherAngleEnt WpjTextEnt WPJBeam2)) ;过滤掉不同角度的实体;
	)
	(cond
		(	(= WPJType "AsG")
			(setq
				As (mapcar
						'(lambda(X)
							(separateAsv&Ast x)
						)
						(cons WpjTextEnt WPJBeam2)
					)
				AsLeft (apply 'max (mapcar 'car as))
				AsRight (apply 'max (mapcar 'cadr as))
				As (strcat "G" (Real2String AsLeft 1) "-" (Real2String AsRight 1))
				WpjTextEnt (subst (cons 1 As) (assoc 1 WpjTextEnt) WpjTextEnt)
			)
			(entmod WpjTextEnt)
		)
		
		(	(= WPJType "AsT")
			(setq
				As (mapcar
						'(lambda(X)
							(separateAsv&Ast x)
						)
						(cons WpjTextEnt WPJBeam2)
					)
				AsLeft (apply 'max (mapcar 'car as))
				AsRight (apply 'max (mapcar 'cadr as))
				As (strcat "VT" (Real2String AsLeft 0) "-" (Real2String AsRight 1))
				WpjTextEnt (subst (cons 1 As) (assoc 1 WpjTextEnt)  WpjTextEnt)
			)
			(entmod WpjTextEnt)
		)
	   
		(	(= WPJType "As")
			(setq
				As (mapcar
						'(lambda(X)
							(mapcar 'atoi (mai_str2lst (mai_dxf 1 x) "-"))
						)
						(cons WpjTextEnt WPJBeam2)
					)
				AsLeft (apply 'max (mapcar 'car as))
				AsMidd (apply 'max (mapcar 'cadr as))
				AsRight (apply 'max (mapcar 'caddr as))
				As (strcat (itoa AsLeft) "-" (itoa AsMidd) "-" (itoa AsRight))
				WpjTextEnt (subst (cons 1 As) (assoc 1 WpjTextEnt) WpjTextEnt)
			)
			(entmod WpjTextEnt)
		)
	)
	(mai_entdel WPJBeam2 nil)
)

(defun MAXWpjAs_Clu ( WpjTextEnt WPJColumn2 / ColumnAstList As)
	(setq
		WPJColumn2 (mai_ssget_2_list (FilterOtherAngleEnt WpjTextEnt WPJColumn2)) ;过滤掉不同角度的实体;
		ColumnAstList
			(mapcar
				'(lambda(x)(mai_dxf 1 x))
				(cons WpjTextEnt WPJColumn2)
			)
		As (apply 'max (mapcar '(lambda (x) (atof x)) ColumnAstList))
		As (Real2String As 1)
		WpjTextEnt (subst (cons 1 As) (assoc 1 WpjTextEnt) WpjTextEnt)
	)
	(entmod WpjTextEnt)
	(mai_entdel WPJColumn2 nil)
)

(defun MAXWpjAs_Clu_ZHJ ( WpjTextEnt WPJColumn2 / ColumnAstList As)
	(setq
		WPJColumn2 (FilterOtherAngleEnt WpjTextEnt WPJColumn2) ;过滤掉不同角度的实体;
		WPJColumn2 (mai_ssget_2_list (FilterDoteEnt WPJColumn2)) ;在WPJColumn2过滤掉可能含"."的实体;
		ColumnAstList
			(mapcar
				'(lambda(x)(mai_dxf 1 x))
				(cons WpjTextEnt WPJColumn2)
			)
		As (apply 'max (mapcar '(lambda (x) (atof x)) ColumnAstList))
		As (Real2String As 0) ;与上面的function不同的只是小数位数差别;
		WpjTextEnt (subst (cons 1 As) (assoc 1 WpjTextEnt) WpjTextEnt)
	)
	(entmod WpjTextEnt)
	(mai_entdel WPJColumn2 nil)
)

(defun MAXWpjAs_ZHYB ( WpjTextEnt WPJZHouYaBi2 / WpjText ZHYBList index  WpjText2 As)
	(setq
		WPJZHouYaBi2 (FilterOtherAngleEnt WpjTextEnt WPJZHouYaBi2) ;过滤掉不同角度的实体;
		WPJZHouYaBi2 (mai_ssget_2_list WPJZHouYaBi2) ;过滤掉不同角度的实体;
		ZHYBList
			(mapcar
				'(lambda(x)(setq x (mai_dxf 1 x)) (substr x 2 (- (strlen x) 2)))
				(cons WpjTextEnt WPJZHouYaBi2)
			)
		As (apply 'max (mapcar '(lambda (x) (atof x)) ZHYBList))
		As (Real2String As 2)
		As (strcat "(" As ")")
		WpjTextEnt (subst(cons 1 As) (assoc 1 WpjTextEnt)  WpjTextEnt)
	)
	(entmod WpjTextEnt)
	(mai_entdel WPJZHouYaBi2 nil)
)
;文件3/3

(defun MAXWpjAs_Wall ( WPJType WpjTextEnt WPJWall2 / WpjText index  WpjText2 AsHList AsVList AsH AsV)
	(setq
		WPJWall2 (FilterOtherAngleEnt WpjTextEnt WPJWall2);过滤掉不同角度的实体;
		WPJWall2 (mai_ssget_2_list WPJWall2)
	)
	(cond
		(	(= WPJType "AsH")
			(setq
				AsHList
					(mapcar
						'(lambda(x)(substr (mai_dxf 1 x) 2))
						 (cons WpjTextEnt WPJWall2)
					)
				AsH (car (vl-sort AsHList '>))
				AsH (strcat "H" AsH)
				WpjTextEnt (subst(cons 1 AsH) (assoc 1 WpjTextEnt)  WpjTextEnt)
			)
			(entmod WpjTextEnt)
		)
		
		(	(= WPJType "AsV")
			(setq
				AsVList
					(mapcar
						'(lambda(x)(mai_dxf 1 x))
						(cons WpjTextEnt WPJWall2)
					)
				AsV (car (vl-sort AsVList '>))
				WpjTextEnt (subst (cons 1 AsV) (assoc 1 WpjTextEnt) WpjTextEnt)
			)
			(entmod WpjTextEnt)
		)
	)
	(mai_entdel WPJWall2 nil)
)

(defun MAXWpjAs_WallEdge ( WPJType WpjTextEnt WPJWall2 / WpjText2 PsvList Psv AsList1 AsList2 As1 As2 As
														 LsList1 LsList2 Ls1 Ls2 Ls LcList Lc
						 )
	(setq
		WPJWall2 (FilterOtherAngleEnt WpjTextEnt WPJWall2);过滤掉不同角度的实体;
		WPJWall2 (mai_ssget_2_list WPJWall2)
	)
	(cond
		(	(= WPJType "Psv")
			(setq
				PsvList
					(mapcar
						'(lambda(x) (substr (mai_dxf 1 x) 4 4))
						(cons WpjTextEnt WPJWall2)
					)
				Psv (car (vl-sort PsvList '>))
				Psv (strcat "Psv" Psv "%")
				WpjTextEnt (subst (cons 1 Psv) (assoc 1 WpjTextEnt)  WpjTextEnt)
			)
			(entmod WpjTextEnt)
		)
		
		(	(= WPJType "As")
			(if (wcmatch WPJType "*(*%)") ;类似As1400(1.12%);
				(progn
					(setq
						As (mapcar '(lambda(x) (mai_dxf 1 x)) (cons WpjTextEnt WPJWall2))
						AsList1
							(mapcar
								'(lambda(x) (substr x 3 (- (vl-string-position (ascii "(") x) 2)))
								 As
							)
						AsList2
							(mapcar
								'(lambda(x) (substr x (+ 2 (vl-string-position (ascii "(") x)) 4))
								 As
							)
						As1 (car (vl-sort AsList1 '>))
						As2 (car (vl-sort AsList2 '>))
						As (strcat "As" As1 "(" As2 "%)")
					)
				)
				(progn ;类似As1400;
					(setq
						LsList1
							(mapcar
								'(lambda(x)
									(setq x (mai_dxf 1 x))
									(substr x 3 (- (vl-string-position (ascii "(") x) 2))
								)
								(cons WpjTextEnt WPJWall2)
							)
						As1 (car (vl-sort AsList1 '>))
						As (strcat "As" As1)
					)
				)
			);end if;
			(setq WpjTextEnt (subst (cons 1 As) (assoc 1 WpjTextEnt)  WpjTextEnt))
			(entmod WpjTextEnt)
		)
		
		(	(= WPJType "Ls")
			(if (wcmatch WPJType "*/Lt*")
				(progn ;类似Ls350/Lt350;
					(setq
						Ls (mapcar '(lambda(x) (mai_dxf 1 x)) (cons WpjTextEnt WPJWall2))
						LsList1
							(mapcar
								'(lambda(x) (substr x 3 (1- (vl-string-position (ascii "/") x))))
								 Ls
							)
						LsList2
							(mapcar
								'(lambda(x) (substr x (+ 2 (vl-string-position (ascii "t") x))))
								 Ls
							)
						Ls1 (car (vl-sort LsList1 '>))
						Ls2 (car (vl-sort LsList2 '>))
						Ls (strcat "Ls" Ls1 "/Lt" Ls2)
					)
				)
				(progn ;类似Ls350;
					(setq 
						LsList1
							(mapcar
								'(lambda(x) (substr (mai_dxf 1 x) 3))
								(cons WpjTextEnt WPJWall2)
							)
						Ls1 (car (vl-sort LsList1 '>))
						Ls (strcat "Ls" Ls1)
					)
				)
			);end if;
			(setq WpjTextEnt (subst (cons 1 Ls) (assoc 1 WpjTextEnt) WpjTextEnt))
			(entmod WpjTextEnt)
		)
		
		(	(= WPJType "Lc")
			(setq
				LcList
					(mapcar
						'(lambda(x) (substr (mai_dxf 1 x) 3))
						(cons WpjTextEnt  WPJWall2)
					)
				Lc (car (vl-sort LcList '>))
				Lc (strcat "Lc" Lc)
				WpjTextEnt (subst (cons 1 Lc) (assoc 1 WpjTextEnt) WpjTextEnt)
			)
			(entmod WpjTextEnt)
		)
	)
	(mai_entdel WPJWall2 nil)
)

 ;|
(defun separateAsu&Asd ( str / ChaPosition1 ChaPosition2 AsLeft AsMidd AsRight);分离梁面筋和底筋;
  (setq ChaPosition1 (VL-STRING-position (ascii "-") str 0)
		ChaPosition2 (VL-STRING-position (ascii "-") str 0 t)
		AsLeft (substr str 1 ChaPosition1)
		AsMidd (substr str (+ ChaPosition1 2) (- ChaPosition2 ChaPosition1 1))
		AsRight (substr str (+ ChaPosition2 2) (- (strlen str) ChaPosition2))
  )
  (mapcar 'atoi (list AsLeft AsMidd AsRight))
)
;|;

(defun separateAsv&Ast(str / n s1 cha);分离梁箍筋和扭筋;
	(setq
		AsLeft
			(cond
				((wcmatch str "G*") 2)
				((wcmatch str "VT*") 3)
			)
		str (substr str AsLeft)
		ChaPosition1 (vl-string-position (ascii "-") str 0)
		AsLeft (substr str 1 ChaPosition1)
		AsRight (substr str (+ ChaPosition1 2) )
	)
	(list (atof AsLeft) (atof AsRight))
)

(defun FilterOtherAngleEnt ( WpjTextEnt WPJColumn2 / Ang1 ) ;在WPJColumn2过滤掉与WpjTextEnt的文字转角不同的实体;
	(setq Ang1 (mai_dxf 50 WpjTextEnt))
	(mai_list_2_ssget
		(vl-remove-if-not
			'(lambda(x) (mai_equal_angle Ang1 (mai_dxf 50 x)))
			(mai_ssget_2_list WPJColumn2)
		)
	)
)

(defun FilterDoteEnt ( WPJColumn2 ) ;在WPJColumn2过滤掉可能含"."号的实体;
	(mai_list_2_ssget
		(vl-remove-if
			'(lambda(x) (wcmatch (mai_dxf 1 index) "*.*"))
			(mai_ssget_2_list WPJColumn2)
		)
	)
)

(defun PanPtbXYZ ( Ptb SourcePT TargetPT / PanXYZ );求在SourcePT下点表Ptb平移到TargetPT后得到新的坐标;
	(setq PanXYZ (mapcar '- TargetPT SourcePT))
	(mapcar '(lambda (x) (mapcar '+ x PanXYZ)) Ptb)
)

(defun Real2String ( RealNum XiaoShuWeiShu / x y z);实数以及小数位数;
	(cond
		(	(= XiaoShuWeiShu 0)
			(itoa (fix ((if (> RealNum 0) + -) RealNum 0.5)))
		)

		(	(>= XiaoShuWeiShu 1)
			(setq
				x (fix RealNum)
				y (fix (+ 0.5 (* (abs (- RealNum x)) (expt 10 XiaoShuWeiShu))))
				x (itoa x)
				y (itoa y)
				z (strcat x "." y)
			)
		)

		(t (princ "没有定义小数位数为负数的情况!"))
	)
)
