- UID
- 70647
- 积分
- 987
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2003-8-7
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
[php]; =============================================================================
; Filename : ChgRad.lsp
; Datum : 07.11.01
; Author : jme
; Copyright : MENZI ENGINEERING GmbH
; Revision 1 : 18.01.05 jme - Selection mode added
; Revision 2 : __.__.__ ___ -
; -----------------------------------------------------------------------------
; Description:
; Function to change the radius of circles.
; -----------------------------------------------------------------------------
; Known bugs:
; - None
; -----------------------------------------------------------------------------
; Global variables:
; Me:Err Me:Nra Me:Ora Me:Smd Me:Svr
; -----------------------------------------------------------------------------
; Internal LISP-functions:
; MeEndFunction MeGetAssoc MeGetRadius MeStartFunction MeUserError
; -----------------------------------------------------------------------------
; External LISP-functions:
;
; -----------------------------------------------------------------------------
; Version notes:
; AutoCAD: Version: Language: AddIns:
; 14+ 1.01 English ...
; -----------------------------------------------------------------------------
;
; -- Message on loading -------------------------------------------------------
;
(princ "\nChgRad v1.01")
;
; == Main =====================================================================
;
(defun c:chgrad( / CurEnt CurSet EntLst FltLst TmpStr)
(MeStartFunction '("APERTURE" "AUTOSNAP" "CURSORSIZE" "OSMODE"))
(initget "Match Select")
(setq Me:Ora (cond
(Me:Ora)
((> (getvar "CIRCLERAD") 0) (getvar "CIRCLERAD"))
(1.0)
)
Me:Nra (cond
(Me:Nra)
((> (getvar "CIRCLERAD") 0) (getvar "CIRCLERAD"))
(1.0)
)
Me:Smd (cond (Me:Smd) ("Select"))
TmpStr (strcat "\nSelection mode [Match/Select] <" Me:Smd ">: ")
Me:Smd (cond ((getkword TmpStr)) (Me:Smd))
)
(if (eq Me:Smd "Select")
(progn
(princ "\nSelect circle(s)...")
(setq CurSet (ssget '((0 . "CIRCLE"))))
)
(setq Me:Ora (MeGetRadius "\nSelect Circle or enter radius to match" Me:Ora)
FltLst (list
'(0 . "CIRCLE")
'(-4 . ">=") (cons 40 (- Me:Ora 1E-6))
'(-4 . "<=") (cons 40 (+ Me:Ora 1E-6))
)
CurSet (ssget "X" FltLst)
)
)
(if CurSet
(progn
(setq Me:Nra (MeGetRadius "\nSelect Circle or enter new radius" Me:Nra))
(while (setq CurEnt (ssname CurSet 0))
(setq EntLst (entget CurEnt)
EntLst (subst (cons 40 Me:Nra) (assoc 40 EntLst) EntLst)
)
(entmod EntLst)
(ssdel CurEnt CurSet)
)
)
(if (eq Me:Smd "Match") (alert "No matching circle(s) found..."))
)
(MeEndFunction)
)
;
; == Subs =====================================================================
;
; -- Function MeGetRadius
; Get the default radius by object or number.
; Arguments [Typ]:
; Pmt = Prompt [STR]
; Rad = Default radius [REAL]
; Return [Typ]:
; > New radius [REAL]
; Notes:
; None
;
(defun MeGetRadius (Pmt Rad / EntLst GoLoop RetVal TmpStr TmpVal)
(setq GoLoop T)
(while GoLoop
(setvar "OSMODE" 512)
(setvar "APERTURE" (getvar "PICKBOX"))
(setvar "AUTOSNAP" 0)
(setvar "CURSORSIZE" 1)
(initget 128)
(setq RetVal (getpoint (strcat Pmt " <" (rtos Rad) ">: ")))
(setvar "OSMODE" 0)
(setvar "APERTURE" (MeGetAssoc "APERTURE" Me:Svr))
(setvar "AUTOSNAP" (MeGetAssoc "AUTOSNAP" Me:Svr))
(setvar "CURSORSIZE" (MeGetAssoc "CURSORSIZE" Me:Svr))
(cond
((= (type RetVal) 'LIST)
(if (= (type (setq TmpVal (car (nentselp RetVal)))) 'ENAME)
(progn
(setq EntLst (entget TmpVal))
(if (= (MeGetAssoc 0 EntLst) "CIRCLE")
(setq RetVal (MeGetAssoc 40 EntLst)
GoLoop nil
)
(prompt "selected object is not a Circle. ")
)
)
(prompt "1 selected, 0 found. ")
)
)
((= (type RetVal) 'STR)
(cond
((wcmatch RetVal "*[~0-9.-]*")
(prompt "requires a decimal number. ")
)
((minusp (atof RetVal))
(prompt "number must be positive. ")
)
((zerop (atof RetVal))
(prompt "requires a number >0. ")
)
(T
(setq RetVal (atof RetVal)
GoLoop nil
)
)
)
)
(T
(setq GoLoop nil
RetVal Rad
)
)
)
)
RetVal
)
;
; -- Function MeGetAssoc
; Returns the assoc value of a DottedPair list.
; Arguments [Typ]:
; Key = Key name [ALL]
; Return [Typ]:
; > Associated value from list [ALL]
; Notes:
; None
;
(defun MeGetAssoc (Key Lst) (cdr (assoc Key Lst)))
;
; -- User Error
;
(defun MeUserError (Msg)
(command) (command)
(if (not
(member Msg
'("Function cancelled" "console break" "quit / exit abort")
)
)
(princ (strcat "\nError: " Msg))
)
(MeEndFunction)
(princ)
)
;
; -- Start function
;
(defun MeStartFunction (Lst)
(setvar "CMDECHO" 0)
(if (= (logand (getvar "UNDOCTL") 4) 4) (command "_.UNDO" "_GROUP"))
(setq Me:Err *error*
*error* MeUserError
Me:Svr (mapcar '(lambda (l) (cons l (getvar l))) Lst)
)
(princ)
)
;
; -- End function
;
(defun MeEndFunction ()
(if Me:Svr (mapcar '(lambda (l) (setvar (car l) (cdr l))) Me:Svr))
(setq Me:Svr nil
*error* Me:Err
)
(if (= (logand (getvar "UNDOCTL") 4) 4) (command "_.UNDO" "_END"))
(princ)
)
;
; == Copyright - Note (May be never deleted) ==================================
;
(princ "\n------------------------------------------------")
(princ "\n ?001-2005 MENZI ENGINEERING GmbH, Switzerland ")
(princ "\n------------------------------------------------")
(princ "\nType ChgRad in the command line to start the programm...")
(princ)
;
; == End ChgCircRad ===========================================================[/php] |
|