明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
楼主: userzhl

[求助]如何能设置标注点到标注线的距离?(禁止liminnet xchrimp跟贴)

    [复制链接]
 楼主| 发表于 2009-7-20 14:43:00 | 显示全部楼层
是呀,也是菜鸟一个,才刚学会搞菜单。。。总到网上忽悠人,还经常换马甲,最近好像又换成了xchrimp,还仿人家高手名字,让人总容易误会是xshrimp我在好多个群里的人都说他不地道,包括院长。
发表于 2009-7-20 16:24:00 | 显示全部楼层
userzhl发表于2009-7-19 21:47:00经过测试,有问题,当标注起点与标注线距离为0时,会有出错。

这也不能全怪人家,当起点和标注线距离为0时,用户必须提供一个距离和矢量,才能修改新的起点,所以给 AutoCAD 的数据一定要足够!!

通过组码10 13 14求 标注对象箭头位置是不科学的!!

发表于 2009-7-20 16:40:00 | 显示全部楼层
提示: 作者被禁止或删除 内容自动屏蔽
发表于 2009-7-20 17:41:00 | 显示全部楼层
本帖最后由 作者 于 2009-7-21 1:23:25 编辑

;;-已经修改

(defun c:TT (/ lt:dim-definingPoint ss i di en ent p13 p14 p1 p2 a p13@ p14@ p ang)

(defun lt:dim-definingPoint (edata / dxf typ p10 p13 p14 ang)
  (setq dxf (lambda (x) (cdr (assoc x edata)))
        typ (- (dxf 70) 32)
        p10 (dxf 10)
        p13 (dxf 13)
  )
  (list (cond
          ((zerop typ)
           (setq ang (dxf 50) p13 (list (car p13) (cadr p13) (last p10)))
           (inters p10 (polar p10 ang 1) p13 (polar p13 (+ ang (/ pi 2)) 1) nil)
          )
          ((= typ 1)
           (setq p14 (dxf 14) ang (if (equal p14 p13 1e-7) 0 (angle p14 p13)))
           (if (equal p10 p14 1e-7)
             p13
             (polar p10 ang (dxf 42))
           )
          )
        )
        p10
  )
)
(if (and (setq ss (ssget '((0 . "DIMENSION"))))
         (progn
           (initget 7)
           (setq di (getdist "\n指定标注界限长度: "))
         )
    )
  (repeat (setq i (sslength ss))
    (setq en  (ssname ss (setq i (1- i)))
          ent (entget en)
          p13 (cdr (assoc 13 ent))
          p14 (cdr (assoc 14 ent))
    )
    (mapcar 'set '(p1 p2) (lt:dim-definingPoint ent))
    (setq a    (+ (angle p1 p2) (/ pi 2))
          p13@ (inters p1 p2 p13 (polar p13 a 1) nil)
          p14@ (inters p1 p2 p14 (polar p14 a 1) nil)
    )
    (if (or (and (equal p13 p13@ 1E-6)
                 (equal p14 p14@ 1E-6)
            )
            (not (equal (angle p14 p14@) (angle p13 p13@) 1E-6))
        )
      (progn
        (redraw en 3)
        (setq p   (getpoint "\n无法判断标注界限方向,请重新指定: ")
              ang (angle (inters p1 p2 p (polar p a 1) nil) p)
        )
        (redraw en 4)
      )
      (setq ang (angle p13@ p13))
    )
    (setq p13 (cons 13 (polar p13@ ang di))
          p14 (cons 14 (polar p14@ ang di))
    )
    (entmod (subst p14 (assoc 14 ent) (subst p13 (assoc 13 ent) ent)))
  )
)
(princ)
)

 楼主| 发表于 2009-7-20 18:25:00 | 显示全部楼层

为什么是错的?版主:

选择对象:  ; 错误: 参数类型错误: 二维/三维点: nil

发表于 2009-7-20 19:39:00 | 显示全部楼层
我测试无错,请把测试文件发上来
 楼主| 发表于 2009-7-20 19:54:00 | 显示全部楼层
本帖最后由 作者 于 2009-7-20 20:54:48 编辑

院长已经解决。

发表于 2009-7-20 22:59:00 | 显示全部楼层
本帖最后由 作者 于 2009-7-21 1:25:19 编辑

我找到了以前写的一个函数可以用,liminnet 以前求救的帖子中我发过,但对于“样式替代”的错误至今没有修改!

;; [功能] 获取标注的定义点
;; [参数] edata---标注对象的 DXF 定义数据
;; [返回] 包含两个点的表,依次为 (第一个尺寸线定义点 第二个尺寸线定义点p10)
(defun lt:dim-definingPoint (edata / dxf typ p10 p13 p14 ang)
  (setq dxf (lambda (x) (cdr (assoc x edata)))
        typ (- (dxf 70) 32)
        p10 (dxf 10)
        p13 (dxf 13)
  )
  (list (cond
          ((zerop typ)
           (setq ang (dxf 50) p13 (list (car p13) (cadr p13) (last p10)))
           (inters p10 (polar p10 ang 1) p13 (polar p13 (+ ang (/ pi 2)) 1) nil)
          )
          ((= typ 1)
           (setq p14 (dxf 14) ang (if (equal p14 p13 1e-7) 0 (angle p14 p13)))
           (if (equal p10 p14 1e-7)
             p13
             (polar p10 ang (dxf 42))
           )
          )
        )
        p10
  )
)

发表于 2009-7-20 23:39:00 | 显示全部楼层
找vla对象参考去吧!
发表于 2009-7-21 01:20:00 | 显示全部楼层
24楼已经修改
您需要登录后才可以回帖 登录 | 注册

本版积分规则

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

GMT+8, 2024-10-2 14:35 , Processed in 0.173042 second(s), 18 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

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