1. ;;;** 局部放大图 By Gu_xl 2013.07.24 命令: ZoomMap **
    2. ;;
    3. ;; Copyright (c)2013 Gu_xl
    4. ;; 版权所有 Gu_xl
    5. ;; 程序思路:
    6. ;; 1、首先确定放大范围的边界,可以用圆或多边形放大,计算出圆或多边形的顶点边界的点表PList,因XCLIP的边界为直线段,所以有圆弧的需要用直线来拟合一下。
    7. ;; 2、用(ssget "_CP" Plist)选中放大范围的实体,并将其制成无名块
    8. ;; 3、在原位置插入该无名块,并用XCLIP命令剪裁该无名块,剪裁边界就是PList
    9. ;; 4、根据放大倍数,放大该无名块,移动到相应位置!
    10. ;; 很多人在写放大程序时,都采用Trim对象来剪裁边界,Trim只能剪裁线性对象,块、文字、标注等都无法剪裁!遇到块还要炸开后再剪裁,不仅速度慢,边界往往剪裁不干净。利用剪裁块来做放大程序,优点是速度很快,剪裁边界外绝对不会有剪裁不净的内容!
    11. ;;作者保留本程序的一切权利,但你可以自由拷贝与复制、修改本程序用于非商业目的。
    12. ;;作者尽力将本程序做得完善,但不会因本软件的错失而造成的损失承担任何责任。
    13. ;;本程序仅提供作为应用上的参考, 而未声明或隐含任何保证; 对于任何特殊用途之适
    14. ;;应性, 以及商业销售所隐含作出的保证, 在此一概予以否认。
    15. ;;
    16. (vl-load-com)
    17. ;;;*SysVarNL* 常用系统变量表
    18. (setq *SysVarNL*
    19. (list 'AUNITS 'AUPREC 'ATTDIA 'ATTREQ
    20. 'BLIPMODE 'DIMZIN 'CECOLOR 'CELTYPE
    21. 'CLAYER 'CMDECHO 'TRIMMODE 'EXPERT
    22. 'HIGHLIGHT 'LUNITS 'LUPREC 'EDGEMODE
    23. 'OSMODE 'ORTHOMODE 'TEXTSTYLE 'PLINEWID 'PLINEGEN
    24. 'FILEDIA 'PICKBOX 'QAFLAGS 'UCSAXISANG
    25. 'CELTSCALE 'NOMUTT 'PEDITACCEPT 'Mirrtext 'limcheck
    26. )
    27. ) ;_ setq
    28. ;;;常量定义
    29. (setq *Acad* (vlax-get-acad-object)
    30. *AcDocument* (vla-get-activedocument *Acad*)
    31. *Model-Space* (vla-get-modelspace *AcDocument*)
    32. *Paper-Space* (vla-get-PaperSpace *AcDocument*)
    33. pi2 (* pi 0.5)
    34. pi4 (* pi 0.25)
    35. 2pi (* pi 2.)
    36. 3pi2 (* 1.5 pi)
    37. 3pi4 (+ pi2 pi4)
    38. 5pi4 (+ pi pi4)
    39. 7pi4 (+ 3pi2 pi4)
    40. pi6 (/ pi 6)
    41. 2pi3 (/ pi 3 0.5)
    42. #ZJWS# 2
    43. *jd* 0.00001
    44. en2obj vlax-ename->vla-object
    45. obj2en vlax-vla-object->ename
    46. *Space* (vlax-get-property *AcDocument* (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace))
    47. )
    48. ;;;增加内置函数
    49. (mapcar 'vl-arx-import
    50. '(ACAD_COLORDLG ACAD_truecolordlg ACAD_STRLSORT
    51. INITDIA ACAD-POP-DBMOD ACAD-PUSH-DBMOD
    52. STARTAPP layoutlist Bpoly
    53. )
    54. )
    55. ;;;*********************************************************************************
    56. ;;;*************函数 gxl-layer-restore.lsp *************
    57. ;;(gxl-layer-Restore name delflag) 恢复图层状态,成功返回T,否则返回nil
    58. (defun gxl-layer-Restore (name delflag / lm rtn)
    59. (setq lm
    60. (vla-GetInterfaceObject
    61. *ACAD*
    62. (strcat "AutoCAD.AcadLayerStateManager."
    63. (substr (getvar 'acadver) 1 2)
    64. )
    65. )
    66. )
    67. (vla-SetDatabase lm (vla-get-Database *ACDOCUMENT*))
    68. (setq rtn
    69. (not
    70. (VL-CATCH-ALL-ERROR-P
    71. (VL-CATCH-ALL-APPLY 'vla-Restore (list lm name))
    72. )
    73. )
    74. )
    75. (if delflag
    76. (VL-CATCH-ALL-APPLY 'vla-delete (list lm name)))
    77. rtn
    78. )
    79. ;;;***************** 函数 gxl-layer-Restore*****************
    80. ;;;*************函数 gxl-restoreslayers.lsp *************
    81. ;;;(gxl-restoreslayers) 恢复图层状态
    82. (defun gxl-restoreslayers ()
    83. (gxl-LAYER-RESTORE "#GxlLayerSave" t)
    84. )
    85. ;;;***************** 函数 gxl-restoreslayers*****************
    86. ;;;*************函数 gxl-layer-save.lsp *************
    87. ;;(gxl-layer-Save name Mask) 保存图层状态,成功返回T,否则返回nil
    88. ;|acLsAll All layer properties
    89. acLsColor Color
    90. acLsFrozen Frozen or thawed
    91. acLsLineType Linetype
    92. acLsLineWeight Lineweight
    93. acLsLocked Locked or unlocked
    94. acLsNewViewport New viewport layers frozen or thawed
    95. acLsNone None
    96. acLsOn On or off
    97. acLsPlot Plotting on or off
    98. acLsPlotStyle Plot style
    99. |;
    100. (defun gxl-layer-Save (name Mask / lm)
    101. (if (null Mask)
    102. (setq Mask aclsall))
    103. (setq lm
    104. (vla-GetInterfaceObject
    105. *ACAD*
    106. (strcat "AutoCAD.AcadLayerStateManager."
    107. (substr (getvar 'acadver) 1 2)
    108. )
    109. )
    110. )
    111. (vla-SetDatabase lm (vla-get-Database *ACDOCUMENT*))
    112. (if (VL-CATCH-ALL-ERROR-P
    113. (VL-CATCH-ALL-APPLY 'vla-save (list lm name mask))
    114. )
    115. (progn
    116. (VL-CATCH-ALL-APPLY 'vla-delete (list lm name))
    117. (not
    118. (VL-CATCH-ALL-ERROR-P
    119. (VL-CATCH-ALL-APPLY 'vla-save (list lm name mask))
    120. )
    121. )
    122. )
    123. t
    124. )
    125. )
    126. ;;;***************** 函数 gxl-layer-Save*****************
    127. ;;;*************函数 gxl-storeslayers.lsp *************
    128. ;_ 结束defun
    129. ;;;(gxl-storeslayers) 保存图层状态
    130. (defun gxl-storeslayers (/ layers activelayer layer)
    131. (gxl-layer-Save "#GxlLayerSave" nil)
    132. )
    133. ;;;***************** 函数 gxl-storeslayers*****************
    134. ;;;*************函数 gxl-layer-unlockall.lsp *************
    135. ;;;解锁所有图层 gxl-Layer-UnLockAll 语法 (gxl-Layer-UnLockAll)
    136. (defun gxl-Layer-UnLockAll (/ n)
    137. (vlax-map-Collection
    138. (vla-get-layers
    139. (vla-get-ActiveDocument (vlax-get-acad-object))
    140. )
    141. '(lambda (n)
    142. (vla-put-lock n :vlax-false)
    143. ;(gxl-LOCKLAYERGRAY n) ;_ 锁定灰显
    144. )
    145. )
    146. )
    147. ;;;***************** 函数 gxl-Layer-UnLockAll*****************
    148. ;;;*************函数 gxl-ge-pntinview.lsp *************
    149. ;;(gxl-Ge-GetInsideScreenPts p1 p2) 将P1 p2 截取到当前屏幕显示范围,UcsFlag t,表示提供坐标为Ucs坐标
    150. ;;;**************************************************************************************************
    151. ;; | ----------------------------------------------------------------------------
    152. ;; | (gxl-GE-PntInView pt) 判断点是否在屏幕显示范围内 返回 T or nil
    153. ;; | ----------------------------------------------------------------------------
    154. ;; | Function : Check if point is in current viewport
    155. ;; | Auguments: 'pt' - The point to be checked
    156. ;; | Return : T or nil depending on 'pt' is in viewport or not
    157. ;; | Updated : April 22, 1998
    158. ;; | e-mail : rakesh.rao@4d-technologies.com
    159. ;; | Web : www.4d-technologies.com
    160. ;; | ----------------------------------------------------------------------------
    161. ;(gxl-GE-PntInView '(0 0 0))
    162. (defun gxl-GE-PntInView(pt / vc Y_Len ssz X_Pix Y_Pix X_Len ll ur)
    163. (setq
    164. vc (getvar "VIEWCTR")
    165. Y_Len (getvar "VIEWSIZE")
    166. ssz (getvar "SCREENSIZE")
    167. X_Pix (car ssz)
    168. Y_Pix (cadr ssz)
    169. X_Len (* (/ X_Pix Y_Pix) Y_Len)
    170. ll (polar vc pi (* 0.5 X_Len))
    171. ur (polar ll 0.0 X_Len)
    172. ll (polar ll 3pi2 (* 0.5 Y_Len))
    173. ur (polar ur pi2 (* 0.5 Y_Len))
    174. )
    175. (if (and
    176. (> (car pt) (car ll))
    177. (< (car pt) (car ur))
    178. (> (cadr pt) (cadr ll))
    179. (< (cadr pt) (cadr ur))
    180. )
    181. T
    182. nil
    183. )
    184. )
    185. ;;;***************** 函数 gxl-GE-PntInView*****************
    186. ;;;*************函数 gxl-ge-screenext.lsp *************
    187. ;; | ---------------------------------------------------------------------------
    188. ;; | (gxl-ge-ScreenExt) 返回屏幕的左下角、右上角坐标
    189. ;; | ---------------------------------------------------------------------------
    190. ;; | Function : Returns the co-ordinates of the extents of the current view
    191. ;; | window.
    192. ;; | Arguments: (none)
    193. ;; | Return : (list LL UR)
    194. ;; | LL - Lower Left corner
    195. ;; | UR - Upper Right corner
    196. ;; | Update : January 21, 2003
    197. ;; | e-mail : rakesh.rao@4d-technologies.com
    198. ;; | Web : www.4d-technologies.com
    199. ;; | Comments : Available in VBA
    200. ;; | ---------------------------------------------------------------------------
    201. ;(gxl-ge-ScreenExt)
    202. (defun gxl-ge-ScreenExt ( / VS VC SS 1Pixel dX dY LL UR )
    203. (setq
    204. VS (getvar "VIEWSIZE")
    205. VC (trans (getvar "VIEWCTR") 1 0)
    206. SS (getvar "SCREENSIZE")
    207. 1Pixel (/ VS (cadr SS))
    208. dX (* 0.5 (car SS) 1Pixel)
    209. dY (* 0.5 VS)
    210. LL (list
    211. (- (car VC) dX)
    212. (- (cadr VC) dY)
    213. 0.0
    214. )
    215. UR (list
    216. (+ (car VC) dX)
    217. (+ (cadr VC) dY)
    218. 0.0
    219. )
    220. )
    221. (list LL UR)
    222. )
    223. ;;;***************** 函数 gxl-ge-ScreenExt*****************
    224. ;;;*************函数 gxl-ge-extents.lsp *************
    225. ;; | ---------------------------------------------------------------------------
    226. ;; | (gxl-GE-Extents plist) 返回点表的包围框坐标 '(左下角点 右上角点)
    227. ;; | ---------------------------------------------------------------------------
    228. ;; | Function : Return the x,y and z extents of a list of points
    229. ;; | Argument : 'vlist' - List of points
    230. ;; | Returns : A list of p1 and p2, where p1 is lower left corner point (x,y,z)
    231. ;; | and p2 is the upper right corner point (x,y,z).
    232. ;; | Update : March 6, 1998
    233. ;; | e-mail : rakesh.rao@4d-technologies.com
    234. ;; | Web : www.4d-technologies.com
    235. ;; | ---------------------------------------------------------------------------
    236. ; Return the Extents of a list of points.
    237. (defun gxl-GE-Extents(vlist / MinX MaxX MinY MaxY MinZ MaxZ tmp pt )
    238. (setq
    239. MinX 1E20 MinY 1E20 MinZ 1E20
    240. MaxX -1E20 MaxY -1E20 MaxZ -1E20
    241. )
    242. (foreach pt vlist
    243. (if (< (setq tmp (car pt)) MinX)
    244. (setq MinX tmp)
    245. )
    246. (if (< (setq tmp (cadr pt)) MinY)
    247. (setq MinY tmp)
    248. )
    249. (if (> (setq tmp (car pt)) MaxX)
    250. (setq MaxX tmp)
    251. )
    252. (if (> (setq tmp (cadr pt)) MaxY)
    253. (setq MaxY tmp)
    254. )
    255. (if (and (setq tmp (caddr pt)) (< tmp MinZ))
    256. (setq MinZ tmp)
    257. )
    258. (if (and (setq tmp (caddr pt)) (> tmp MaxZ))
    259. (setq MaxZ tmp)
    260. )
    261. )
    262. (if (= MinZ 1E20) (setq MinZ 0.0))
    263. (if (= MaxZ -1E20) (setq MaxZ 0.0))
    264. (list (list MinX MinY MinZ) (list MaxX MaxY MaxZ))
    265. )
    266. ;;;***************** 函数 gxl-GE-Extents*****************
    267. ;;;*************函数 gxl-ge-zoom2lst.lsp *************
    268. ;; | ----------------------------------------------------------------------------
    269. ;; | (gxl-GE-Zoom2Lst plist) 点表范围显示
    270. ;; | ----------------------------------------------------------------------------
    271. ;; | Function : Zoom to the extents of a list of points
    272. ;; | Arguments:
    273. ;; | 'vlist' - List of points
    274. ;; | Action : Performs a Zoom Window operation using the bottom left and top
    275. ;; | right corners of a list of points
    276. ;; | Updated : November 2, 1998
    277. ;; | e-mail : rakesh.rao@4d-technologies.com
    278. ;; | Web : www.4d-technologies.com
    279. ;; | ----------------------------------------------------------------------------
    280. ;;;(gxl-GE-Zoom2Lst (gxl-getbox (car (entsel))))
    281. (defun gxl-GE-Zoom2Lst( vlist / bl tr Lst OS )
    282. (setq
    283. Lst (gxl-GE-Extents vlist)
    284. bl (car Lst)
    285. tr (cadr Lst)
    286. )
    287. (if (not (and (gxl-GE-PntInView bl) (gxl-GE-PntInView tr)))
    288. (progn
    289. (setq OS (getvar "OSMODE"))
    290. (setvar "OSMODE" 0)
    291. (command
    292. "._Zoom" "_Window" bl tr
    293. "._Zoom" "0.95x"
    294. )
    295. (setvar "OSMODE" OS)
    296. ))
    297. )
    298. ;;;***************** 函数 gxl-GE-Zoom2Lst*****************
    299. ;;;*************函数 gxl-ge-zoominpt.lsp *************
    300. ;; | ----------------------------------------------------------------------------
    301. ;; | (gxl-GE-ZoomInPt pt) 将点显示到屏幕范围内
    302. ;; | ----------------------------------------------------------------------------
    303. ;; | Function : Zooms current extents to include a pt if it lies outside the
    304. ;; | screen
    305. ;; | Argument : [pt] - point of interest
    306. ;; | Return : None
    307. ;; | Updated : December 18, 1998
    308. ;; | e-mail : rakesh.rao@4d-technologies.com
    309. ;; | Web : www.4d-technologies.com
    310. ;; | ----------------------------------------------------------------------------
    311. (defun gxl-GE-ZoomInPt( pt / ptlst )
    312. (if (not (gxl-GE-PntInView pt))
    313. (progn
    314. (setq ptlst (cons pt (gxl-ge-ScreenExt)))
    315. (gxl-GE-Zoom2Lst ptlst)
    316. ))
    317. )
    318. ;;;***************** 函数 gxl-GE-ZoomInPt*****************
    319. ;;;*************函数 gxl-ge-grdrawcross.lsp *************
    320. ;;;(gxl-Ge-GRDrawCross pt size rotation color B) 画十字交叉 参数:pt 点 size 十字大小 rotation 十字旋转角 color 颜色 B T size为绝对大小 nil 屏幕相对大小
    321. ;;;(gxl-Ge-GRDrawCross (getpoint) 5 pi4 1 t)
    322. (defun gxl-Ge-GRDrawCross (pt size rotation color B / pts p1 p2 p3 p4 d)
    323. (gxl-GE-ZoomInPt pt)
    324. (if (not B)
    325. (progn
    326. (setq d (apply '- (mapcar 'cadr (reverse(gxl-GE-SCREENEXT)))))
    327. (setq size (* (/ size 100.0) d))
    328. )
    329. )
    330. (setq p1 (polar pt rotation (* size 0.5))
    331. p2 (polar p1 (+ pi rotation) size)
    332. p3 (polar pt (+ pi2 rotation) (* size 0.5))
    333. p4 (polar pt (+ 3pi2 rotation) (* size 0.5))
    334. )
    335. (IF (MINUSP COLOR)
    336. (PROGN
    337. (SETQ COLOR (ABS COLOR))
    338. (grdraw p1 p2 color 1 )
    339. (grdraw p3 p4 color 1)
    340. )
    341. (PROGN
    342. (grdraw p1 p2 color)
    343. (grdraw p3 p4 color)
    344. )
    345. )
    346. )
    347. ;;;***************** 函数 gxl-Ge-GRDrawCross*****************
    348. ;;;*************函数 gxl-getspace.lsp *************
    349. ;;;得到空间变量
    350. (defun gxl-GetSpace ()
    351. (setq *Space* (vlax-get-property *AcDocument* (if (= 1 (getvar 'CVPORT)) 'PaperSpace 'ModelSpace)))
    352. )
    353. ;;;***************** 函数 gxl-GetSpace*****************
    354. ;;;*************函数 gxl-axaddcircle.lsp *************
    355. ;_ 结束defun
    356. ;;;===================================================================
    357. ;;; (gxl-AX:AddCircle obj pt R) 制造园实体
    358. (defun gxl-AX:AddCircle (obj pt R)
    359. (vla-AddCircle
    360. (if obj obj (gxl-GETSPACE))
    361. (vlax-3d-point pt)
    362. R
    363. ) ;_ 结束vla-Addline
    364. )
    365. ;;;***************** 函数 gxl-AX:AddCircle*****************
    366. ;;;*************函数 gxl-sel-entnextall.lsp *************
    367. ;;;gxl-Sel-EntNextAll en 返回 en 之后的所有物体选择集,无则返回 nil,ennil返回图形全部图元
    368. (defun gxl-Sel-EntNextAll (ent / ss)
    369. (if (not ent)
    370. (progn
    371. (setq ent (entnext))
    372. (if ent
    373. (setq ss (ssadd ent))
    374. (setq ss (ssadd))
    375. )
    376. )
    377. (setq ss (ssadd))
    378. )
    379. (while (setq ent (entnext ent))
    380. (if (not (member (cdr (assoc 0 (entget ent)))
    381. '("ATTRIB" "VERTEX" "SEQEND")
    382. )
    383. )
    384. (ssadd ent ss)
    385. )
    386. )
    387. (if (= 0 (sslength ss))
    388. nil
    389. ss
    390. )
    391. )
    392. ;;;***************** 函数 gxl-Sel-EntNextAll*****************
    393. ;;;*************函数 gxl-command.lsp *************
    394. ;;自定义一个gxl-Command 函数,在lisp中自定义运行任何CAD的command命令,返回选择自,无需考虑cad命令所需参数,
    395. ;;;参数 cad命令字符串,例如:(gxl-Command "line"),返回line命令所画的全部直线选择集
    396. (defun gxl-Command (cmd / EN cmdecho)
    397. (setq cmdecho (getvar "cmdecho"))
    398. (setvar "cmdecho" 1)
    399. (SETQ EN (ENTLAST))
    400. (vl-cmdf cmd)
    401. (while (= 1 (getvar "cmdactive"))
    402. (vl-cmdf pause) ;_ (vl-cmdf "\\")
    403. )
    404. (setvar "cmdecho" cmdecho)
    405. (gxl-SEL-ENTNEXTALL en)
    406. )
    407. ;;;***************** 函数 gxl-Command*****************
    408. ;;;*************函数 gxl-ch_ent.lsp *************
    409. ;;;==================================================================
    410. ;;;(gxl-CH_Ent ent i pt) 用新值pt更新图元ent索引i对应的值
    411. ;;;==================================================================
    412. (defun gxl-CH_Ent (ent i pt / en)
    413. (if (assoc i (setq en (entget ent)))
    414. (setq en (subst (cons i pt) (assoc i en) en))
    415. (setq en (append en (list (cons i pt))))
    416. )
    417. (entmod en)
    418. (entupd ent)
    419. )
    420. ;;;***************** 函数 gxl-CH_Ent*****************
    421. ;;;*************函数 gxl-midpoint.lsp *************
    422. ;;;==================================================================
    423. ;;;gxl-MidPoint 表操作函数,计算两点的中点
    424. ;;;计算两点的中点
    425. ;;;==================================================================
    426. (defun gxl-MidPoint (p1 p2)
    427. (mapcar '(lambda (x) (* x 0.5)) (mapcar '+ p1 p2))
    428. )
    429. ;;;***************** 函数 gxl-MidPoint*****************
    430. ;;;*************函数 gxl-massoc.lsp *************
    431. ;;;==================================================================
    432. ;;;gxl-massoc 返回包含每一出现在列表中的指定键的cdr(点对的后部分)的列表。
    433. ;|功能
    434. 返回包含每一出现在列表中的指定键的cdr(点对的后部分)的列表。
    435. 参数
    436. 一个整数和一个图元定义列表
    437. 示例
    438. (gxl-massoc 10 (entget (car (entsel))))
    439. 注意
    440. 该函数特别适合用于找到细多义线上的所有顶点。
    441. |;
    442. ;;;==================================================================
    443. (defun gxl-massoc (key alist)
    444. (if (= 'ename (type alist))
    445. (setq alist (entget alist))
    446. )
    447. (mapcar 'cdr
    448. (vl-remove-if-not '(lambda (x) (equal key (car x))) alist)
    449. )
    450. )
    451. ;;;***************** 函数 gxl-massoc*****************
    452. ;;;*************函数 gxl-listp.lsp *************
    453. ;;;(gxl-listp lst) 判断表是否为真正的表,非nil、非点对表
    454. ;;;(gxl-listp nil) nil (gxl-listp '(1 . 2)) (gxl-listp '(1 2))
    455. (defun gxl-listp (lst)
    456. (and (vl-consp lst)
    457. (vl-list-length lst)
    458. )
    459. )
    460. ;;;***************** 函数 gxl-listp*****************
    461. ;;;*************函数 gxl-dxf.lsp *************
    462. ;;;==================================================================
    463. ;;;(gxl-dxf ent i )取出图元索引i对应的值
    464. ;;;==================================================================
    465. (defun gxl-dxf (ent i)
    466. (if (= (type ent) 'ename)
    467. (setq ent (entget ent '("*")))
    468. )
    469. (cond ((atom i)
    470. (cdr (assoc i ent))
    471. )
    472. ((gxl-listp i)
    473. (mapcar '(lambda (x) (cdr (assoc x ent))) i)
    474. )
    475. )
    476. )
    477. ;;;***************** 函数 gxl-dxf*****************
    478. ;;;*************函数 gxl-mat-mxm.lsp *************
    479. ;; Matrix x Matrix - Lee Mac 2010
    480. ;; Args: m,n - nxn matrices
    481. ;;;(gxl-Mat-MxM m v ) 矩阵*矩阵
    482. ;|(defun gxl-Mat-MxM ( m n )
    483. ( (lambda ( a ) (mapcar '(lambda ( r ) (gxl-Mat-MXV a r)) m)) (gxl-Mat-trp n))
    484. )|;
    485. ;(gxl-Mat-MxM '((3 5 2 1) (0 3 0 4) (1 1 1 1)(1 -1 -3 2)) '((3 5 2 1) (0 3 0 4) (1 1 1 1)(1 -1 -3 2)))
    486. ;(gxl-Mat-Compose '((3 5 2 1) (0 3 0 4) (1 1 1 1)(1 -1 -3 2)) '((3 5 2 1) (0 3 0 4) (1 1 1 1)(1 -1 -3 2)))
    487. ;;(gxl-Mat-MxM '((3 5 2 1) (0 3 0 4) ) '((3 5 ) ( 0 4) ( 1 1)(1 -1 -))) (gxl-Mat-MxM '((3 5 ) ( 0 4) ( 1 1)(1 -1 -)) '((3 5 2 1) (0 3 0 4) ))
    488. (defun gxl-Mat-MxM (m n)
    489. (
    490. (lambda (a)
    491. (mapcar '(lambda (r)
    492. (mapcar '(lambda (s) (apply '+ (mapcar '* s r))) a)
    493. )
    494. m
    495. )
    496. )
    497. (apply 'mapcar (cons 'list n))
    498. )
    499. )
    500. ;;;***************** 函数 gxl-Mat-MxM*****************
    501. ;;;*************函数 gxl-mat-mxmxm.lsp *************
    502. ;;(gxl-Mat-MxMxM MatLst) 矩阵连续相乘,MatLst变换顺序自右向左
    503. (defun gxl-Mat-MxMxM (MatLst)
    504. (if (car MatLst)
    505. (if (cdr MatLst)
    506. (gxl-Mat-MxM
    507. (car MatLst)
    508. (gxl-Mat-MxMxM (cdr MatLst))
    509. )
    510. (car MatLst)
    511. )
    512. )
    513. )
    514. ;;;***************** 函数 gxl-Mat-MxMxM*****************
    515. ;;;*************函数 gxl-mat-translation.lsp *************
    516. ;;;-----------------------------------------------------------;;
    517. ;;; (gxl-Mat-Translation v) 平移变换矩阵方式1 ;;
    518. ;;; 参数: ;;
    519. ;;; v - 位移矢量 ;;
    520. ;;;-----------------------------------------------------------;;
    521. ;;;---------------=={ Translate by Matrix }==-----------------;;
    522. ;;; ;;
    523. ;;; Translation Matrix ;;
    524. ;;;-----------------------------------------------------------;;
    525. ;;; Author: highflybird, Copyright ? 2012 ;;
    526. ;;;-----------------------------------------------------------;;
    527. ;;; Arguments: ;;
    528. ;;; v - Displacement vector by which to translate ;;
    529. ;;;-----------------------------------------------------------;;
    530. (defun gxl-Mat-Translation ( v )
    531. (list
    532. (list 1. 0. 0. (car v))
    533. (list 0. 1. 0. (cadr v))
    534. (list 0. 0. 1. (caddr v))
    535. (list 0. 0. 0. 1.)
    536. )
    537. )
    538. ;;;***************** 函数 gxl-Mat-Translation*****************
    539. ;;;*************函数 gxl-mat-rotatez.lsp *************
    540. ;;; gxl-Mat-RotateZ Z軸旋转矩阵
    541. (defun gxl-Mat-RotateZ (an)
    542. (list (list (cos an) (- (sin an)) 0. 0.)
    543. (list (sin an) (cos an) 0. 0.)
    544. '(0. 0. 1. 0.)
    545. '(0. 0. 0. 1.)
    546. )
    547. )
    548. ;;;***************** 函数 gxl-Mat-RotateZ*****************
    549. ;;;*************函数 gxl-mat-scale.lsp *************
    550. ;;; gxl-Mat-Scale 缩放矩阵
    551. ;;;(gxl-Mat-Scale 2)
    552. (defun gxl-Mat-Scale (s)
    553. (cond
    554. ((and (= (type s) 'list) (= (length s) 3))
    555. ;;X Y Z 不等比缩放,CAD不接受非
    556. (list (list (car s) 0. 0. 0.) ;等比矩阵
    557. (list 0. (cadr s) 0. 0.)
    558. (list 0. 0. (caddr s) 0.)
    559. '(0. 0. 0. 1.)
    560. )
    561. )
    562. ((numberp s) ;等比缩放
    563. (list (list s 0. 0. 0.)
    564. (list 0. s 0. 0.)
    565. (list 0. 0. s 0.)
    566. '(0. 0. 0. 1.)
    567. )
    568. )
    569. )
    570. )
    571. ;;;***************** 函数 gxl-Mat-Scale*****************
    572. ;;;*************函数 gxl-mat-transform1.lsp *************
    573. ;;(gxl-Mat-TransForm1 scale rotate move) 计算平移、旋转、缩放矩阵
    574. ;;参数 scale = 缩放比例或XYZ缩放比例表'(sx sy sz)
    575. ;; rotate = 旋转角
    576. ;; move = 平移参数表 '(dx dy dz)
    577. (defun gxl-Mat-TransForm1 (scale rotate move)
    578. (gxl-Mat-MxMxM
    579. (list (gxl-Mat-Translation move)
    580. (gxl-Mat-RotateZ rotate)
    581. (gxl-Mat-Scale scale)
    582. )
    583. )
    584. )
    585. ;;;***************** 函数 gxl-Mat-TransForm1*****************
    586. ;;;*************函数 gxl-pt-》3d.lsp *************
    587. ;;; (gxl-pt->3d p) 无条件转换为3维点,
    588. (defun gxl-pt->3d (p)
    589. (cond ((= 'LIST (type p))
    590. (if (= 1 (length p))
    591. (list (if (= 'REAL (type (car p))) (car p) (atof (itoa (car p)))) 0.0 0.0)
    592. (if (= 2 (length p))
    593. (list (if (= 'REAL (type (car p))) (car p) (atof (itoa (car p))))
    594. (if (= 'REAL (type (cadr p))) (cadr p) (atof (itoa (cadr p))))
    595. 0.0
    596. )
    597. (list (if (= 'REAL (type (car p))) (car p) (atof (itoa (car p))))
    598. (if (= 'REAL (type (cadr p))) (cadr p) (atof (itoa (cadr p))))
    599. (if (= 'REAL (type (caddr p))) (caddr p) (atof (itoa (caddr p))))
    600. )
    601. )
    602. )
    603. )
    604. ((= 'REAL (type p))
    605. (list p 0.0 0.0)
    606. )
    607. ((= 'INT (type p))
    608. (list (atof (itoa p)) 0.0 0.0)
    609. )
    610. (t nil)
    611. )
    612. )
    613. ;;;***************** 函数 gxl-pt->3d*****************
    614. ;;;*************函数 gxl-mat-mxv.lsp *************
    615. ;; Matrix x Vector - Lee Mac 2010
    616. ;; Args: m - nxn matrix, v - vector in R^n
    617. ;;;(gxl-Mat-MXV m v ) 矩阵*向量 ,即坐标转换 4X4矩阵 * 向量
    618. ;;;(gxl-Mat-MXV '((1.57897 -1.84131 0.0 1144.8) (1.22754 2.36845 0.0 312.421) (0.0 0.0 2.0 0.0) (0.0 0.0 0.0 1.0)) (append (getpoint) '(1)))
    619. ;;(gxl-Mat-MXV (gxl-Mat-TRP (nth 2 (nentsel))) '(0 0 0 1))
    620. (defun gxl-Mat-MXV (m v)
    621. (mapcar '(lambda (r) (apply '+ (mapcar '* r v))) m)
    622. )
    623. ;;;***************** 函数 gxl-Mat-MXV*****************
    624. ;;;*************函数 gxl-mat-mxp.lsp *************
    625. ;;;(gxl-Mat-MxP m p ) 4X4矩阵*点 得到转换后的点
    626. ;;(gxl-Mat-MxP '((1.57897 -1.84131 0.0 1144.8) (1.22754 2.36845 0.0 312.421) (0.0 0.0 2.0 0.0) (0.0 0.0 0.0 1.0)) (getpoint))
    627. (defun gxl-Mat-MxP (m p / v)
    628. (setq v (append (gxl-pt->3d p) '(1.0)))
    629. (reverse (cdr (reverse (gxl-Mat-MxV m v))))
    630. )
    631. ;;;***************** 函数 gxl-Mat-MxP*****************
    632. ;;;*************函数 gxl-xclipboundary.lsp *************
    633. ;;(gxl-XClipBoundary ename) 计算XClip的包围点,某些情况不行
    634. ;;(gxl-ge-grdrawbox (gxl-XClipBoundary (car(entsel))) 1)
    635. ;; http://www.theswamp.org/index.php?topic=39201.0 LeeMac
    636. ;;(gxl-XClipBoundary ename) 计算XClip的包围点
    637. ;;;(gxl-ge-grdrawlines (gxl-XClipBoundary (car(entsel))) 3 t)
    638. (defun gxl-XClipBoundary
    639. (ENAME / ISXCLIP EL PL DXF40 SCALE ROTATE MOVE M0 M1 n)
    640. (defun IsXClip (ename / xdict)
    641. (if
    642. (setq xdict (cdr (assoc 360 (entget ename))))
    643. (IsXClip xdict)
    644. (if
    645. (and
    646. (eq "SPATIAL_FILTER"
    647. (cdr (assoc 0 (setq ename (entget ename))))
    648. )
    649. (eq 1 (cdr (assoc 71 ename)))
    650. )
    651. ename
    652. )
    653. )
    654. )
    655. (if (setq el (IsXClip ename))
    656. (progn
    657. (setq pl (gxl-massoc 10 el) ;_ 顶点坐标
    658. n (gxl-dxf el 70)
    659. dxf40 (gxl-massoc 40 el) ;_ 矩阵数据表
    660. scale (list (gxl-dxf ename 41)
    661. (gxl-dxf ename 42)
    662. (gxl-dxf ename 43)
    663. ) ;_ 缩放比例
    664. rotate (gxl-dxf ename 50) ;_ 旋转角度
    665. move (gxl-dxf ename 10) ;_ 平移参数
    666. )
    667. (if (= 1 (gxl-dxf el 72)) (setq dxf40 (cdr dxf40)))
    668. (setq m0
    669. (list
    670. (list (nth 0 dxf40)
    671. (nth 1 dxf40)
    672. (nth 2 dxf40)
    673. (nth 3 dxf40)
    674. )
    675. (list (nth 4 dxf40)
    676. (nth 5 dxf40)
    677. (nth 6 dxf40)
    678. (nth 7 dxf40)
    679. )
    680. (list (nth 8 dxf40)
    681. (nth 9 dxf40)
    682. (nth 10 dxf40)
    683. (nth 11 dxf40)
    684. )
    685. '(0 0 0 1)
    686. )
    687. ) ;_ 顶点的变换矩阵
    688. (if (= 2 n)
    689. (progn
    690. (list (car pl)
    691. (list (caar pl) (cadadr pl) (caddar pl))
    692. (cadr pl)
    693. (list (caadr pl) (cadar pl) (caddar pl))
    694. )
    695. )
    696. pl
    697. )
    698. (setq m1 (gxl-Mat-TransForm1 scale rotate move)) ;_ 图块的变换矩阵 Def -> Ref
    699. (setq pl (mapcar '(lambda (x) (gxl-mat-mxp (gxl-MAT-MXM m1 m0) x)) pl)) ;_ 点的矩阵变换
    700. )
    701. )
    702. )
    703. ;;;***************** 函数 gxl-XClipBoundary*****************
    704. ;;;*************函数 gxl-getbox.lsp *************
    705. ;;;*******************************************************************************************************
    706. ;;By Longxin 明经通道 2005.06
    707. ;;gxl-getbox 取得实体外矩形框
    708. ;;例:(gxl-getbox 图元名)
    709. ;;返回:((x1 y1 z1)_min (x2 y2 z2)_max)
    710. ;;(gxl-Ge-GRDrawBox (gxl-getbox (car (entsel)) ) 1)
    711. (defun gxl-getbox (E1 / OBJ MINPOINT MAXPOINT P1 P2 P3 P4 D DD PL D1 D3 D2 D4 name ll)
    712. (if (= 'ENAME (type e1))
    713. (setq obj (vlax-ename->vla-object e1)) ;转换图元名
    714. (setq obj e1
    715. e1 (vlax-vla-object->ename e1)
    716. )
    717. )
    718. (if (not
    719. (VL-CATCH-ALL-ERROR-P
    720. (VL-CATCH-ALL-APPLY
    721. 'vla-GetBoundingBox
    722. (list obj 'minpoint 'maxpoint)
    723. )
    724. )
    725. )
    726. (progn
    727. ;取得包容图元的最大点和最小点
    728. (setq minpoint (vlax-safearray->list minpoint))
    729. ;把变体数据转化为表
    730. (setq maxpoint (vlax-safearray->list maxpoint))
    731. ;把变体数据转化为表
    732. ;;(command "box" minpoint maxpoint 2)
    733. (cond
    734. ((= (vla-get-objectname obj) "AcDbSpline")
    735. (setq p1 minpoint
    736. p2 (list (car minpoint) (cadr maxpoint) (caddr minpoint))
    737. p3 maxpoint
    738. p4 (list (car maxpoint) (cadr minpoint) (caddr minpoint))
    739. )
    740. (setq d (/ (distance p1 p2) 250)
    741. dd (- d)
    742. pl nil
    743. )
    744. (repeat 251
    745. (setq pl (cons (polar p1 pi2 (setq dd (+ dd d))) pl))
    746. )
    747. (setq d1
    748. (car (vl-sort
    749. (mapcar
    750. '(lambda (x)
    751. (distance x
    752. (vlax-curve-getclosestpointto obj x)
    753. )
    754. )
    755. pl
    756. )
    757. '(lambda (a b) (< a b))
    758. )
    759. )
    760. )
    761. (setq dd (- d)
    762. pl nil
    763. )
    764. (repeat 251
    765. (setq pl (cons (polar p4 pi2 (setq dd (+ dd d))) pl))
    766. )
    767. (setq d3
    768. (car (vl-sort
    769. (mapcar
    770. '(lambda (x)
    771. (distance x
    772. (vlax-curve-getclosestpointto obj x)
    773. )
    774. )
    775. pl
    776. )
    777. '(lambda (a b) (< a b))
    778. )
    779. )
    780. )
    781. (setq d (/ (distance p2 p3) 250)
    782. dd (- d)
    783. pl nil
    784. )
    785. (repeat 251
    786. (setq pl (cons (polar p2 0 (setq dd (+ dd d))) pl))
    787. )
    788. (setq d2
    789. (car (vl-sort
    790. (mapcar
    791. '(lambda (x)
    792. (distance x
    793. (vlax-curve-getclosestpointto obj x)
    794. )
    795. )
    796. pl
    797. )
    798. '(lambda (a b) (< a b))
    799. )
    800. )
    801. )
    802. (setq dd (- d)
    803. pl nil
    804. )
    805. (repeat 251
    806. (setq pl (cons (polar p1 0 (setq dd (+ dd d))) pl))
    807. )
    808. (setq d4
    809. (car (vl-sort
    810. (mapcar
    811. '(lambda (x)
    812. (distance x
    813. (vlax-curve-getclosestpointto obj x)
    814. )
    815. )
    816. pl
    817. )
    818. '(lambda (a b) (< a b))
    819. )
    820. )
    821. )
    822. (list (list (+ (car minpoint) d1)
    823. (+ (cadr minpoint) d4)
    824. (caddr minpoint)
    825. )
    826. (list (- (car maxpoint) d3)
    827. (- (cadr maxpoint) d2)
    828. (caddr minpoint)
    829. )
    830. )
    831. )
    832. ((setq ll (gxl-XClipBoundary e1)) ;_ XClip盒子
    833. (list (apply 'mapcar (cons 'min ll))
    834. (apply 'mapcar (cons 'max ll))
    835. )
    836. )
    837. (t
    838. (list minpoint maxpoint)
    839. )
    840. )
    841. )
    842. (list (getvar 'extmin) (getvar 'extmax))
    843. )
    844. )
    845. ;;;***************** 函数 gxl-getbox*****************
    846. ;;;*************函数 gxl-sel-entsel.lsp *************
    847. ;;;(gxl-Sel-ENTSEL 提示 过滤表),相当于EntSel,醒目显示
    848. ;;USAGE:(gxl-Sel-ENTSEL "\n请选Polyline物件: " '((0 . "*Polyline")))
    849. (defun gxl-Sel-ENTSEL (STR FILTER / PT MIND OLDPT SS SS_NAME FLAG)
    850. (if (/= (type STR) 'STR)
    851. (progn (princ "\n变量类型不对,STR应为字符串。\n")
    852. nil
    853. ) ;_ progn
    854. (progn
    855. (if (and FILTER (/= (type FILTER) 'list))
    856. (progn (princ "\n变量类型不对,FILTER应为表。\n")
    857. nil
    858. ) ;_ progn
    859. (progn
    860. (princ STR)
    861. (setq PT (grread t 5 2))
    862. (setq mind (* (getvar "viewsize") 0.01))
    863. (if (not oldpt)
    864. (setq oldpt (cadr PT))
    865. )
    866. (while (not flag) ;_(and (/= 3 (car PT))(not (and (= (car pt) 2) (= 13 (cadr pt)))))
    867. (cond
    868. ((and (= 5 (car PT))
    869. (> (distance (cadr PT) oldpt) mind)
    870. )
    871. (setq PT (cadr PT)
    872. oldpt pt
    873. )
    874. (if FILTER
    875. (setq SS (ssget PT FILTER))
    876. (setq SS (ssget PT))
    877. ) ;_ if
    878. (if (and ss
    879. (equal (ssname SS 0) SS_NAME)
    880. )
    881. ()
    882. (progn
    883. (if SS_NAME
    884. (redraw SS_NAME 4)
    885. ) ;_ if
    886. (setq SS_NAME NIL)
    887. (if SS
    888. (progn (setq SS_NAME (ssname SS 0))
    889. (redraw SS_NAME 3)
    890. )
    891. ) ;_ if
    892. )
    893. )
    894. ) ;_
    895. ((or (= 3 (car PT)) (and (= (car pt) 2) (= 13 (cadr pt))))
    896. (setq flag t)
    897. )
    898. ) ;_ cond
    899. (setq mind (* (getvar "viewsize") 0.005))
    900. (if (not flag)
    901. (setq PT (grread t 5 2))
    902. )
    903. (if (= 25 (car pt))
    904. (setq flag t
    905. pt nil
    906. )
    907. )
    908. ) ;_ while
    909. (if pt
    910. (progn
    911. (setq PT (cadr PT))
    912. (if (= 13 pt)
    913. (setq pt (cadr (grread t)))
    914. )
    915. (if FILTER
    916. (setq SS (ssget PT FILTER))
    917. (setq SS (ssget PT))
    918. )
    919. (if SS_NAME
    920. (redraw SS_NAME 4)
    921. ) ;_ if
    922. (setq SS_NAME NIL)
    923. (if SS
    924. (progn (setq SS_NAME (ssname SS 0)) (list SS_NAME PT))
    925. SS_NAME
    926. ) ;_ if
    927. )
    928. (progn
    929. (if SS_NAME
    930. (redraw SS_NAME 4)
    931. )
    932. )
    933. )
    934. ) ;_ progn
    935. ) ;_ if
    936. ) ;_ progn
    937. ) ;_ if
    938. )
    939. ;;;***************** 函数 gxl-Sel-ENTSEL*****************
    940. ;;;*************函数 gxl-catchapply.lsp *************
    941. ;;;(gxl-CatchApply fun args) 重定义 VL-CATCH-ALL-APPLY ,如函数错误返回nil
    942. ;;;(gxl-CatchApply vla-offset (list (vlax-ename->vla-object (car(entsel))) 10))
    943. (defun gxl-CatchApply ( fun args / result )
    944. ;; ?Lee Mac 2010
    945. (if
    946. (not
    947. (vl-catch-all-error-p
    948. (setq result
    949. (vl-catch-all-apply (if (= 'SYM (type fun)) fun (function fun)) args)
    950. )
    951. )
    952. )
    953. result
    954. )
    955. )
    956. ;;;***************** 函数 gxl-CatchApply*****************
    957. ;;;*************函数 gxl-get_poly_ptlist.lsp *************
    958. ;;;==================================================================
    959. ;;;gxl-get_poly_ptList 返回多义线顶点点列表不含圆弧段内容,闭合多义线点表不含闭合点坐标
    960. ;;;(gxl-get_poly_ptList (car (entsel)))
    961. ;;;==================================================================
    962. (defun gxl-get_poly_ptList (e / _pl n k objname)
    963. (setq objname
    964. (cond
    965. ((gxl-CATCHAPPLY vla-get-ObjectName (list e)))
    966. ((gxl-CATCHAPPLY gxl-dxf (list e 0)))
    967. )
    968. )
    969. (cond ((or
    970. (= "AcDbCircle" objname)
    971. (= "CIRCLE" objname)
    972. )
    973. (list (vlax-curve-getPointAtParam e 0)
    974. (vlax-curve-getPointAtParam e pi2)
    975. (vlax-curve-getPointAtParam e pi)
    976. (vlax-curve-getPointAtParam e 3pi2)
    977. )
    978. )
    979. ((or
    980. (= "AcDbArc" objname)
    981. (= "ARC" objname)
    982. )
    983. (list (vlax-curve-getStartPoint e)
    984. (vlax-curve-getendPoint e)
    985. )
    986. )
    987. (t
    988. (setq n (1+ (fix (vlax-curve-getEndParam e)))
    989. k -1
    990. )
    991. (if (vlax-curve-isClosed e)
    992. (setq n (1- n))
    993. )
    994. (repeat n
    995. (setq k (1+ k))
    996. (if (vlax-curve-getSecondDeriv e k)
    997. (setq _pl (append _pl (list (vlax-curve-getPointAtParam e k))))
    998. )
    999. )
    1000. )
    1001. )
    1002. )
    1003. ;;;***************** 函数 gxl-get_poly_ptList*****************
    1004. ;;;*************函数 gxl-get_poly_ptlist3.lsp *************
    1005. ;_ 结束defun
    1006. ;;;gxl-get_poly_ptList3 返回多义线顶点点列表,有圆弧则用一定角度分割圆弧,闭合多义线点表不含闭合点坐标
    1007. ;;;(gxl-AX:ADDLWPOLYLINE *MODEL-SPACE* (gxl-get_poly_ptList3 (car (entsel)) 0.5))
    1008. ;;(gxl-Ge-GRDrawLines (gxl-get_poly_ptList3 (car (entsel)) 1) 1 t)
    1009. (defun gxl-get_poly_ptList3 (ENT FGX / OBJNAME VERTEXSNUM
    1010. N PT PLIST SECDEV BUGLE
    1011. BJ D1 D2 D K
    1012. D0 PARAM
    1013. )
    1014. (setq objname
    1015. (cond
    1016. ((gxl-CATCHAPPLY vla-get-ObjectName (list ent)))
    1017. ((gxl-CATCHAPPLY gxl-dxf (list ent 0)))
    1018. )
    1019. )
    1020. (setq vertexsNum
    1021. (fix (vlax-curve-getEndParam ent))
    1022. n 0
    1023. ) ;_ 结束setq
    1024. (cond ((or
    1025. (= "AcDbCircle" objname)
    1026. (= "CIRCLE" objname)
    1027. )
    1028. (if (equal fgx 0 1e-6)
    1029. (setq fgx pi2)
    1030. )
    1031. (setq vertexsNum
    1032. (fix (/ 2pi fgx))
    1033. n 0
    1034. )
    1035. (repeat vertexsNum
    1036. (setq pt (vlax-curve-getPointAtParam ent (* n fgx)))
    1037. (setq plist (cons pt plist)
    1038. n (1+ n)
    1039. )
    1040. )
    1041. (reverse plist)
    1042. )
    1043. (t
    1044. (if (or
    1045. (= "AcDb2dPolyline" objName)
    1046. (= "POLYLINE" objName)
    1047. )
    1048. (progn
    1049. (repeat vertexsNum
    1050. (setq pt (vlax-curve-getPointAtParam ent n))
    1051. (setq plist (cons pt plist))
    1052. (setq pt (vlax-curve-getPointAtParam ent (+ 0.25 n)))
    1053. (setq plist (cons pt plist))
    1054. (setq pt (vlax-curve-getPointAtParam ent (+ 0.5 n)))
    1055. (setq plist (cons pt plist))
    1056. (setq pt (vlax-curve-getPointAtParam ent (+ 0.75 n)))
    1057. (setq plist (cons pt plist))
    1058. (setq n (1+ n))
    1059. )
    1060. (if (not (vlax-curve-isClosed ent))
    1061. (setq plist (cons (vlax-curve-getEndPoint ent) plist))
    1062. ) ;_ 结束if
    1063. (reverse plist)
    1064. )
    1065. (if (equal fgx 0 1e-6)
    1066. (gxl-GET_POLY_PTLIST ent)
    1067. (progn
    1068. (if (= 'ename (type ent)) (setq ent (vlax-ename->vla-object ent)))
    1069. (repeat vertexsNum
    1070. (if (setq secdev (vlax-curve-getSecondDeriv ent n))
    1071. (progn
    1072. (setq pt (vlax-curve-getPointAtParam ent n)
    1073. bugle (vla-GetBulge ent n)
    1074. ) ;_ 结束setq
    1075. (setq plist (cons pt plist))
    1076. (if (/= bugle 0.0)
    1077. (progn
    1078. (setq bj (* (atan (abs bugle)) 4))
    1079. (setq d1 (vlax-curve-getdistAtParam ent n)
    1080. d2 (vlax-curve-getdistAtParam ent (1+ n))
    1081. d (- d2 d1)
    1082. k (fix (/ bj fgx))
    1083. d0 (/ 1.0 (1+ k))
    1084. param n
    1085. ) ;_ 结束setq
    1086. (if (equal d0 1.0 0.001)
    1087. (setq plist (cons (vlax-curve-getPointAtParam
    1088. ent
    1089. (+ 0.5 param)
    1090. )
    1091. plist
    1092. )
    1093. )
    1094. (repeat k
    1095. (setq plist (cons (vlax-curve-getPointAtParam
    1096. ent
    1097. (setq param (+ param d0))
    1098. )
    1099. plist
    1100. )
    1101. )
    1102. )
    1103. )
    1104. ) ;_ 结束progn
    1105. ) ;_ 结束if
    1106. )
    1107. )
    1108. (setq n (1+ n))
    1109. ) ;_ 结束repeat
    1110. (if (not (vlax-curve-isClosed ent))
    1111. (setq plist (cons (vlax-curve-getEndPoint ent) plist))
    1112. ) ;_ 结束if
    1113. (reverse plist)
    1114. )
    1115. )
    1116. )
    1117. )
    1118. )
    1119. )
    1120. ;;;***************** 函数 gxl-get_poly_ptList3*****************
    1121. ;;;*************函数 gxl-sel-ss-》ax:array.lsp *************
    1122. ;;;===================================================================
    1123. ;;;gxl-Sel-SS->AX:Array 转换选择集为变体数组
    1124. ;|功能
    1125. 转换选择集为变体数组
    1126. 语法
    1127. (selectionsetToArray ss)
    1128. 参数
    1129. ss: 选择集
    1130. 返回值
    1131. 变体数组
    1132. 样例
    1133. (selectionsetToArray mySS)
    1134. 说明
    1135. 使用该函数可以将选择集转换为数组传递给ActiveX函数。
    1136. 如果需要其它的子类型,只需更改引用vlax-vbObject。
    1137. |;
    1138. ;;;===================================================================
    1139. (defun gxl-Sel-SS->AX:Array (ss / c r en)
    1140. (repeat (setq c (sslength ss))
    1141. (setq en (ssname ss (setq c (1- c))))
    1142. (if (entget en)
    1143. (setq r (cons en r))
    1144. )
    1145. )
    1146. (vlax-safearray-fill
    1147. (vlax-make-safearray
    1148. vlax-vbObject
    1149. (cons 0 (1- (length r)))
    1150. )
    1151. (mapcar 'vlax-ename->vla-object r)
    1152. )
    1153. )
    1154. ;;;***************** 函数 gxl-Sel-SS->AX:Array*****************
    1155. ;;;*************函数 gxl-axaddblock.lsp *************
    1156. ;;;===================================================================
    1157. ;;;(gxl-AX:AddBlock InsPt Name) 增加块定义(做块头),返回块定义 OBJ
    1158. (defun gxl-AX:AddBlock (InsPt Name)
    1159. (if (= (substr (strcase name) 1 2) "*U") (setq name "*U"))
    1160. (vla-add (vla-get-Blocks *AcDocument*) (vlax-3d-point InsPt) Name)
    1161. )
    1162. ;;;***************** 函数 gxl-AX:AddBlock*****************
    1163. ;;;*************函数 gxl-str-subst.lsp *************
    1164. ;_ end of defun
    1165. ;;; (gxl-Str-Subst New Old Str) 替换字符串中的某些字符为其它字符
    1166. ;;;(gxl-Str-Subst ",." ".." "123..456..789")
    1167. (defun gxl-Str-Subst (New Old Str / str1 n)
    1168. (setq n (strlen old))
    1169. (cond ((> (strlen str) n)
    1170. (setq str1 (substr str 1 n))
    1171. (if (= str1 old)
    1172. (strcat new (gxl-Str-Subst new old (substr str (1+ n))))
    1173. (strcat (substr str 1 1) (gxl-Str-Subst new old (substr str 2)))
    1174. )
    1175. )
    1176. ((= (strlen str) n)
    1177. (if (= old str)
    1178. new
    1179. str
    1180. )
    1181. )
    1182. (t
    1183. str
    1184. )
    1185. ) ;_ 结束cond
    1186. )
    1187. ;;;***************** 函数 gxl-Str-Subst*****************
    1188. ;;;*************函数 gxl-blk-check.lsp *************
    1189. ;;; gxl-Blk-Check 检查定义图块
    1190. (defun gxl-Blk-Check (B_Name / $PROMPT B_NAME1 CURLAY ERR)
    1191. (if (or (= 'SUBR (type MakeBlock-001))
    1192. (= 'USUBR (type MakeBlock-001))
    1193. )
    1194. ()
    1195. (setq $prompt (load "MakeBlockSymbol.vlx" "未找到MakeBlockSymbol.vlx文件"))
    1196. )
    1197. (if (= $prompt "未找到MakeBlockSymbol.vlx文件")
    1198. (setq $prompt (load "E:\\lisp\\房产CAD工具软件\\lisp\\MakeBlockSymbol.vlx" "未找到MakeBlockSymbol.vlx文件"))
    1199. )
    1200. ;(if (= $prompt "未找到MakeBlockSymbol.vlx文件") (progn (princ "\n未找到MakeBlockSymbol.vlx文件") (exit)))
    1201. (if (= $prompt "未找到MakeBlockSymbol.vlx文件")
    1202. B_Name
    1203. (progn
    1204. (setq B_Name1 (gxl-Str-Subst "]" ")" (gxl-Str-Subst "[" "(" B_Name)))
    1205. (setq curlay (getvar "Clayer"))
    1206. (setq err (VL-CATCH-ALL-APPLY 'vla-Item (list (vla-get-Blocks *ACDOCUMENT*) B_Name)))
    1207. (if (VL-CATCH-ALL-ERROR-P err) ;(not (member B_Name (gxl-TABLE "block")))
    1208. (progn
    1209. (if (or (= 'USUBR (type (eval(read (strcat "MakeBlock-" B_Name1)))))
    1210. (= 'SUBR (type (eval(read (strcat "MakeBlock-" B_Name1)))))
    1211. )
    1212. (eval (read (strcat "(MakeBlock-" B_Name1 ")")))
    1213. )
    1214. )
    1215. )
    1216. (setvar "clayer" curlay)
    1217. B_Name
    1218. )
    1219. )
    1220. )
    1221. ;;;***************** 函数 gxl-Blk-Check*****************
    1222. ;;;*************函数 gxl-ax:minsertblock.lsp *************
    1223. ;;;(gxl-AX:MInsertBlock InsPt Name Xscale Yscale ZScale Rotation NumRows NumColumns RowSpacing ColumnSpacing) 插入复杂块
    1224. ;;;(gxl-AX:MInsertBlock InsPt Name Xscale Yscale ZScale Rotation) 插入复杂图块,返回BlockREf
    1225. ;;;(gxl-AX:MInsertBlock (getpoint) "001" 1 1 1 0 2 2 10 10)
    1226. (defun gxl-AX:MInsertBlock (InsPt Name Xscale Yscale ZScale Rotation NumRows NumColumns RowSpacing ColumnSpacing)
    1227. (gxl-BLK-CHECK Name)
    1228. (setvar "insname" (VL-FILENAME-BASE name))
    1229. (VL-CATCH-ALL-APPLY 'vla-AddMInsertBlock (list *MODEL-SPACE* (vlax-3d-point InsPt) Name Xscale Yscale ZScale Rotation NumRows NumColumns RowSpacing ColumnSpacing))
    1230. )
    1231. ;;;***************** 函数 gxl-AX:MInsertBlock*****************
    1232. ;;;*************函数 gxl-blk-unmblockbase.lsp *************
    1233. ;;(gxl-BLK-UnMBlockBase ss base) 制作无名复杂块,base 为图块基点 0 = 中心 1 = 左下 2 = 右下 3 = 右上 4 = 左上 ,默认值为0
    1234. (defun gxl-BLK-UnMBlockBase (ss base / obj blkName obj1 cp)
    1235. (if (> (sslength ss) 0)
    1236. (progn
    1237. (setq blkName "*U")
    1238. (setq ss (gxl-Sel-SS->AX:Array ss))
    1239. (setq obj (gxl-AX:AddBlock '(0 0 0) blkName))
    1240. (vla-CopyObjects *AcDocument* ss obj)
    1241. (foreach ent (vlax-safearray->list ss)
    1242. (VL-CATCH-ALL-APPLY 'vla-Delete (list ent))
    1243. ) ;_ foreach
    1244. (setq obj1 (gxl-AX:MInsertBlock '(0 0 0) (vla-get-name obj) 1 1 1 0 1 1 0 0))
    1245. ;;计算基点
    1246. (cond
    1247. ((= 'list (type base))
    1248. (setq cp base)
    1249. )
    1250. ((or (null base)
    1251. (= 0 base)
    1252. )
    1253. (vla-GetBoundingBox obj1 'll 'ur)
    1254. (setq ll (vlax-safearray->list ll)
    1255. ur (vlax-safearray->list ur)
    1256. )
    1257. (setq cp (gxl-MIDPOINT ll ur))
    1258. )
    1259. ((= 1 base)
    1260. (vla-GetBoundingBox obj1 'll 'ur)
    1261. (setq ll (vlax-safearray->list ll)
    1262. ;ur (vlax-safearray->list ur)
    1263. )
    1264. (setq cp ll)
    1265. )
    1266. ((= 2 base)
    1267. (vla-GetBoundingBox obj1 'll 'ur)
    1268. (setq ll (vlax-safearray->list ll)
    1269. ur (vlax-safearray->list ur)
    1270. )
    1271. (setq cp (list (car ur) (cadr ll) 0))
    1272. )
    1273. ((= 3 base)
    1274. (vla-GetBoundingBox obj1 'll 'ur)
    1275. (setq ;ll (vlax-safearray->list ll)
    1276. ur (vlax-safearray->list ur)
    1277. )
    1278. (setq cp ur)
    1279. )
    1280. ((= 4 base)
    1281. (vla-GetBoundingBox obj1 'll 'ur)
    1282. (setq ll (vlax-safearray->list ll)
    1283. ur (vlax-safearray->list ur)
    1284. )
    1285. (setq cp (list (car ll) (cadr ur) 0))
    1286. )
    1287. )
    1288. ;;修改图块基点
    1289. (vla-put-Origin obj (vlax-3d-point cp))
    1290. (vla-move obj1 (vlax-3d-point '(0 0 0)) (vlax-3d-point cp))
    1291. obj1
    1292. )
    1293. )
    1294. )
    1295. ;;;***************** 函数 gxl-BLK-UnMBlockBase*****************
    1296. ;;;*************函数 gxl-ax:addline.lsp *************
    1297. ;;;===================================================================
    1298. ;;; (gxl-AX:AddLine obj pt1 pt2) 制造直线实体
    1299. (defun gxl-AX:AddLine (obj pt1 pt2)
    1300. (vla-Addline
    1301. (if obj obj (gxl-GETSPACE))
    1302. (vlax-3d-point pt1)
    1303. (vlax-3d-point pt2)
    1304. ) ;_ 结束vla-Addline
    1305. )
    1306. ;;;***************** 函数 gxl-AX:AddLine*****************
    1307. ;;;*************函数 gxl-ax:getboundingbox.lsp *************
    1308. ;;;==================================================================
    1309. ;;;gxl-ax:GetBoundingBox 返回一个单独图元的范围
    1310. ;|功能
    1311. 返回一个单独图元的范围
    1312. 语法
    1313. (gxl-ax:GetBoundingBox ent)
    1314. 参数
    1315. 一个图元名称
    1316. 样例
    1317. (gxl-ax:GetBoundingBox (car (entsel)))
    1318. 说明
    1319. 不要使用该程序于XLINES或RAYS
    1320. |;
    1321. ;;;==================================================================
    1322. (defun gxl-ax:GetBoundingBox (ent / ll ur r)
    1323. (if (= 'ENAME (type ent))
    1324. (setq r (VL-CATCH-ALL-APPLY
    1325. 'vla-getboundingbox
    1326. (list (vlax-ename->vla-object ent) 'll 'ur)
    1327. )
    1328. )
    1329. (setq r (VL-CATCH-ALL-APPLY 'vla-getboundingbox (list ent 'll 'ur)))
    1330. )
    1331. (if (not (VL-CATCH-ALL-ERROR-P r))
    1332. (mapcar 'vlax-safearray->list (list ll ur))
    1333. )
    1334. )
    1335. ;;;***************** 函数 gxl-ax:GetBoundingBox*****************
    1336. ;;;*************函数 gxl-mat:scaling.lsp *************
    1337. ;;;-----------------------------------------------------------;;
    1338. ;;; 比例缩放矩阵 ;;
    1339. ;;; 参数: ;;
    1340. ;;; Cen - 基点 ;;
    1341. ;;; scale - 缩放比例 ;;
    1342. ;;;-----------------------------------------------------------;;
    1343. ;;;-----------------=={ Scale by Matrix }==-------------------;;
    1344. ;;; ;;
    1345. ;;; Scaling Matrix ;;
    1346. ;;;-----------------------------------------------------------;;
    1347. ;;; Author: highflybird, Copyright ? 2012 ;;
    1348. ;;;-----------------------------------------------------------;;
    1349. ;;; Arguments: ;;
    1350. ;;; Cen - Base Point for Scaling Transformation ;;
    1351. ;;; scale - Scale Factor by which to scale object ;;
    1352. ;;;-----------------------------------------------------------;;
    1353. (defun gxl-MAT:Scaling ( Cen scale / s)
    1354. (setq s (- 1 scale))
    1355. (list
    1356. (list scale 0. 0. (* s (car Cen)))
    1357. (list 0. scale 0. (* s (cadr Cen)))
    1358. (list 0. 0. scale (* s (caddr Cen)))
    1359. '(0. 0. 0. 1.)
    1360. )
    1361. )
    1362. ;;;***************** 函数 gxl-MAT:Scaling*****************
    1363. ;;;*************函数 gxl-itemsall.lsp *************
    1364. ;;;gxl-ItemsAll collection )返回集合全部成员表
    1365. ;;(gxl-ItemsAll (vla-get-blocks (vla-get-ActiveDocument (vlax-get-acad-object))))
    1366. (defun gxl-ItemsAll (collection / result)
    1367. (vl-catch-all-apply
    1368. (FUNCTION
    1369. (lambda ()
    1370. (vlax-for item collection (setq result (cons item result)))
    1371. (reverse result)
    1372. )
    1373. )
    1374. )
    1375. result
    1376. )
    1377. ;;;***************** 函数 gxl-ItemsAll*****************
    1378. ;;;*************函数 gxl-setoverride.lsp *************
    1379. ;;修正放大对象的替换样式
    1380. ;|设置实体的OverRide参数:
    1381. e ---- 实体名 scl -- 比例返回值:
    1382. t说明:本函数支持嵌套图块本函数根据比例设置实体的OverRide,对LWPOLYLINE的线宽,
    1383. 尺寸标注的界限长度,文字、箭头大小,HATCH的填充比例, TEXT,MTEXT,ATTRIB根据比
    1384. 例的倒数缩放。以满足局部放大后的上述实体的显示要求。
    1385. |;
    1386. (defun Gxl-setOverride (e scl / basept1
    1387. basept2 box cen class
    1388. cwidth dis e1 i info
    1389. lscl mat mat0 name nums
    1390. obj p1 p2 pj pts
    1391. scl1 ss1 vec w obj w1 w2
    1392. objs objs1 atts objname)
    1393. (if (= 'ename (type e))
    1394. (setq obj (vlax-ename->vla-object e))
    1395. (setq obj e e (vlax-vla-object->ename obj))
    1396. )
    1397. (setq class (gxl-dxf e 0) )
    1398. (cond ((or (= class "TEXT") (= class "MTEXT") (= class "ATTRIB") (= class "TCH_TEXT"))
    1399. (setq box (gxl-ax:GetBoundingBox e)
    1400. cen (apply 'GXL-MIDPOINT box)
    1401. mat (Gxl-MAT:Scaling cen (/ 1.0 scl) )
    1402. )
    1403. (vla-TransformBy obj (vlax-tmatrix mat))
    1404. )
    1405. ((= class "DIMENSION")
    1406. (vla-put-TextHeight obj (/ (vla-get-TextHeight obj) scl))
    1407. (vla-put-ArrowheadSize obj (/ (vla-get-ArrowheadSize obj) scl))
    1408. (if (vlax-property-available-p obj 'ExtensionLineOffset)
    1409. (VL-CATCH-ALL-APPLY 'vla-put-ExtensionLineOffset (list obj (/ (vla-get-ExtensionLineOffset obj) scl)))
    1410. )
    1411. (if (vlax-property-available-p obj 'ExtensionLineExtend)
    1412. (VL-CATCH-ALL-APPLY 'vla-put-ExtensionLineExtend (list obj (/ (vla-get-ExtensionLineExtend obj) scl)))
    1413. )
    1414. )
    1415. ((= class "HATCH")
    1416. (if (gxl-dxf e 41)
    1417. (vla-put-PatternScale obj (/ (gxl-dxf e 41) scl))
    1418. )
    1419. )
    1420. ((= class "LWPOLYLINE")
    1421. (setq cwidth (gxl-dxf e 43))
    1422. (cond ((not cwidth)
    1423. (setq nums (fix(vlax-curve-getEndParam e)))
    1424. (setq i 0)
    1425. (repeat (1- nums)
    1426. (VL-CATCH-ALL-APPLY 'vla-getwidth (list obj i 'w1 'w2))
    1427. (if (and w1 w2)
    1428. (setq w1 (/ w1 scl)
    1429. w2 (/ w1 scl)
    1430. )
    1431. )
    1432. (VL-CATCH-ALL-APPLY 'vla-SetWidth (list obj i w1 w2))
    1433. (setq i (1+ i))
    1434. )
    1435. )
    1436. ((/= 0 cwidth)
    1437. (GXL-CH_ENT e 43 (/ cwidth scl))
    1438. )
    1439. )
    1440. )
    1441. ((= class "INSERT")
    1442. (setq name (gxl-dxf e 2))
    1443. (setq atts (vlax-invoke obj 'GetAttributes))
    1444. (foreach a atts (VL-CATCH-ALL-APPLY 'Gxl-setOverride (list a scl)))
    1445. (if (setq
    1446. objs1 (GXL-ITEMSALL
    1447. (vla-item (vla-get-blocks *ACDOCUMENT*) name)
    1448. )
    1449. )
    1450. (foreach a objs1
    1451. (setq objname (gxl-dxf (vlax-vla-object->ename a) 0))
    1452. (cond
    1453. ((= objname "DIMENSION")
    1454. (setq objs
    1455. (vlax-invoke *ACDOCUMENT* 'CopyObjects (list a) *SPACE*)
    1456. )
    1457. (VL-CATCH-ALL-APPLY 'vla-delete (list a))
    1458. (foreach a objs
    1459. (Gxl-setOverride a scl)
    1460. )
    1461. (if objs
    1462. (vlax-invoke
    1463. *ACDOCUMENT*
    1464. 'CopyObjects
    1465. objs
    1466. (vla-item (vla-get-blocks *ACDOCUMENT*) name)
    1467. )
    1468. )
    1469. (foreach a objs
    1470. (VL-CATCH-ALL-APPLY 'vla-delete (list a))
    1471. )
    1472. )
    1473. (t
    1474. (VL-CATCH-ALL-APPLY 'Gxl-setOverride (list a scl))
    1475. )
    1476. )
    1477. )
    1478. )
    1479. )
    1480. (t (if (vlax-property-available-p obj 'LinetypeScale) (vla-put-LinetypeScale obj (/ (vla-get-LinetypeScale obj) scl))))
    1481. )
    1482. t
    1483. )
    1484. ;;;***************** 函数 gxl-setOverride*****************
    1485. ;;;*************函数 gxl-lst-split.lsp *************
    1486. ;;;(gxl-lst-split lst n)将表等分成若干长度为n的子表
    1487. ;(setq a '(1 2 3 4 5 6 7 8))
    1488. ;(gxl-lst-split a 2) 返回 ((1 2) (3 4) (5 6) (7 8))
    1489. ;(gxl-lst-split a 3) 返回 ((1 2 3) (4 5 6) (7 8))
    1490. ;(gxl-lst-split '(0 1 2 3 4 5 6 7 8 9 10 11) 3)
    1491. ;;;递归算法
    1492. (defun gxl-lst-split (lst len / tmp)
    1493. (if lst
    1494. (cons
    1495. (reverse
    1496. (repeat len
    1497. (if (car lst)
    1498. (setq tmp (cons (car lst) tmp)
    1499. lst (cdr lst)
    1500. )
    1501. )
    1502. tmp ;_ 制造返回值
    1503. )
    1504. )
    1505. (gxl-lst-split lst len)
    1506. )
    1507. )
    1508. )
    1509. ;;;***************** 函数 gxl-lst-split*****************
    1510. ;;;*************函数 gxl-inters.lsp *************
    1511. ;;;(gxl-inters en1 en2 Param) 计算两曲线交点,param : acExtendNone acExtendThisEntity acExtendOtherEntity acExtendBoth
    1512. ;;;(gxl-inters (car (entsel)) (car (entsel)) 0)
    1513. (defun gxl-inters (obj1 obj2 param)
    1514. (if (= 'ENAME (type obj1))
    1515. (setq obj1 (vlax-ename->vla-object obj1))
    1516. (if (= 'STR (type obj1))
    1517. (setq obj1 (vlax-ename->vla-object (handent obj1)))
    1518. )
    1519. )
    1520. (if (= 'ENAME (type obj2))
    1521. (setq obj2 (vlax-ename->vla-object obj2))
    1522. (if (= 'STR (type obj2))
    1523. (setq obj2 (vlax-ename->vla-object (handent obj2)))
    1524. )
    1525. )
    1526. (if (and obj1 obj2)
    1527. (gxl-lst-split
    1528. (vlax-invoke obj1 'IntersectWith obj2 param)
    1529. 3
    1530. )
    1531. )
    1532. )
    1533. ;;;***************** 函数 gxl-inters*****************
    1534. ;;;*************************************************
    1535. (defun c:ZoomMap (/ KD DELFLAG CP R GR D
    1536. P1 ENT FLAG SCALE PL SS ENDENT
    1537. UNBLK NEWENT OLDPT ENLINE PTS *error* os cmdecho)
    1538. (defun *error* (s)
    1539. (command "_ucs" "_p")
    1540. (setvar 'cmdecho cmdecho)
    1541. (gxl-RESTORESLAYERS)
    1542. (if os (setvar 'osmode os))
    1543. (if unblk (vla-delete unblk))
    1544. (if NewEnt (vla-delete NewEnt))
    1545. (if enline (entdel enline))
    1546. (if delflag (entdel ent))
    1547. (princ s)
    1548. (princ)
    1549. )
    1550. (setq cmdecho (getvar 'cmdecho))
    1551. (setvar 'cmdecho 0)
    1552. (command "_ucs" "_w")
    1553. (gxl-storeslayers)
    1554. (gxl-Layer-UnLockAll)
    1555. (setvar "clayer" "0")
    1556. (initget 7 "Select Rect Draw Circle ")
    1557. (setq kd (getkword "\n**选择放大范围方式[选择多边形Select/四边形R/绘制多边形Draw/圆形放大Circle]<Circle>:"))
    1558. (if (= "" kd) (setq kd "Circle"))
    1559. (while (not ent)
    1560. (cond ((= kd "Circle")
    1561. (setq delflag t)
    1562. (while (not (setq cp (getpoint "\n 选择放大区域中心点:"))))
    1563. (setq R 0 flag nil)
    1564. (while (not flag)
    1565. (setq gr (grread t 2))
    1566. (setq d (* 0.0015 (getvar "viewsize")))
    1567. (gxl-Ge-GRDrawCross cp 5 0 1 nil)
    1568. (cond ((= 5 (car gr))
    1569. (setq p1 (cadr gr))
    1570. (if (> (abs (- (distance cp p1) R)) d)
    1571. (progn
    1572. (setq R (distance cp p1))
    1573. (if ent
    1574. (gxl-ch_ent ent 40 r)
    1575. (progn
    1576. (gxl-AX:ADDCIRCLE *MODEL-SPACE* cp r)
    1577. (setq ent (entlast))
    1578. )
    1579. )
    1580. ;(gxl-CH_ENT ent 62 1)
    1581. )
    1582. )
    1583. )
    1584. ((= 3 (car gr))
    1585. (setq flag t)
    1586. (setq p1 (cadr gr))
    1587. (setq R (distance cp p1))
    1588. (if ent
    1589. (gxl-ch_ent ent 40 r)
    1590. (progn
    1591. (gxl-AX:ADDCIRCLE *MODEL-SPACE* cp r)
    1592. (setq ent (entlast))
    1593. )
    1594. )
    1595. )
    1596. )
    1597. )
    1598. )
    1599. ((= kd "Rect")
    1600. (setq delflag t)
    1601. (if (setq ent (gxl-COMMAND "_.rectang"))
    1602. (progn
    1603. (setq ent (entlast))
    1604. (gxl-ch_ent ent 70 1)
    1605. (setq cp (apply 'gxl-MIDPOINT (gxl-GETBOX ent)))
    1606. (setq d (* 0.0015 (getvar "viewsize")))
    1607. (gxl-Ge-GRDrawCross cp 5 0 1 nil)
    1608. )
    1609. )
    1610. )
    1611. ((= kd "Draw")
    1612. (setq delflag t)
    1613. (if (setq ent (gxl-COMMAND "_.Pline"))
    1614. (progn
    1615. (setq ent (entlast))
    1616. (gxl-ch_ent ent 70 1)
    1617. (setq cp (apply 'gxl-MIDPOINT (gxl-GETBOX ent)))
    1618. (setq d (* 0.0015 (getvar "viewsize")))
    1619. (gxl-Ge-GRDrawCross cp 5 0 1 nil)
    1620. )
    1621. )
    1622. )
    1623. ((= kd "Select")
    1624. (while (not (setq ent (car (gxl-SEL-ENTSEL "\n选择封闭多段线:" '((0 . "*LWPOLYLINE,circle")))))))
    1625. (setq cp (apply 'gxl-MIDPOINT (gxl-GETBOX ent)))
    1626. (setq d (* 0.0015 (getvar "viewsize")))
    1627. (gxl-Ge-GRDrawCross cp 5 0 1 nil)
    1628. )
    1629. )
    1630. (if (not ent)
    1631. (cond
    1632. ((= kd "Select")
    1633. (princ "\n***没有选择放大边界,请重新选择边界***")
    1634. )
    1635. (t
    1636. (princ "\n***没有绘制放大边界,请重新绘制边界***")
    1637. )
    1638. )
    1639. )
    1640. )
    1641. (setq os (getvar 'osmode))
    1642. (setvar 'osmode 0)
    1643. (setq p1 (vlax-3d-point cp))
    1644. (setq scale (getreal "\n 放大倍数<2.0>:"))
    1645. (if (null scale) (setq scale 2.0))
    1646. (redraw ent 2)
    1647. (setq pl (gxl-get_poly_ptList3 ent 0.017))
    1648. (setq ss (ssget "cp" pl))
    1649. (if ss
    1650. (progn
    1651. (setq endent (entlast))
    1652. (command "_copy" ss "" "0,0" "0,0")
    1653. (setq ss (gxl-SEL-ENTNEXTALL endent))
    1654. (setq unblk (gxl-BLK-UnMBlockBase ss cp))
    1655. (command "_xclip" (entlast) "" "n" "p")
    1656. (foreach a pl (command a))
    1657. (command "")
    1658. (redraw ent 1)
    1659. (setq NewEnt (vla-copy (vlax-ename->vla-object ent)))
    1660. (vla-ScaleEntity NewEnt (setq oldpt (vlax-3d-point cp)) scale)
    1661. (princ "\n 摆放位置:")
    1662. (setq flag t)
    1663. (while flag
    1664. (setq gr (grread t 2))
    1665. (gxl-Ge-GRDrawCross cp 5 0 1 nil)
    1666. (if (= 5 (car gr))
    1667. (progn
    1668. (vla-move NewEnt p1 (setq p1 (vlax-3d-point (cadr gr))))
    1669. (if enline
    1670. (gxl-CH_ENT enline 11 (apply 'gxl-MIDPOINT (gxl-GETBOX NewEnt)))
    1671. (progn
    1672. (gxl-AX:ADDLINE *MODEL-SPACE* cp (cadr gr))
    1673. (setq enline (entlast))
    1674. )
    1675. )
    1676. )
    1677. (setq flag nil)
    1678. )
    1679. )
    1680. (vla-move unblk (vlax-3d-point cp) p1)
    1681. (vla-ScaleEntity unblk p1 scale)
    1682. (gxl-setOverride (vlax-vla-object->ename unblk) scale)
    1683. (setq pts (gxl-inters enline NewEnt acExtendNone))
    1684. (gxl-CH_ENT enline 11 (car pts))
    1685. (setq pts (gxl-inters enline Ent acExtendNone))
    1686. (gxl-CH_ENT enline 10 (car pts))
    1687. (gxl-ch_ent ent 62 3)
    1688. (gxl-ch_ent enline 62 3)
    1689. (vla-put-color NewEnt 3)
    1690. )
    1691. (alert "所选范围没有任何实体!")
    1692. )
    1693. (command "_ucs" "_p")
    1694. (setvar 'osmode os)
    1695. (setvar 'cmdecho cmdecho)
    1696. (gxl-RESTORESLAYERS)
    1697. (princ)
    1698. )
    1699. (princ "\n** 局部放大图 By Gu_xl 2013.07.24 命令: ZoomMap **") (princ)