Aftertouch 发表于 2022-7-5 17:07:52

L中的对象选择问题

我成功地编写了这段代码,它允许我更改对象的注释比例(AnnotationScale)。
 
当前问题:
-LISP使用“box”选择,这使我能够手动选择对象。我需要LISP来选择此时可见的所有对象。
我已经试过了(ssget“_A”),但这也会选择具有注释比例(AnnotationScale)的不可见对象。我需要它只选择当前活动annotationscale的所有对象。
 
而且
-LISP需要选择1:1的比例,然后才能继续进行1:2的翻译。如果没有annoscale为1:1的对象,我如何让LISP继续?有点像“没有那么大比例的物体”。然后继续。。。
 
希望有人能帮忙!
 

(defun c:OBJECTSCHALENVERVANGEN ()
(command "UNDO" "begin")
(setvar 'annoallvisible 0)
(command "_SchalenMaken" "ME")
(SCHALEN1NEW)
(SCHALEN2NEW)
(command "CANNOSCALE" "NLCS_M_1:2")
(command "undo" "end")
)

(defun SCHALEN1NEW ( / cmd ent idx lst scl sel )
   (command "CANNOSCALE" "NLCS_M_1:1")
   (cond
       (   (= 1 (getvar 'cvport))
         (princ "\nThis command is only available in Modelspace.")
       )
       (
          (setq scl (getvar 'cannoscale)
         )
         (command "CANNOSCALE" "HB 1:1")
         (setq sel (ssget "_:L" '((0 . "*TEXT,*DIMENSION,INSERT,HATCH,MULTILEADER"))))

         (repeat (setq idx (sslength sel))
               (if (setq ent (ssname sel (setq idx (1- idx)))
                         lst (LM:annoscales ent)
                   )
                   (progn
                     (if (not (member scl lst))
                           (command "_.-objectscale" ent "" "_a" "NLCS_M_1:1" "")
                     )
                      (if (not (member scl lst))
                           (command "_.-objectscale" ent "" "_d" "HB 1:1" "")
                     )
                   )
               )
         )
       (command "CANNOSCALE" "NLCS_M_1:1")
       )
   )
   (princ)
)


(defun SCHALEN2NEW ( / cmd ent idx lst scl sel )
   (command "CANNOSCALE" "NLCS_M_1:2")
   (cond
       (   (= 1 (getvar 'cvport))
         (princ "\nThis command is only available in Modelspace.")
       )
       (
          (setq scl (getvar 'cannoscale)
         )
         (command "CANNOSCALE" "HB 1:2")
         (setq sel (ssget "_:L" '((0 . "*TEXT,*DIMENSION,INSERT,HATCH,MULTILEADER"))))

         (repeat (setq idx (sslength sel))
               (if (setq ent (ssname sel (setq idx (1- idx)))
                         lst (LM:annoscales ent)
                   )
                   (progn
                     (if (not (member scl lst))
                           (command "_.-objectscale" ent "" "_a" "NLCS_M_1:2" "")
                     )
                      (if (not (member scl lst))
                           (command "_.-objectscale" ent "" "_d" "HB 1:2" "")
                     )
                   )
               )
         )
       (command "CANNOSCALE" "NLCS_M_1:2")
       )
   )
   (princ)
)

;; Returns a list of all annotative scales associated with a supplied entity
(defun LM:annoscales ( ent / dic enx itm rtn )
   (if
       (and
         (setq enx (entget ent))
         (setq dic (cdr (assoc 360 (cdr (member '(102 . "{ACAD_XDICTIONARY") enx)))))
         (setq dic (cdr (assoc -1(dictsearch dic "acdbcontextdatamanager"))))
         (setq dic (cdr (assoc -1(dictsearch dic "acdb_annotationscales"))))
       )
       (while (setq itm (dictnext dic (not itm)))
         (setq rtn (cons (cdr (assoc 300 (entget (cdr (assoc 340 itm))))) rtn))
       )
   )
   (reverse rtn)
)

(princ)

Aftertouch 发表于 2022-7-5 17:37:50

解决了它。:-)

Roy_043 发表于 2022-7-5 18:07:07

如果你能分享你的解决方案,让其他人也能从中受益,那就太好了。

Aftertouch 发表于 2022-7-5 18:16:19

我用肮脏的方式解决了这个问题。但它做了必须做的事情。:-)
它将annoallvisible设置为0,将当前比例设置为“HB 1:200”,因此仅显示注释性对象。
然后在坐标1000000到1000000处生成一个大矩形。(我使用荷兰协调系统RD。)
将比例“NLCS\u M\u 1:200”添加到所有对象,并删除旧比例。
 
工作起来很有魅力。:-)
 
 

(defun SCHALEN200NEW ( )
       (setvar 'annoallvisible 0)
        (command "CANNOSCALE" "HB 1:200")
(setq sel200a (ssget "_CP" '((-1000000 -1000000) (-1000000 1000000) (1000000 1000000) (1000000 -1000000))))
(command "_.-objectscale" sel200a "" "a" "NLCS_M_1:200" "")
(setq sel200d (ssget "_CP" '((-1000000 -1000000) (-1000000 1000000) (1000000 1000000) (1000000 -1000000))))
(command "_.-objectscale" sel200d "" "d" "HB 1:200" "")
(command "CANNOSCALE" "NLCS_M_1:200")
(princ)
)
页: [1]
查看完整版本: L中的对象选择问题