gpt4 book ai didi

lisp - 选择折线时 Autocad 错误 "error: bad arguement type: lselsetp nil"

转载 作者:太空宇宙 更新时间:2023-11-03 18:54:54 26 4
gpt4 key购买 nike

我目前正在尝试在沿着另一条多段线运行的两个 block (first_block、second_block)之间运行一条多段线,在操作结束时调用一个插入函数,该函数使用开始的详细信息填充注释 block (cable_name_tag)和结束 block 。

此折线将横切其他 block ,并且通常需要与底层折线(cable_ducting)平行运行,因此用户需要选择折线的适当部分来删除注释,因为有时空间有限。

我注意到,如果我注释掉 second_block 并提供硬编码值,则 ssget 函数可以正常工作,因此我有理由相信问题出在该代码中 first_block 和 second_block 的语法或处理上。

(defun c:cable ()
(vl-load-com)
(setvar "clayer" "cable layer")
(setvar "celtype" "bylayer")
(setvar "osmode" 515)
(command "_.pline"
(getpoint))
(while (> (getvar ' cmdactive) 0)
(command pause)
(princ "\npress enter to finish:"))
(setq elst
(entsel "\nselect cable segment: "))
(setq ename
(car elst))
(setq pt
(cadr elst))
(setq annopt pt)
(setq pt
(vlax-curve-getclosestpointto ename pt))
(setq param
(vlax-curve-getparamatpoint ename pt))
(setq preparam
(fix param))
(setq postparam
(1+ preparam))
(list (setq pt1
(vlax-curve-getpointatparam ename preparam))
(setq pt2
(vlax-curve-getpointatparam ename postparam)))
(setq cable
(entlast))
(setq cable_start
(vlax-curve-getstartparam cable))
(setq cable_start_point
(vlax-curve-getstartpoint cable))
(setq cable_end_point
(vlax-curve-getendpoint cable))
(setq cable_end
(angtos (angle '(0 0)
(vlax-curve-getfirstderiv cable 0.0))))
(setq first_block
(ssget "_c" cable_start_point cable_end_point
(list (cons 0 "insert")
(cons 2 "first_block"))))
(setq second_block
(ssget "_c" cable_start_point cable_end_point
(list (cons 0 "insert")
(cons 2 "second_block"))))
(setq end_cable
(ssname second_block 0))
(setq start_cable
(ssname first_block 0))
(setq $end_cable
(vla-get-textstring
(cadr (vlax-safearray->list
(variant-value
(vla-getattributes
(vlax-ename->vla-object end_cable)))))))
(setq $start_cable
(vla-get-textstring
(cadr (vlax-safearray->list
(variant-value
(vla-getattributes
(vlax-ename->vla-object start_cable)))))))
(setq cable_name
(vlax-curve-getendparam cable))
(command ; insert cable param
"-insert"
"cable_name_tag"
annopt
"1"
"1"
cable_angle
cable_name
$start_cable
$end_cable
"144"
cable_length))

我被困在一个角落里,非常感谢任何人可以提供的任何帮助、建议或指示。

谢谢大家的宝贵时间。

最佳答案

为什么不直接使用 (entlast) 来获取刚刚创建的实体?

关于lisp - 选择折线时 Autocad 错误 "error: bad arguement type: lselsetp nil",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12504861/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com