Snownut 发表于 2022-7-6 09:49:35

Dimstyle数据检索?

我试图从单个DIMIE中检索所有测量数据;为单个dimstyle的每个标注添加所有测量值。我希望在LISP中执行此操作,然后将结果用作单个变量。有什么想法吗?
 
提前感谢您提供的所有帮助。
 
布鲁斯

Smirnoff 发表于 2022-7-6 10:02:02

oLst变量中的所有测量值。
 
(defun c:test(/ sDim dSet dLst dSty oLst)
(if(and
      (setq sDim(entsel "\nPick sample dimension > "))
      (equal '(0 . "DIMENSION")(assoc 0(entget(car sDim))))
      (setq dSty(assoc 3(entget(car sDim))))
      ); end and
   (progn
   (setq dSet(ssget "_X" (list '(0 . "DIMENSION") dSty))
    dLst(vl-remove-if 'listp(mapcar 'cadr(ssnamex dSet)))
    ); end setq
   (foreach d dLst
(setq oLst(append oLst(list(cdr(assoc 42(entget d))))))
); end foreach
   ); end progn
   (progn "\n<!> This isn't dimension <!> ")
   ); end if
(princ "\n")(textscr)
oLst
); end of c:test

Smirnoff 发表于 2022-7-6 10:09:22

 
Ок. 所选dimstyle的所有尺寸的总和长度。
 
(defun c:test(/ sDim dSet dLst dSty oLst)
(if(and
      (setq sDim(entsel "\nPick sample dimension > "))
      (equal '(0 . "DIMENSION")(assoc 0(entget(car sDim))))
      (setq dSty(assoc 3(entget(car sDim))))
      ); end and
   (progn
   (setq dSet(ssget "_X" (list '(0 . "DIMENSION") dSty))
    dLst(vl-remove-if 'listp(mapcar 'cadr(ssnamex dSet)))
    ); end setq
   (foreach d dLst
(setq oLst(append oLst(list(cdr(assoc 42(entget d))))))
); end foreach
   ); end progn
   (progn "\n<!> This isn't dimension <!> ")
   ); end if
(princ(strcat "\nSum length for '"
        (cdr dSty)
        "' dimstyle: "
        (rtos(apply '+ oLst))
   ); end strcat
); end princ
(princ)
); end of c:test

Snownut 发表于 2022-7-6 10:20:09

Smirnoff,这很好用,但是我知道Dimstyle的名称,不想为此选择尺寸。我想输入dimstyle名称作为变量ie;(setq变量“TtoTSLine”),其中“TtoTSLine”是dimstyle的名称。我一直在玩弄你的代码,让它以这种方式运行,但没有成功。
 
谢谢你为她提供的一切。
 
布鲁斯

Smirnoff 发表于 2022-7-6 10:32:09

这就是你需要的?
 
(defun c:test(/ dSet dLst dSty oLst)

(setq dSty "TtoTSLine")

(if(setq dSet(ssget "_X" (list '(0 . "DIMENSION")(cons 3dSty ))))
   (progn
   (setq dLst(vl-remove-if 'listp(mapcar 'cadr(ssnamex dSet)))
    ); end setq
   (foreach d dLst
(setq oLst(append oLst(list(cdr(assoc 42(entget d))))))
); end foreach
       (princ(strcat "\nSum length for '"
        dSty
        "' dimstyle: "
        (rtos(apply '+ oLst))
   ); end strcat
); end princ
   ); end progn
   (princ "\n<!> No dimensions found <!> ")
   ); end if
(princ)
); end of c:test

Snownut 发表于 2022-7-6 10:35:48

斯米尔诺夫,效果很好,非常感谢你的努力。
 
布鲁斯

Smirnoff 发表于 2022-7-6 10:41:51

没问题。这只是对大脑神经元的一个小练习。

alanjt 发表于 2022-7-6 10:57:11

注意DimRadial和DimAngular。径向可能是可以接受的(取决于一个人的情况),但角度将返回以弧度为单位的角度。
 
这是我使用的。。。
 
(defun c:DimSum (/ ss)
;; Alan J. Thompson
(if (setq ss (ssget '((0 . "DIMENSION"))))
   ((lambda (i total / e d)
      (while (setq e (ssname ss (setq i (1+ i))))
      (or (wcmatch (cdr (assoc 100 (reverse (setq d (entget e))))) "*Angular*,*Radial*")
            (setq total (+ total (cdr (assoc 42 d))))
      )
      )
      (or (zerop total) (alert (princ (strcat "\nTotal: " (rtos total)))))
    )
   -1
   0.
   )
)
(princ)
)
页: [1]
查看完整版本: Dimstyle数据检索?