明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 424|回复: 4

CAD断面图超欠挖插件

[复制链接]
发表于 2024-6-14 20:38:30 | 显示全部楼层 |阅读模式
1明经币
(defun c:cqw (/ spl_real spl_design sty pt_n pt pt_near dim_mk) (setq spl_real (car (entsel "选择实际开挖线 red"))) (setq spl_design (car (entsel "选择设计开挖线 white"))) (setq sty nil) (setq pt_n (XD::Polyline:GetVertices spl_real)) (foreach pt pt_n  (progn   (setq pt_near (vlax-curve-getClosestPointTo spl_design pt))                    ;求距离点最近的曲线上的点   (if (xdrx_point_isinside pt spl_design)    (setq sty "隧道欠挖-")    (setq sty "隧道超挖+")   )   (setq dim_mk nil)                    ;直接生成有问题                    ;(setq dim_mk (xdrx_dimension_MakeAlign pt pt_near pt_near sty))                     ;(xdrx_dimension_update dim_mk)   (setq dim_mk (xdrx_dimension_MakeAlign pt pt_near pt_near))   (xdrx_dimension_SetStyle dim_mk sty)  ) ))

 楼主| 发表于 2024-6-14 20:39:49 | 显示全部楼层
有问题无法用,希望大神帮写
类似程序
回复

使用道具 举报

 楼主| 发表于 2024-6-24 15:58:57 | 显示全部楼层
;文件名:bz.lsp
;;功能说明:超欠挖标注
;;;修改时间:2024-06-20  ss en v-en pc ss1 en1 po-li n p11 pt pt@curve osm

(vl-load-com)
(defun c:bz(/ )  
  (setq osm (getvar "osmode"))  
  (setvar "cmdecho" 0)
  (setvar "osmode" 0)  

  (while
    (progn
      (prompt "\n请选择设计开挖线:")
      (not(setq ss(ssget ":s" '((0 . "CIRCLE,*POLYLINE")))))
        );end progn
    (prompt "\n<<<<未选择到正确的对象,请重新选择!>>>>")
  );end while

  (setq en(ssname ss 0)
        v-en(vlax-ename->vla-object en)
    )  
  (setq pc(find-centerpoint en));找设计开挖线的型心

  (while(progn(prompt "\n请选择实际开挖线:")
                (not(setq ss1(ssget ":s" '((0 . "*POLYLINE")))))
        );end progn
    (prompt "\n<<<<未选择到正确的对象,请重新选择!>>>>")
  );end while

  (setq en1(ssname ss1 0))
  (setq po-li (vl-remove-if 'not (mapcar '(lambda (x) (if (= (car x) 10) (cdr x))) (entget en1))));取多段线顶点表

  (initget 6)
  (setq n (getint "\n 请输入实际开挖线上标注间隔数(默认为0):"))
  (if(null n)(setq n 0))

  (if(/= n 0)(setq po-li(get-new-point-list po-li n)));end if

  (foreach pt po-li   
    (setq pt@curve(vlax-curve-getClosestPointTo v-en pt))

    (if(> (distance pt pc) (distance pt@curve pc));如果超挖
      (progn
      (setq p11 (polar pt@curve (angle pt@curve pt) (* 2 (distance pt pt@curve))))
      ;(make-dimension pt pt@curve p11 "隧道超挖+")
      (make-dimension pt pt@curve p11 "+<>" 3);箭头及线颜色3 绿色
    ;   (command "_.pline" P11 pc "")
      );end progn
      );end if

    (if(< (distance pt pc) (distance pt@curve pc));如果欠挖
      (progn
      (setq p11(polar pt(angle pt pt@curve ) (* 3 (distance pt pt@curve))))
      ;(make-dimension pt@curve pt p11 "隧道欠挖-")
      (make-dimension pt@curve pt p11 "-<>" 1);箭头及线颜色1 红色
     ;  (command "_.pline" Pt p11 "")
      );end progn
      );end if

    );end foreach

  (setvar "osmode" osm)
  (princ)  
  );end defun

;;;sub-routine1
(defun find-centerpoint(en / po-li n y pc)
  (setq entda(entget en)
        ename(cdr(assoc 0 entda)))
  (if(= ename "CIRCLE")
    (setq pc(cdr(assoc 10 entda)))
    (progn
      (setq po-li (vl-remove-if 'not (mapcar '(lambda (x) (if (= (car x) 10) (cdr x))) entda)))
      (setq n(length po-li))  
      (setq y(apply 'mapcar (cons '+ po-li)))
      (setq pc(mapcar '/ y (list n n n)))
      );progn
    );end if
  );end defun

;;;sub-routine2
(defun make-dimension (p14 p13 p11 dimsty ys)
  (entmake (list '(0 . "DIMENSION")
                 '(100 . "AcDbEntity")
                 '(100 . "AcDbDimension")                 
                  (cons 10 p14)
                  (cons 11 p11)
                 '(70 . 33)
                  (cons 1 dimsty);前缀符号
                  (cons 3 "超欠挖")
                 '(100 . "AcDbAlignedDimension")
                 (cons 13 p13)
                 (cons 14 p14)
                 (cons 62 ys) ;箭头及线颜色
                 )
           );endmake  
  );end defun

;;;sub-routine3
;;;间隔N个数取点表
(defun get-new-point-list(li n / s-li i k)
  (setq s-li nil i 0 k (1+ n))

  (while(nth i li)
    (setq s-li(cons (nth i li) s-li))
    (setq i(+ i k))
    );end while

  (reverse s-li)
  );end defun
回复

使用道具 举报

 楼主| 发表于 2024-6-24 16:00:30 | 显示全部楼层
cjf160204 发表于 2024-6-24 15:58
;文件名:bz.lsp
;;功能说明:超欠挖标注
;;;修改时间:2024-06-20  ss en v-en pc ss1 en1 po-li n p11  ...

大神帮着修改的,已经能用,效果也不错
回复

使用道具 举报

 楼主| 发表于 2024-6-24 16:01:38 | 显示全部楼层
。。。。。。。。。。。。。。。。。。。。。。。。。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-9-8 10:10 , Processed in 0.197946 second(s), 19 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表