请教如何实现类似探索者CAD的数值比例换算
本人在结构设计院工作,我们院的习惯是按比例画图,1:1出图。探索者中如果绘图比例是1:100,输入1000后Ctrl+enter,将自动换算回10,请教一下如和在lsp实现该功能呢,或者将该功能加入到lsp中,还望各位高手能解答。hao3ren 发表于 2023-9-17 17:33
在1:100的情况下,输入100,得到的长度是不是应该为100000?
(setq bl (/ (cdr(assoc 144 (tblsearch "DIM ...
太感谢您了,已经成功将比例折算的功能融入到我之前的插件中,万分感谢 tssd这个功能才知道不久,挺好用的。 ;比例绘图
(defun c:plcs()
;(if (= (getvar "useri5") 0) (setvar "useri5" 1))
;(if (setq blc (getreal (strcat "\n1:?<" (itoa (getvar "useri5")) ">")))
; (setvar "useri5" blc)
; (setq blc (getvar "useri5"))
;)
;(setq bl (/ blc 1000.0))
(if (and (princ "\n选择尺寸 :") (setq s1 (ssget ":S" '((0 . "DIMENSION"))))) (progn
(setq dimname (cdr(assoc 3 (entget(ssname s1 0)))))
(setq bl (/ (cdr(assoc 144 (tblsearch "DIMSTYLE" dimname))) 1000))
(setq olddim (getvar "DIMSTYLE"))
(command "-DIMSTYLE" "R" dimname "GRAPHSCR")
(initget "L C CO M O ")
(setq bz (getkword "\n直线-L/圆-C/拷贝-CP/移动-M/偏移-O <L>:"))
(cond
((= bz "C")
(if (= (getvar "userr4") 0) (setvar "userr4" 1.0))
(while (setq p1 (getpoint "\n圆心<回车结束>:"))
(if (setq rr (getdist (strcat "\n半径<" (rtos (getvar "userr4")) ">:")))
(setvar "userr4" rr)
(setq rr (getvar "userr4"))
)
(command ".CIRCLE" p1 (/ rr bl))
)
)
((= bz "CO")
(if (= (getvar "userr3") 0) (setvar "userr3" 1.0))
(while (and (print "\n选择图元 :")
(setq ss (ssget))
(setq p1 (getpoint "\n起始点 :"))
(setq ang (getangle p1 "\n方向 :")))
(if (setq ll (getdist (strcat "\n距离<" (rtos (getvar "userr3")) ">:")))
(setvar "userr3" ll)
(setq ll (getvar "userr3"))
)
(command ".COPY" ss "" p1 (polar p1 ang (/ ll bl)))
)
)
((= bz "M")
(if (= (getvar "userr2") 0) (setvar "userr2" 1.0))
(while (and (print "\n选择图元 :")
(setq ss (ssget))
(setq p1 (getpoint "\n起始点 :"))
(setq ang (getangle p1 "\n方向 :")))
(if (setq ll (getdist (strcat "\n距离<" (rtos (getvar "userr2")) ">:")))
(setvar "userr2" ll)
(setq ll (getvar "userr2"))
)
(command ".MOVE" ss "" p1 (polar p1 ang (/ ll bl)))
)
)
((= bz "O")
(if (= (getvar "userr1") 0) (setvar "userr1" 1.0))
(if (setq ll (getdist (strcat "\n偏移距离<" (rtos (getvar "userr1")) ">:")))
(setvar "userr1" ll)
(setq ll (getvar "userr1"))
)
(command ".OFFSET" (/ ll bl))
(while (> (getvar "CMDACTVE") 1) (command PAUSE))
)
(T
(if (= (getvar "userr5") 0) (setvar "userr5" 1.0))
(while (and (setq p1 (getpoint "\n起点<回车结束>:"))
(setq ang (getangle p1 "\n止点所在方向:")))
(if (setq ll (getdist (strcat "\n直线长度<" (rtos (getvar "userr5")) ">:")))
(setvar "userr5" ll)
(setq ll (getvar "userr5"))
)
(command ".LINE" p1 (polar p1 ang (/ ll bl)) "")
)
)
)
))
(if olddim (command "-DIMSTYLE" "R" olddim "GRAPHSCR"))
(princ)
)
1:100不挺好吗,为何要用1:1的。 是等于将图纸缩放0.01倍,文字高度和标注样式换成1:1的样式吗? tiancao100 发表于 2023-9-16 16:09
1:100不挺好吗,为何要用1:1的。 是等于将图纸缩放0.01倍,文字高度和标注样式换成1:1的样式吗?
我的意思是现在的lsp插件很多输入距离,不能像探索者一样自动换算,我感觉很麻烦,想问问lsp能不能也有这个功能:L hao3ren 发表于 2023-9-17 11:06
谢谢大佬,我好好研究研究 hao3ren 发表于 2023-9-17 11:06
您好,用了您提供的lsp,运行后似乎存在有点小问题,目前在1:100的情况下,输入100,得到的长度为10000,实际上我想得到的是1,请问该如何调整呢 在1:100的情况下,输入100,得到的长度是不是应该为100000?
(setq bl (/ (cdr(assoc 144 (tblsearch "DIMSTYLE" dimname))) 1000))
把里面的1000改为0.01 这是目前最遗憾的事情,为此三领没少废了劲!
页:
[1]
2