本帖最后由 kucha007 于 2023-9-24 11:11 编辑
试试这个:
建议还是1:1制图,大不了编块放大或者用布局。要不然比例丢失绘制对不上会很麻烦
- (defun c:TT (/ DOC Old_CMD TmpVar P1 P2 Flag StaPT EndPT)
- (setq DOC (vla-get-ActiveDOCument (vlax-get-acad-object)))
- (defun *error*(msg)
- (setvar "cmdecho" Old_CMD)
- (vla-endundomark DOC)
- )
- (vla-startundomark Doc) ;记录编组
- (setq Old_CMD (getvar "cmdecho"))(setvar "cmdecho" 0) ;关闭回显
- (if (not Global:SCSVar)(setq Global:SCSVar 1.0));设置首次为1
- (while
- (progn
- (initget 2 "R S");非零
- (setq TmpVar (getpoint (strcat "\n→请输入起点或:[参照(R)/比例(S)_" (rtos Global:SCSVar 2 2)"]")))
- (cond
- ((and (eq (type TmpVar) 'STR)(eq (strcase TmpVar) "R"))
- (if (setq P1 (getpoint "\n→请指定第一点:")
- P2 (getpoint P1 "\n→请指定第二点:")
- )
- (setq Global:SCSVar (/ (getdist P1 "\n→请输入或量取新的长度:") (distance P1 P2)))
- )
- T ;继续循环
- )
- ((and (eq (type TmpVar) 'STR)(eq (strcase TmpVar) "S"))
- (initget (+ 2 4));非零非负
- (setq Global:SCSVar
- (cond
- ((getreal (strcat "\n→请输入缩放的值:<" (rtos Global:SCSVar 2 2) ">: ")))
- (Global:SCSVar)
- )
- )
- T ;继续循环
- )
- ((and TmpVar (eq (type TmpVar) 'LIST))
- (setq StaPT TmpVar
- Flag T ;循环标志
- )
- (while Flag
- (if (setq EndPT (getpoint StaPT "\n→请输入下一个点:"))
- (progn
- (setq EndPT (polar StaPT (angle StaPT EndPT) (* Global:SCSVar (distance StaPT EndPT))));放大后的点
- (command "_Line" StaPT EndPT "")
- (setq StaPT EndPT)
- )
- (progn
- (setq Flag Nil);退出循环
- (princ "\n——★★★ 未输入下一点, 程序退出!★★★——")
- )
- )
- )
- nil ;退出循环
- )
- (T
- (princ "\n——★★★ 请输入起点或者关键词!★★★——")
- nil ;退出循环
- )
- )
- )
- )
- (setvar "cmdecho" Old_CMD)
- (vla-endundomark Doc) ;结束编组
- (princ)
- )
|