乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: robertbon

[编程交流] 使dimlinear关联

[复制链接]

0

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-5 19:26:28 | 显示全部楼层
对不起我的英语。
我也有类似的问题。
2007年在俄罗斯CAD论坛上找到了部分解决方案。
当线条被修改时,尺寸会发生反应,但它不是真正的关联。
 
  1. (defun EditDimassoc (ent_list dict_id / length_list i el el1 ent_list_new)
  2.   (setq ent_list_new '())
  3.   (setq length_list (length ent_list))
  4.   (setq i 0 )
  5.   (while (< i length_list)
  6.      (setq el (nth i ent_list))
  7.      (if (= i 2)
  8.         (progn
  9.            (setq el1 (list '(102 . "{ACAD_REACTORS") (cons 330 dict_id) '(102 . "}") (cons 330 dict_id)))
  10.            (setq ent_list_new (append ent_list_new el1))
  11.         ); end progn
  12.         (setq ent_list_new (append ent_list_new (list el)))
  13.      ); end if
  14.      (setq i (1+ i))
  15.   ); end while
  16.   ent_list_new
  17. ); end defun
  18. ;--------------------------------------------------------------------------------------------
  19. (defun EditDimension (ent_list dict_id dimassoc_id / length_list i el el1 ent_list_new)
  20.   (setq ent_list_new '())
  21.   (setq length_list (length ent_list))
  22.   (setq i 0 )
  23.   (while (< i length_list)
  24.      (setq el (nth i ent_list))
  25.      (if (= i 2)
  26.         (progn
  27.            (setq el1 (list '(102 . "{ACAD_XDICTIONARY") (cons 330 dict_id) '(102 . "}")
  28.                                    '(102 . "{ACAD_REACTORS") (cons 330 dimassoc_id) '(102 . "}")
  29.                                     el))
  30.            (setq ent_list_new (append ent_list_new el1))
  31.         ); end progn
  32.         (setq ent_list_new (append ent_list_new (list el)))
  33.      ); end if
  34.      (setq i (1+ i))
  35.   ); end while
  36.   ent_list_new
  37. ); end defun
  38. ;--------------------------------------------------------------------------------------------
  39. (defun SetDimAssoc (obj1 obj2 / dim_id dim_list dimassoc_id dimassoc_list dict_id dict_list )
  40.   (setq dim_id dim_obj)
  41.   (setq dim_list (entget dim_id))
  42.   (setq dimassoc_id (entmakex (list '(0 . "DIMASSOC")
  43.                                                   '(100 . "AcDbDimAssoc")  (cons 330 dim_id)
  44.                                                   '(90 . 3) '(70 . 0) '(71 . 0)
  45.                                                   '(1 . "AcDbOsnapPointRef") (cons 331 obj1)
  46.                                                   '(72 . 13) '(40 . 1.0) (cons 10 (cdr (assoc 10 (entget obj1))))
  47.                                                   '(1 . "AcDbOsnapPointRef") (cons 331 obj2)
  48.                                                   '(72 . 1) '(40 . 1.0)   (cons 11 (cdr (assoc 10 (entget obj2))))
  49.                                          );list
  50.                              );entmake
  51.   );setq
  52.   (setq dimassoc_list (entget dimassoc_id))
  53.   (entmod dimassoc_list)
  54.   (setq dict_id (entmakex (list '(0 . "DICTIONARY")
  55.                                                (cons 330 dim_id)
  56.                                                '(100 . "AcDbDictionary")
  57.                                                '(280 . 1) '(281 . 1)
  58.                                                '(3 . "ACAD_DIMASSOC")
  59.                                                (cons 360 dimassoc_id)
  60.                                       );list
  61.                        );entmake
  62.   )
  63.   (setq dict_list (entget dict_id))
  64.   (entmod dict_list)
  65.   (setq dict_list (EditDimassoc dimassoc_list dict_id))
  66.   (entmod dict_list)
  67.   (setq dim_list (EditDimension dim_list dict_id dimassoc_id))
  68.   (entmod dim_list)
  69.   (entupd dim_id)
  70. ); end defun
  71. (defun Test_DimAssoc ( / line1 line2 line3 ang doc mspace obj dim_obj)
  72.   (command "_line" '(0 0) '(0 100) "")
  73.   (setq line1 (entlast))
  74.   (command "_line" '(0 100) '(100 100) "")
  75.   (setq line2 (entlast))
  76.   (command "_line" '(100 100) '(150 0) "")
  77.   (setq line3 (entlast))
  78.   (setq ang 0)
  79.   (setq doc (vla-get-activeDocument (vlax-get-acad-object)))
  80.   (setq mspace (vla-get-modelSpace doc))
  81.   (setq obj (vla-addDimRotated mspace (vlax-3d-point (cdr (assoc 10 (entget line2))))
  82.                                                         (vlax-3d-point (cdr (assoc 11 (entget line3))))
  83.                                                         (vlax-3d-point '(100 150))
  84.                                                         ang))
  85.   (setq dim_obj (vlax-vla-object->ename obj))
  86.   (vlax-release-object obj)
  87.   (SetDimAssoc line2 line3)
  88.   (princ)
  89. ); end defun
  90. (Test_DimAssoc)
回复

使用道具 举报

62

主题

466

帖子

404

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
310
发表于 2022-7-5 19:31:59 | 显示全部楼层
感谢您的投入!这让我回头看看我的方法。我注意到我忘了什么
 
 
 
 
下面的代码适用于尚未关联的现有标注
 
  1. (defun c:Dassoc ( / _dimension _object _extensiondictionary _dimassoc _number _list )
  2. (if
  3.    (and (setq _dimension (car (entsel "\nSpecify Dimension: ")))
  4.      (or (wcmatch (cdadr (setq _dimension (entget _dimension))) "*DIMENSION*")
  5.         (alert "You must select a dimension to continue!")
  6.      )
  7.      (setq _object (car (entsel "\nSpecify line associate with: ")))
  8.      (or (wcmatch (cdadr (entget _object)) "LINE")
  9.         (alert "You must select a Line to continue!")
  10.      )
  11.    )
  12.    (progn
  13.      (setq _extensiondictionary
  14.        (handent
  15.          (vla-get-handle
  16.            (vla-getextensiondictionary
  17.              (vlax-ename->vla-object (cdar _dimension))
  18.            )
  19.          )
  20.        )
  21.      )
  22.      (setq _dimassoc
  23.        (entmakex
  24.          (list
  25.            (cons 0 "DIMASSOC")
  26.            (cons 100 "AcDbDimAssoc")
  27.            (cons 330 (cdar _dimension))
  28.            (cons 90 3)
  29.            (cons 70 0)
  30.            (cons 71 0)
  31.            (cons 1 "AcDbOsnapPointRef")
  32.            (cons 72 1)
  33.            (cons 331 _object)
  34.            (cons 73 13)
  35.            (cons 91 3)
  36.            (cons 40 1.0)
  37.            (cons 10 '(0.0 0.0 2.0e+050))
  38.            (cons 75 0)
  39.            (cons 1 "AcDbOsnapPointRef")
  40.            (cons 331 _object)
  41.            (cons 72 1)
  42.            (cons 73 2)
  43.            (cons 91 3)
  44.            (cons 40 1.0)
  45.            (cons 10 '(0.0 0.0 2.0e+050))
  46.            (cons 75 0)
  47.          )
  48.        )
  49.      )
  50.      (entmod
  51.        (append (entget _extensiondictionary)
  52.          (list (cons 3 "ACAD_DIMASSOC") (cons 360 _dimassoc))
  53.        )
  54.      )
  55.      (setq _number (vl-position (assoc 330 _dimension) _dimension))
  56.      (repeat _number
  57.        (setq _list (cons (nth (setq _number (1- _number)) _dimension) _list))
  58.      )
  59.      (entmod
  60.        (append _list
  61.          (list '(102 . "{ACAD_XDICTIONARY") (cons 330 _extensiondictionary) '(102 . "}")
  62.            '(102 . "{ACAD_REACTORS") (cons 330  _dimassoc) '(102 . "}")
  63.          )
  64.          (member (assoc 330 _dimension) _dimension)
  65.        )
  66.      )
  67.    )
  68. ) (princ)
  69. )
回复

使用道具 举报

0

主题

2

帖子

2

银币

初来乍到

Rank: 1

铜币
0
发表于 2022-7-5 19:33:09 | 显示全部楼层
非常感谢。我的问题解决了。
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 13:46 , Processed in 0.481540 second(s), 56 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表