本帖最后由 meja 于 2023-6-18 18:04 编辑
- (defun C:TextBox
- (/ CurSet CurEnt EntCnt PntLst RecEnt OffDst OffPnt OldCmd OldUci OldUcf)
- (setq CurSet
- (cond
- ((ssget "_I" '((0 . "TEXT"))))
- (T (prompt "\nTo put boxes around Text,") (ssget '((0 . "TEXT"))))
- ); cond
- ); setq
- (if CurSet
- (progn
- (setq
- OldCmd (getvar "CMDECHO")
- OldUci (getvar "UCSICON")
- OldUcf (getvar "UCSFOLLOW")
- EntCnt 0
- ); setq
- (setvar "CMDECHO" 0)
- (if (= (logand (getvar "UNDOCTL") 4) 4)
- (command "_.UNDO" "_GROUP")
- )
- (setvar "UCSICON" 0)
- (setvar "UCSFOLLOW" 0)
- (repeat (sslength CurSet)
- (setq
- CurEnt (ssname CurSet EntCnt)
- CurEntD (entget CurEnt)
- EntCnt (1+ EntCnt)
- )
- (command "_.UCS" "_OBJ" CurEnt)
- (setq
- PntLst (textbox CurEntD)
- OffPnt (polar (cadr PntLst) 0 1)
- OffDst (* (cdr (assoc 40 CurEntD)) 0.35) ;Distance Text -> Rectangle <--- or 0.5
- ); setq
- (command "_.RECTANGLE" (car PntLst) (cadr PntLst))
- (setq RecEnt (entlast))
- (command
- "_.OFFSET" OffDst RecEnt OffPnt ""
- "_.ERASE" RecEnt ""
- "_.UCS" "_PRE"
- ); command
- ); repeat
- (setvar "UCSICON" OldUci)
- (setvar "UCSFOLLOW" OldUcf)
- (if (= (logand (getvar "UNDOCTL") 4) 4)
- (command "_.UNDO" "_END")
- ); if
- (setvar "CMDECHO" OldCmd)
- ); progn
- ); if
- (princ)
- ); defun
官方大神 KENT COOPER 写的。(批量)完美运行,想知道这一句如何改成取中点
- (command "_.RECTANGLE" (car PntLst) (cadr PntLst))
|