本帖最后由 晨曦CAD 于 2022-12-6 19:06 编辑
案例:将圆和圆弧转为两节点多段线
案例来自帖子:[url=[函数] 将圆和圆弧转为两节点多段线]http://bbs.mjtd.com/thread-186768-1-1.html[/url]
人工智能给出如下答案:
- ;; 定义一个函数,用于将圆和圆弧转为两节点多段线
- (defun c:circle2polyline ()
- (vl-load-com)
- ;; 获取当前文档中的所有圆和圆弧
- (setq entities (vlax-get-Objects (vla-get-activedocument (vlax-get-acad-object)) '((8 . "CIRCLE") (8 . "ARC"))))
- (foreach entity entities
- (setq center (vlax-get-property entity 'center))
- (setq radius (vlax-get-property entity 'radius))
- ;; 如果是圆弧,则取出圆弧的起点和终点
- (if (vlax-member-of-object entity 'objectname "ARC")
- (setq start (vlax-get-property entity 'startpoint))
- (setq start center))
- (if (vlax-member-of-object entity 'objectname "ARC")
- (setq end (vlax-get-property entity 'endpoint))
- (setq end center))
- ;; 将圆或圆弧转为两节点多段线
- (command "pline" start end center)))
- (princ))
测试了一下,只是像模像样,实际一跑就报错
|