prodromosm 发表于 2022-7-5 23:19:52

有关线型和的litle帮助

早上好我需要一点帮助。我试着写一个lisp来画一条线
具有特定的石灰类型,但线条比例并不总是相同的
 
(defun c:DASHDOT ()
(command "_layer" "m" "DASHDOT" "c" "1" "" "")
(setq scl (getvar "useri1"))
((SETQ DAS "DASHDOT")(setvar "LTSCALE" scl))
(command"linetype" "s" DAS "" )
(print "draw DASHDOT line ")
(print "")
(setq s1 (getpoint "give the first point :"))
(print "")
(WHILE (setq s2 (getpoint s1 " give the second point :"))
(print "")
(command "line" s1 s2 "")
(setq s1 s2)

)
)
 
当scl改变时,线型改变
 
谢谢

MSasu 发表于 2022-7-5 23:24:50

这假设设置了USERI1系统变量;如果不是,则返回0,这不是LTSCALE允许的值:
(setq scl (getvar "useri1"))
...
(setvar "LTSCALE" scl)
请删除此语句的外括号:
((SETQ DAS "DASHDOT")(setvar "LTSCALE" scl))
此外,考虑不仅对命令使用下划线,而且对其选项也使用下划线。首先验证该层的存在是有用的:
(if (not (tblsearch "LAYER" "DASHDOT"))
(command "_layer" "_m" "DASHDOT" "_c" "1" "" "")
)
使用系统字作为变量和函数(如DASHDOT)的名称不是一种好的编程实践,尽管这不是一种保留名称。

prodromosm 发表于 2022-7-5 23:29:04

你好,MSasu
我做了这个改变,lisp也能正常工作

(defun c:TEST (/ scl klim)
(if (not (tblsearch "LAYER" "DASHDOT"))
(command "_layer" "_m" "DASHDOT" "_c" "1" "" "")
)
(setq scl (getvar "useri1"))
(setq klim (* 0.0017 scl))
(SETQ PER "DASHDOT" )
(setvar "LTSCALE" klim)
(command"linetype" "s" per "" )
(print "draw DASHDOT line ")
(print "")
(setq s1 (getpoint "give the first point :"))
(print "")
(WHILE (setq s2 (getpoint s1 " give the second point :"))
(print "")
(command "line" s1 s2 "")
(setq s1 s2)

)
)

 
但我还有一个问题。运行lisp时,将线型比例更改为图形中的所有线。我不想将线型比例仅更改为特定的线条

MSasu 发表于 2022-7-5 23:33:37

这是正常的,因为LTSCALE系统变量控制用虚线类型绘制的所有图元的外观。要仅针对一个实体进行调整,只需添加以下语句即可。可能有助于确保对当前Osnap没有干扰。
...
(setvar "LTSCALE" klim)
...
(command "_line" "_non" s1 "_non" s2 "")
(comamnd "_CHPROP" (entlast) "" "_S" klim "")
...

prodromosm 发表于 2022-7-5 23:34:46

 
我无法理解。你能说得更具体些吗

prodromosm 发表于 2022-7-5 23:40:24


(defun c:TEST (/ scl klim)
(if (not (tblsearch "LAYER" "DASHDOT"))
(command "_layer" "_m" "DASHDOT" "_c" "1" "" "")
)
(setq scl (getvar "useri1"))
(setq klim (* 0.0017 scl))
(SETQ PER "DASHDOT" )
(command"linetype" "s" per "" )
(print "draw DASHDOT line ")
(print "")
(setq s1 (getpoint "give the first point :"))
(print "")
(WHILE (setq s2 (getpoint s1 " give the second point :"))
(print "")
(command "line" s1 s2 "")
(setq s1 s2)




)
)


 
那么呢
 
(command "_line" "_non" s1 "_non" s2 "")
(comamnd "_CHPROP" (entlast) "" "_S" klim "")
 
我只想更改这次绘制的部分线条的线型比例。例如,我画一条线,然后转到“特性”菜单并更改线型比例。然后我再画一条线,转到“属性”菜单,并给出另一个比例,但我不想将比例更改为预览线

MSasu 发表于 2022-7-5 23:42:42

我补充了一些意见:
(comamnd "_CHPROP"   ;call the CHPROP command
      (entlast)   ;select the last added entity (your line)
      ""          ;close the selection process
      "_S" klim   ;adjust the entity linetye scale property using the ltScale option
      "")         ;last <Enter> will close the command which is repetitive.

prodromosm 发表于 2022-7-5 23:46:40

不起作用。也许我做错了同样的事。我只想更改这条线的线型比例。我运行lisp并为图形中的所有线提供相同的线型比例,这是错误的。我对每条线使用不同的线型比例。。
我希望在线型管理器窗口中全局比例因子为1,当前对象比例为1,并且仅在“特性”窗口中必须更改线型比例

MSasu 发表于 2022-7-5 23:49:21

请发布最新更改的代码。

prodromosm 发表于 2022-7-5 23:54:16


(defun c:TEST1 (/ scl klim)
(if (not (tblsearch "LAYER" "DASHDOT"))
(command "_layer" "_m" "DASHDOT" "_c" "1" "" "")
)
(setq scl (getvar "useri1"))
(setq klim (* 0.0017 scl)
(comamnd "_CHPROP""" "_S" klim "")
(SETQ PER "DASHDOT" )
(command"_linetype" "s" per "" )
(print "draw DASHDOT line ")
(print "")
(setq s1 (getpoint "give the first point :"))
(print "")
(WHILE (setq s2 (getpoint s1 " give the second point :"))
(print "")
(command "line" s1 s2 "")
(setq s1 s2)

)
)
页: [1] 2
查看完整版本: 有关线型和的litle帮助