samifox 发表于 2022-7-5 18:00:09

组合Dim和Continue as

你好
我通常使用dim工具设置dim线的初始位置,然后使用Continue模式继续该线。永远不明白为什么初始位置设置后,继续模式不会自动触发?
所以再说一次,
1、拾取dim工具
2、设置起点和终点位置
3、调暗换刀继续
4、拾取下一个点
有没有办法用柴油机编程?或者只能通过Lisp程序来完成?
 
谢谢
S

msirois 发表于 2022-7-5 18:09:44

我不确定这是否是你想要的,但这是我在办公室使用的。我通常只画一个整体尺寸,然后用这个LISP在每个需要的点上拆分尺寸。如果出错,也可以使用它连接维度。
 
命令为DIMSPLIT和DIMJOIN。
 
(defun C:DIMSPLIT (/ OBJ_PICK DIM_PICK DIM_ENT DIM_NODE1 DIM_NODE2 DIM_DEF
DIM_POINT DIM_OBJ)
;(STORE)
(command ".undo" "group")
;(setvar "osmode" 183)
(setq DIM_PICK 1)
(while (and DIM_PICK (/= OBJ_PICK "DIMENSION"))
   (setq DIM_PICK (entsel "\nSelect Dimension: "))
   (if DIM_PICK
   (progn
       (setq OBJ_PICK (cdr (assoc 0 (entget (car DIM_PICK))))
             DIM_ENT (entget (car DIM_PICK))
       )
       (if (/= OBJ_PICK "DIMENSION") (prompt "\nThis is not a Dimension
object."))
   )
   )
)
(if (or (= (cdr (assoc 70 DIM_ENT)) 32) ; IF ALIGNED OR ROTATED DIMENSION
         (= (cdr (assoc 70 DIM_ENT)) 160)
         (= (cdr (assoc 70 DIM_ENT)) 33)
         (= (cdr (assoc 70 DIM_ENT)) 161)
   )
   (progn
   (setq DIM_NODE1 (cdr (assoc 13 DIM_ENT))
         DIM_NODE2 (cdr (assoc 14 DIM_ENT))
         DIM_DEF (cdr (assoc 10 DIM_ENT))
         DIM_POINT (getpoint "\nPick split point: ")
   )
   (if DIM_POINT
       (progn
         (if (or (= (cdr (assoc 70 DIM_ENT)) 33) (= (cdr (assoc 70
DIM_ENT)) 161)) ; IF ALIGNED DIMENSION, RESET SPLIT POINT TO ALIGN BETWEEN
NODES
         (setq DIM_POINT (inters (polar DIM_POINT (angle DIM_DEF
DIM_NODE2) 12.0) DIM_POINT DIM_NODE1 DIM_NODE2 nil))
         )
         (setq DIM_OBJ (subst (cons 13 DIM_POINT) (assoc 13 DIM_ENT)
DIM_ENT))
         (entmod DIM_OBJ)
         (command "copy" DIM_PICK "" DIM_POINT DIM_POINT)
         (setq DIM_ENT (entget (entlast))
               DIM_OBJ (subst (cons 14 DIM_NODE1) (assoc 14 DIM_ENT)
DIM_ENT)
         )
         (entmod DIM_OBJ)
       )
   )
   )
   (if DIM_PICK (prompt "\nThis is neither a Rotated nor an Aligned
Dimension."))
)
(command ".undo" "end")
;(RESTORE)
(princ)
)

(defun C:DIMJOIN (/ OBJ1_PICK DIM1_PICK DIM1_ENT DIM1_NODE1 DIM1_NODE2
DIM1_OBJ
                   OBJ2_PICK DIM2_PICK DIM2_ENT DIM2_NODE1 DIM2_NODE2
DIMCASE)
;(STORE)
(command ".undo" "group")
;(setvar "osmode" 183)
(setq DIM1_PICK 1
       DIM2_PICK 1
)
(while (and DIM1_PICK (/= OBJ1_PICK "DIMENSION"))
   (setq DIM1_PICK (entsel "\nSelect First Dimension: "))
   (if DIM1_PICK
   (progn
       (setq OBJ1_PICK (cdr (assoc 0 (entget (car DIM1_PICK))))
             DIM1_ENT (entget (car DIM1_PICK))
       )
       (if (/= OBJ1_PICK "DIMENSION") (prompt "\nThis is not a Dimension
object."))
   )
   )
)
(if (or (= (cdr (assoc 70 DIM1_ENT)) 32) ; IF ALIGNED OR ROTATED DIMENSION
         (= (cdr (assoc 70 DIM1_ENT)) 160)
         (= (cdr (assoc 70 DIM1_ENT)) 33)
         (= (cdr (assoc 70 DIM1_ENT)) 161)
   )
   (progn
   (if (= OBJ1_PICK "DIMENSION")
       (progn
         (while (and DIM2_PICK (/= OBJ2_PICK "DIMENSION"))
         (setq DIM2_PICK (entsel "\nSelect Second Dimension: "))
         (if DIM2_PICK
             (progn
               (setq OBJ2_PICK (cdr (assoc 0 (entget (car DIM2_PICK))))
                     DIM2_ENT (entget (car DIM2_PICK))
               )
               (if (/= OBJ2_PICK "DIMENSION") (prompt "\nThis is not a
Dimension object."))
             )
         )
         )
         (if (or (= (cdr (assoc 70 DIM2_ENT)) 32) ; IF ALIGNED OR ROTATED
DIMENSION
               (= (cdr (assoc 70 DIM2_ENT)) 160)
               (= (cdr (assoc 70 DIM2_ENT)) 33)
               (= (cdr (assoc 70 DIM2_ENT)) 161)
             )
         (progn
             (setq DIM1_NODE1 (cdr (assoc 13 DIM1_ENT))
                   DIM1_NODE2 (cdr (assoc 14 DIM1_ENT))
                   DIM2_NODE1 (cdr (assoc 13 DIM2_ENT))
                   DIM2_NODE2 (cdr (assoc 14 DIM2_ENT))
             )
      (if (= (fix (distance DIM1_NODE2 DIM2_NODE1)) 0.0)
      (setq DIM1_OBJ (subst (cons 14 DIM2_NODE2) (assoc 14 DIM1_ENT)
DIM1_ENT) DIMCASE 1)
      )
      (if (= (fix (distance DIM1_NODE2 DIM2_NODE2)) 0.0)
               (setq DIM1_OBJ (subst (cons 14 DIM2_NODE1) (assoc 14
DIM1_ENT) DIM1_ENT) DIMCASE 2)
      )
      (if (= (fix (distance DIM1_NODE1 DIM2_NODE1)) 0.0)
      (setq DIM1_OBJ (subst (cons 13 DIM2_NODE2) (assoc 13 DIM1_ENT)
DIM1_ENT) DIMCASE 3)
      )
      (if (= (fix (distance DIM1_NODE1 DIM2_NODE2)) 0.0)
      (setq DIM1_OBJ (subst (cons 13 DIM2_NODE1) (assoc 13 DIM1_ENT)
DIM1_ENT) DIMCASE 4)
      )
      (if DIMCASE
      (progn
               (entmod DIM1_OBJ)
               (command "erase" DIM2_PICK "")
      )
      (prompt "\nDimensions are not coincident.")
             )
             )
         (if DIM2_PICK (prompt "\nThis is neither a Rotated nor an
Aligned Dimension."))
         )
       )
   )
   )
   (if DIM1_PICK (prompt "\nThis is neither a Rotated nor an Aligned
Dimension."))
)
(command ".undo" "end")
;(RESTORE)
(princ)
)

(defun C:DIMDIVIDE (/ OBJ_PICK DIM_PICK DIM_ENT DIM_NODE1 DIM_NODE2 DIM_DEF
DIM_POINT DIM_OBJ)
;(STORE)
(command ".undo" "group")
;(setvar "osmode" 183)
(setq DIM_PICK 1)
(while (and DIM_PICK (/= OBJ_PICK "DIMENSION"))
   (setq DIM_PICK (entsel "\nSelect Dimension: "))
   (if DIM_PICK
   (progn
       (setq OBJ_PICK (cdr (assoc 0 (entget (car DIM_PICK))))
             DIM_ENT (entget (car DIM_PICK))
       )
       (if (/= OBJ_PICK "DIMENSION") (prompt "\nThis is not a Dimension
object."))
   )
   )
)
(if (or (= (cdr (assoc 70 DIM_ENT)) 32) ; IF ALIGNED OR ROTATED DIMENSION
         (= (cdr (assoc 70 DIM_ENT)) 160)
         (= (cdr (assoc 70 DIM_ENT)) 33)
         (= (cdr (assoc 70 DIM_ENT)) 161)
   )
   (progn
   (if (not DIM_DIV) (setq DIM_DIV 2))
   (initget 6)
   (setq DIM_DIV (DEFNUM DIM_DIV "\nNumber of divisions"))
   (if (and (= OBJ_PICK "DIMENSION") (> DIM_DIV 1))
       (progn
         (setq DIM_ENT (entget (car DIM_PICK))
               DIM_NODE1 (cdr (assoc 13 DIM_ENT))
               DIM_NODE2 (cdr (assoc 14 DIM_ENT))
               DIM_DEF (cdr (assoc 10 DIM_ENT))
               DIM_POINT (polar DIM_NODE1 (angle DIM_NODE1 DIM_NODE2) (/
(distance DIM_NODE1 DIM_NODE2) DIM_DIV))
               DIM_OBJ (subst (cons 14 DIM_POINT) (assoc 14 DIM_ENT)
DIM_ENT)
         )
         (entmod DIM_OBJ)
         (setq DIM_NODE2 (cdr (assoc 14 DIM_OBJ)))
         (command "copy" DIM_PICK "" DIM_NODE1 DIM_NODE2)
         (setq DIM_ENT (entget (entlast))
               DIM_OBJ (subst (cons 10 DIM_DEF) (assoc 10 DIM_ENT) DIM_ENT)
         )
         (entmod DIM_OBJ)
         (repeat (- DIM_DIV 2)
         (command "copy" (ENTLAST) "" DIM_NODE1 DIM_NODE2)
         (setq DIM_ENT (entget (entlast))
               DIM_OBJ (subst (cons 10 DIM_DEF) (assoc 10 DIM_ENT)
DIM_ENT)
         )
         (entmod DIM_OBJ)
         )
       )
   )
   )
   (if DIM_PICK (prompt "\nThis is neither a Rotated nor an Aligned
Dimension."))
)
(command ".undo" "end")
;(RESTORE)
(princ)
)

(defun C:DIMOFFSET (/ OBJ_PICK DIM_SIDE DIM_PICK DIM_ENT DIM_NODE1 DIM_NODE2
DIM_INT DIM_DEF DIM_POINT DIM_OBJ)
;(STORE)
(command ".undo" "group")
(if (not DIM_OFFS) (setq DIM_OFFS (* 0.375 (getvar "dimscale"))))
(initget 2)
(setq DIM_OFFS (DEFDIST DIM_OFFS "Specify offset distance"))
(setq DIM_PICK 1 OBJ_PICK 1)
(while (and DIM_PICK (/= OBJ_PICK "DIMENSION"))
   (setq DIM_PICK (entsel "\nSelect Dimension to offset: "))
   (if DIM_PICK
   (progn
       (setq OBJ_PICK (cdr (assoc 0 (entget (car DIM_PICK))))
             DIM_ENT (entget (car DIM_PICK))
       )
       (if (/= OBJ_PICK "DIMENSION") (prompt "\nThis is not a Dimension
object."))
   )
   )
)
(if (or (= (cdr (assoc 70 DIM_ENT)) 32) ; IF ALIGNED OR ROTATED DIMENSION
         (= (cdr (assoc 70 DIM_ENT)) 160)
         (= (cdr (assoc 70 DIM_ENT)) 33)
         (= (cdr (assoc 70 DIM_ENT)) 161)
   )
   (progn
   (setq DIM_SIDE (getpoint "\nSpecify point on side to offset: "))
   (if DIM_SIDE
       (if (and (= OBJ_PICK "DIMENSION") (> DIM_OFFS 0))
         (progn
         (setvar "osmode" 0)
         (setq DIM_ENT (entget (car DIM_PICK))
               DIM_NODE1 (cdr (assoc 13 DIM_ENT))
               DIM_NODE2 (cdr (assoc 14 DIM_ENT))
               DIM_DEF (cdr (assoc 10 DIM_ENT))
               DIM_INT (polar DIM_SIDE (angle DIM_DEF DIM_NODE2) 12.0)
               DIM_POINT (inters (polar DIM_DEF (+ (angle DIM_DEF
DIM_NODE2) (DTR 90.0)) 12.0) DIM_DEF DIM_SIDE DIM_INT nil)
         )
         (command "copy" DIM_PICK "" DIM_NODE2 (polar DIM_NODE2 (angle
DIM_POINT DIM_SIDE) DIM_OFFS))
         (setq DIM_ENT (entget (entlast))
               DIM_OBJ (subst (cons 13 DIM_NODE1) (assoc 13 DIM_ENT)
DIM_ENT)
         )
         (entmod DIM_OBJ)
         (setq DIM_ENT (entget (entlast))
               DIM_OBJ (subst (cons 14 DIM_NODE2) (assoc 14 DIM_ENT)
DIM_ENT)
         )
         (entmod DIM_OBJ)
         (setq DIM_ENT (entget (entlast))
               DIM_DEF (polar DIM_DEF (angle DIM_POINT DIM_SIDE)
DIM_OFFS)
               DIM_OBJ (subst (cons 10 DIM_DEF) (assoc 10 DIM_ENT)
DIM_ENT)
         )
         (entmod DIM_OBJ)
         )
       )
   )
   )
   (if DIM_PICK (prompt "\nThis is neither a Rotated nor an Aligned
Dimension."))
)
(command ".undo" "end")
;(RESTORE)
(princ)
)

samifox 发表于 2022-7-5 18:11:51

 
这是不错的选择谢谢
 
实际上,我希望变暗工具在设置变暗线位置后自动切换到“继续”工具

msirois 发表于 2022-7-5 18:17:48

好的,我通常用DIMLINEAR,但是试着用DIM,为什么不在你画第一个维度后输入“C”?C代表继续,你可以无限期地继续。

samifox 发表于 2022-7-5 18:25:04

 
你是指DCO。。。。
 
在我看来,
 
单击“起点”和“终点”后,下一个点应自动继续变暗。为什么不是这样?

msirois 发表于 2022-7-5 18:32:26

 
嗯,我正在使用AutoCAD 2016。。。所以这可能是一个版本问题。这是我完成第一个维度后看到的
http://imgur.com/mOkEkdy

samifox 发表于 2022-7-5 18:33:47

其防御版本问题,
im使用acad 2010,
 
Lisp程序是我唯一的原因?

msirois 发表于 2022-7-5 18:40:49

 
可能但您可以尝试以下命令:“DIMCONTINUE”,看看在2010年是否有效。如果可以,您可以编写一个同时运行DIM命令和DIMCONTINUE命令的LISP,也可以创建一个快捷键来运行DIMCONTINUE命令
 
一、 e.将其设置为快捷方式^C^C\U Dimlinear\\\_dimcontinue;

samifox 发表于 2022-7-5 18:48:07

 
我试过你的Lisp程序,
这是一个非常强大的尺寸概念,
但为什么它会在一点后停止?

msirois 发表于 2022-7-5 18:53:36

 
公平地说,这是我使用的LISP,不是我写的。但我相信它会在一点之后停止,因为它创建了两条新的尺寸线,它不知道在哪里继续。你有没有试过我之前的建议,把DIMCONTINUE指定给一个快捷键?
页: [1] 2
查看完整版本: 组合Dim和Continue as