- UID
- 813421
- 积分
- 12
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2025-3-21
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
帮忙看一下程序,该程序将command命令自动生成的图元转换成图块,程序在-BLOCK和-INSERT参数好像都有问题,不知道如何修改?
源码如下:
(defun c:tkcreate ()
;; 生成图块函数
(setvar "cmdecho" 0)
;; 保存生成前的最后一个实体
(setq old_ent (entlast))
;; 使用command生成图元(示例:直线和圆)
(command "line" "0,0" "1000,5000" "") ; 示例图元1
(command "circle" "5,0" "3000") ; 示例图元2
(command "line" "1000,2000" "5000,0" "") ; 示例图元3
;; 收集新生成的实体
(setq new_ents '())
(if old_ent
(progn
(setq ent (entnext old_ent))
(while ent
(setq new_ents (cons ent new_ents))
(setq ent (entnext ent))
)
)
;; 如果old_ent为nil,则所有实体都是新的
(progn
(setq ent (entnext))
(while ent
(setq new_ents (cons ent new_ents))
(setq ent (entnext ent))
)
)
)
(setq new_ents (reverse new_ents))
;; 创建选择集
(setq ss (ssadd))
(setq tempent (car new_ents))
(while tempent
(ssadd tempent ss)
(setq new_ents (cdr new_ents))
(setq tempent (car new_ents))
)
;; 设置块名和基点
(setq blockname "MyBlock1")
;; 检查块是否存在
(if (tblsearch "BLOCK" blockname)
(princ (strcat "\n块 " blockname " 已存在。"))
(progn
(sssetfirst nil ss)
;; 创建块定义
(command "-BLOCK" blockname '(0 0))
;; 插入块实例
(command "-INSERT" blockname '(0 0) "" "" "") ; 此处出问题
(princ (strcat "\n块 " blockname " 创建成功。"))
)
)
(princ)
)
|
|