PDuMont 发表于 2022-7-5 19:40:44

帮助更改层Lisp

你好
 
我有一个lisp例程,它将特定直径的圆放在不同的层上。
我想在这个例程中包括一条带有凸起的LW多段线。
 
我可以将lwpolyline放入选择集中,但我可以在例程进入圆的条件语句之前更改其图层吗?
 
或者如何将lwployline包含到条件语句中。
 
这条多段线有一个非常特定的面积,这将是更准确的方法,但这是否更有意义按面积过滤?
 
我可能没说清楚。。。
 
...snip

(setq cecho (getvar "cmdecho"))
(prompt "\nSelect Entities to be Changed : ")
(command "setvar" "cmdecho" "0")
(setq ss-circle
    (ssget
      '(
   (-4 . "<OR")
   (-4 . "<AND") (0 . "CIRCLE")                (-4 . "AND>")
   (-4 . "<AND") (0 . "LWPOLYLINE") (42 . 1.0) (-4 . "AND>")
   (-4 ."OR>")                
)
    )
)



                  
(setq index 0)                        ;(repeat n
(setq i -1)
(while (setq ent (ssname ss-circle (setq i (1+ i))))
   (setq lst (cons ent lst))
)
(reverse lst)
(foreach ent lst
   (setq enlist (entget ent))
   (setq cr (cdr (assoc 40 enlist)))
   
   (cond
   ((equal cr 0.0625 0.00001)        ;1/8" PILOTDRILL
      (command        "change" ent ""        "property" "layer" "cnc_drill-pilot"
        ""
       )
   )   snip...

Tharwat 发表于 2022-7-5 19:44:10

既然要将LWDOLYLINE更改为同一图层,为什么要在圆之前更改其图层?

PDuMont 发表于 2022-7-5 19:49:33

谢谢
 
对不起,我没说清楚。
 
该例程指定直径范围为的圆。125至5.0,以分离特定层。
我想把这条特殊的多段线连接到它自己的特定层。
 
希望这现在有意义。

Tharwat 发表于 2022-7-5 19:50:21

目前只需进行简单修改,我们就可以根据您的要求扩展这些代码(如果适用)。
 

(if (setq ss-circle (ssget '((-4 . "<OR") (0 . "CIRCLE") (-4 . "<AND") (0 . "LWPOLYLINE") (42 . 1.0) (-4 . "AND>") (-4 . "OR>"))))
(progn
   (setq i -1)
   (while (setq ent (ssname ss-circle (setq i (1+ i))))
   (setq enlist (entget ent))
   (if (and (eq (cdr (assoc 0 enlist)) "CIRCLE")(equal cr 0.0625 0.00001))
       (command "change" ent "" "property" "layer" "cnc_drill-pilot" "")
       )
   (   ;; Add your stuff here for the LWpolyline
      )
   )
   )
)

PDuMont 发表于 2022-7-5 19:56:10

谢谢你的回复。
 
我会发布整个代码,也许它会更有意义。
 
创建的最后一个层“CNC\U PLY-SLOT”是我试图获得指定的lwpolyline的层。
 
 
(defun C:C2L (/        a1 a2 n        index b1 b2 b3 d1 d2 cecho ss-circle ss-pline ent lst
      enlist cr        i cl
   )
                                ;(command "undo" "be")
(setq *old_error* *error*)
(setq *error* trap)
                                ;(command "undo" "be")
(setq cl (getvar "clayer"))


                                ; -----------------------------------------------------------------------------
                                ; |                               CREATE LAYERS                               |
                                ; |                                                                           |
                                ; -----------------------------------------------------------------------------


(if                                        ; if layer CNC_DRILL-PILOT does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-PILOT")
   )
    (command "-layer" "make" "CNC_DRILL-PILOT" "color" "9" "" ""
   )                                ;create layer CNC_DRILL-PILOT

    (command "-layer" "thaw" "CNC_DRILL-PILOT" "on"
      "CNC_DRILL-PILOT" "set" "CNC_DRILL-PILOT" ""
   )
)



(if                                        ; if layer CNC_DRILL-.1875 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.1875-THRU")
   )
    (command "-layer" "make" "CNC_DRILL-.1875-THRU"        "color"        "CYAN"
      "" ""
   )
                                ;create layer CNC_DRILL-.1875-THRU
    (command "-layer" "thaw" "CNC_DRILL-.1875-THRU"        "on"
      "CNC_DRILL-.1875-THRU"        "set" "CNC_DRILL-.1875-THRU"
      ""
   )
)



(if                                        ; if layer CNC_DRILL-.250 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.250-PEG")
   )
    (command "-layer" "make" "CNC_DRILL-.250-PEG" "color" "RED" ""
      ""
   )
                                ;create layer CNC_DRILL-.250-PEG
    (command "-layer" "thaw" "CNC_DRILL-.250-PEG" "on"
      "CNC_DRILL-.250-PEG" "set" "CNC_DRILL-.250-PEG" ""
   )
)



(if                                        ; if layer CNC_DRILL-.3125 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.3125-THRU")
   )
    (command "-layer" "make" "CNC_DRILL-.3125-THRU"        "color"        "GREEN"
      "" ""
   )
                                ;create layer CNC_DRILL-.3125-THRU
    (command "-layer" "thaw" "CNC_DRILL-.3125-THRU"        "on"
      "CNC_DRILL-.3125-THRU"        "set" "CNC_DRILL-.3125-THRU"
      ""
   )
)



(if                                        ; if layer CNC_DRILL-.375 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.375-THRU")
   )
    (command "-layer" "make" "CNC_DRILL-.375-THRU" "color" "MAGENTA"
      "" ""
   )
                                ;create layer CNC_DRILL-.375-THRU
    (command "-layer" "thaw" "CNC_DRILL-.375-THRU" "on"
      "CNC_DRILL-.375-THRU" "set" "CNC_DRILL-.375-THRU" ""
   )
)




(if                                        ; if layer CNC_DRILL-.500 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.500-THRU")
   )
    (command "-layer" "make" "CNC_DRILL-.500-THRU" "color" "9" "" ""
   )
                                ;create layer CNC_DRILL-.375-THRU
    (command "-layer" "thaw" "CNC_DRILL-.500-THRU" "on"
      "CNC_DRILL-.375-THRU" "set" "CNC_DRILL-.500-THRU" ""
   )
)





(if                                        ; if layer CNC_PLY-DOWEL does not exist
   (not
   (tblsearch "LAYER" "CNC_PLY-DOWEL")
   )
    (command "-layer" "make" "CNC_PLY-DOWEL" "color" "211" "" ""
   )
                                ;create layer CNC_DRILL-DOWEL
    (command "-layer" "thaw" "CNC_PLY-DOWEL" "on" "CNC_PLY-DOWEL"
      "set" "CNC_PLY-DOWEL" ""
   )                               
)




(if                                        ; if layer CNC_PLY-T-NUT-RECESS does not exist
   (not
   (tblsearch "LAYER" "CNC_PLY-T-NUT-RECESS")
   )
    (command "-layer" "make" "CNC_PLY-T-NUT-RECESS"        "color"        "YELLOW" "" ""
                   )
                                ;create layer CNC_PLY-T-NUT-RECESS
    (command "-layer" "thaw" "CNC_PLY-T-NUT-RECESS"        "on"
      "CNC_PLY-T-NUT-RECESS"        "set" "CNC_PLY-T-NUT-RECESS"
      ""
   )                        
)                                       




(if                                        ; if layer CNC_PLY-GROMMET does not exist
   (not
   (tblsearch "LAYER" "CNC_PLY-GROMMET")
   )
    (command "-layer" "make" "CNC_PLY-GROMMET"        "color"        "40" "" ""
                   )
                                ;create layer CNC_PLY-GROMMET
    (command "-layer" "thaw" "CNC_PLY-GROMMET"        "on"
      "CNC_PLY-GROMMET"        "set" "CNC_PLY-GROMMET"
      ""
   )
)



(if                                        ; if layer CNC_PLY-SLOT does not exist
   (not
   (tblsearch "LAYER" "CNC_PLY-SLOT")
   )
    (command "-layer" "make" "CNC_PLY-SLOT"        "color"        "RED" "" ""
                   )
                                ;create layer CNC_PLY-SLOT
    (command "-layer" "thaw" "CNC_PLY-SLOT"        "on"
      "CNC_PLY-SLOT"        "set" "CNC_PLY-SLOT"
      ""
   )
)



                                ; -----------------------------------------------------------------------------
                                ; |                               MAIN PROGRAM                              |
                                ; |                                                                           |
                                ; -----------------------------------------------------------------------------

(setq cecho (getvar "cmdecho"))
(prompt "\nSelect Entities to be Changed : ")
(command "setvar" "cmdecho" "0")
(setq ss-circle
    (ssget
      '(
   (-4 . "<OR")
   (-4 . "<AND") (0 . "CIRCLE")                (-4 . "AND>")
   (-4 . "<AND") (0 . "LWPOLYLINE") (42 . 1.0) (-4 . "AND>")
   (-4 ."OR>")                
)
    )
)



                  
(setq index 0)                        ;(repeat n
(setq i -1)
(while (setq ent (ssname ss-circle (setq i (1+ i))))
   (setq lst (cons ent lst))
)
(reverse lst)
(foreach ent lst
   (setq enlist (entget ent))
   (setq cr (cdr (assoc 40 enlist)))
   
   (cond
   ((equal cr 0.0625 0.00001)        ;1/8" PILOTDRILL
      (command        "change" ent ""        "property" "layer" "cnc_drill-pilot"
        ""
       )
   )

   ((equal cr 0.09375 0.00001)        ;3/16" DRILL
      (command        "change" ent ""        "property" "layer"
        "cnc_drill-.1875-thru" ""
       )
   )

   ((equal cr 0.125 0.00001)                ;1/4" DRILL BLIND
      (command        "change" ent ""        "property" "layer"
        "CNc_DRILL-.250-PEG"        ""
       )
   )

   ((equal cr 0.15625 0.00001)
                                ;((= cr 0.15625) ;5/16" DRILL
      (command        "change" ent ""        "property" "layer"
        "cnc_drill-.3125-thru" ""
       )
   )

   ((equal cr 0.1875 0.00001)        ;3/8" DRILL
      (command        "change" ent ""        "property" "layer"
        "cnc_drill-.375-thru" ""
       )
   )

   ((equal cr 0.25 0.00001)                ;1/2" DRILL
      (command        "change" ent ""        "property" "layer"
        "cnc_DRILL-.500-THRU" ""
       )
   )

   ((equal cr 0.3750 0.00001)        ;3/4" DOWEL PINS
      (command        "change" ent ""        "property" "layer" "CNC_PLY-DOWEL" ""
       )
   )

   ((equal cr 0.453125 0.000001)        ;29/32" HOLE LOCK IN DOOR
      (command        "change" ent ""        "property" "layer" "CNC_PLY-DOWEL" ""
       )
   )

   ((equal cr 0.4375 0.00001)        ;7/8" RECESS FOR T-NUT
      (command        "change" ent ""        "property" "layer"
        "CNC_PLY-T-NUT-RECESS" ""
       )
   )

   ((equal cr 0.500 0.00001)                ;1.0" RECESS FOR T-NUT
      (command        "change" ent ""        "property" "layer"
        "CNC_PLY-T-NUT-RECESS" "color" "YELLOW" ""
       )
   )

   ((equal cr 0.52343750 0.00001)        ; 1 3/64" HOLE PUSH LOCK IN DOOR
      (command        "change" ent ""        "property" "layer" "CNC_PLY-DOWEL" ""
       )
   )

   ((and (>= cr 0.5625) (<= cr 2.5))        ;GROMMETS
      (command        "change" ent ""        "property" "layer"
        "CNC_PLY-GROMMET" ""
       )      
   )
   )                                        ;foreach
)


(command "setvar" "cmdecho" cecho)
(setvar "clayer" cl)
                                ;(command "undo" "end")
(setq *error* *old_error*)
(princ)
)
(princ "\nType C2L to put circles on standard CNC layers.")
(princ)
 
 
 

(defun C:C2L(/ *error* cm a1 a2 n index b1 b2 b3 d1 d2 cecho ss-circle
            ss-pline ent lst enlist cr i cl)
(defun *error*(x)
   (if cl
   (setvar "clayer" cl))
   (if cm
   (setvar "cmdecho" cm))
   (princ x)
   )
(setq cl (getvar "clayer")
       cm (getvar "cmdecho")
       )
(setvar "cmdecho" 0)
;; -----------------------------------------------------------------------------
;; |                               CREATE LAYERS                               |
;; |                                                                           |
;; -----------------------------------------------------------------------------

(if                                 ; if layer CNC_DRILL-PILOT does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-PILOT")
   )
    (command "-layer" "make" "CNC_DRILL-PILOT" "color" "9" "" "")
                                       ;create layer CNC_DRILL-PILOT

    (command "-layer" "thaw" "CNC_DRILL-PILOT" "on" "CNC_DRILL-PILOT"
             "set" "CNC_DRILL-PILOT" "")
    )
(if                                 ; if layer CNC_DRILL-.1875 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.1875-THRU")
   )
    (command "-layer" "make" "CNC_DRILL-.1875-THRU" "color" "CYAN" ""
             "")
                                       ;create layer CNC_DRILL-.1875-THRU
    (command "-layer" "thaw" "CNC_DRILL-.1875-THRU" "on"
             "CNC_DRILL-.1875-THRU" "set" "CNC_DRILL-.1875-THRU" "")
    )
(if                                 ; if layer CNC_DRILL-.250 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.250-PEG")
   )
    (command "-layer" "make" "CNC_DRILL-.250-PEG" "color" "RED" "" "")
                                       ;create layer CNC_DRILL-.250-PEG
    (command "-layer" "thaw" "CNC_DRILL-.250-PEG" "on"
             "CNC_DRILL-.250-PEG" "set" "CNC_DRILL-.250-PEG" "")
    )
(if                                 ; if layer CNC_DRILL-.3125 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.3125-THRU")
   )
    (command "-layer" "make" "CNC_DRILL-.3125-THRU" "color" "GREEN" ""
             "")
                                       ;create layer CNC_DRILL-.3125-THRU
    (command "-layer" "thaw" "CNC_DRILL-.3125-THRU" "on"
             "CNC_DRILL-.3125-THRU" "set" "CNC_DRILL-.3125-THRU" "")
    )
(if                                 ; if layer CNC_DRILL-.375 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.375-THRU")
   )
    (command "-layer" "make" "CNC_DRILL-.375-THRU" "color" "MAGENTA" ""
             "")
                                       ;create layer CNC_DRILL-.375-THRU
    (command "-layer" "thaw" "CNC_DRILL-.375-THRU" "on"
             "CNC_DRILL-.375-THRU" "set" "CNC_DRILL-.375-THRU" "")
    )
(if                                 ; if layer CNC_DRILL-.500 does not exist
   (not
   (tblsearch "LAYER" "CNC_DRILL-.500-THRU")
   )
    (command "-layer" "make" "CNC_DRILL-.500-THRU" "color" "9" "" "")
                                       ;create layer CNC_DRILL-.375-THRU
    (command "-layer" "thaw" "CNC_DRILL-.500-THRU" "on"
             "CNC_DRILL-.375-THRU" "set" "CNC_DRILL-.500-THRU" "")
    )

(if                                 ; if layer CNC_PLY-DOWEL does not exist
   (not
   (tblsearch "LAYER" "CNC_PLY-DOWEL")
   )
    (command "-layer" "make" "CNC_PLY-DOWEL" "color" "211" "" "")
                                       ;create layer CNC_DRILL-DOWEL
    (command "-layer" "thaw" "CNC_PLY-DOWEL" "on" "CNC_PLY-DOWEL" "set"
             "CNC_PLY-DOWEL" "")
    )

(if                                 ; if layer CNC_PLY-T-NUT-RECESS does not exist
   (not
   (tblsearch "LAYER" "CNC_PLY-T-NUT-RECESS")
   )
    (command "-layer" "make" "CNC_PLY-T-NUT-RECESS" "color" "YELLOW" ""
             "")
                                       ;create layer CNC_PLY-T-NUT-RECESS
    (command "-layer" "thaw" "CNC_PLY-T-NUT-RECESS" "on"
             "CNC_PLY-T-NUT-RECESS" "set" "CNC_PLY-T-NUT-RECESS" "")
    )

(if                                 ; if layer CNC_PLY-GROMMET does not exist
   (not
   (tblsearch "LAYER" "CNC_PLY-GROMMET")
   )
    (command "-layer" "make" "CNC_PLY-GROMMET" "color" "40" "" "")
                                       ;create layer CNC_PLY-GROMMET
    (command "-layer" "thaw" "CNC_PLY-GROMMET" "on" "CNC_PLY-GROMMET"
             "set" "CNC_PLY-GROMMET" "")
    )

(if                                 ; if layer CNC_PLY-SLOT does not exist
   (not
   (tblsearch "LAYER" "CNC_PLY-SLOT")
   )
    (command "-layer" "make" "CNC_PLY-SLOT" "color" "RED" "" "")
                                       ;create layer CNC_PLY-SLOT
    (command "-layer" "thaw" "CNC_PLY-SLOT" "on" "CNC_PLY-SLOT" "set"
             "CNC_PLY-SLOT" "")
    )
;; -----------------------------------------------------------------------------
;; |                               MAIN PROGRAM                              |
;; |                                                                           |
;; -----------------------------------------------------------------------------
(prompt "\nSelect Entities to be Changed : ")
(if (setq ss-circle
            (ssget
            '(
                (-4 . "<OR")
                (0 . "CIRCLE")
                (-4 . "<AND")
                (0 . "LWPOLYLINE")
                (42 . 1.0)
                (-4 . "AND>")
                (-4 . "OR>")
                )
            )
         )
   (progn
   (setq i -1)
   (while (setq ent (ssname ss-circle (setq i (1+ i))))
       (setq enlist (entget ent))
       (if (eq (cdr (assoc 0 enlist)) "LWPOLYLINE")
         (command "change" ent "" "property" "layer" "CNC_PLY-SLOT" "")
         (cond
         ((equal (setq cr (cdr (assoc 40 enlist)))
                   0.0625
                   0.00001)            ;1/8" PILOTDRILL
            (command "change" ent "" "property" "layer"
                     "cnc_drill-pilot" "")
            )

         ((equal cr 0.09375 0.00001) ;3/16" DRILL
            (command "change" ent "" "property" "layer"
                     "cnc_drill-.1875-thru" "")
            )

         ((equal cr 0.125 0.00001)   ;1/4" DRILL BLIND
            (command "change" ent "" "property" "layer"
                     "CNc_DRILL-.250-PEG" "")
            )

         ((equal cr 0.15625 0.00001)
                                       ;((= cr 0.15625) ;5/16" DRILL
            (command "change" ent "" "property" "layer"
                     "cnc_drill-.3125-thru" "")
            )

         ((equal cr 0.1875 0.00001);3/8" DRILL
            (command "change" ent "" "property" "layer"
                     "cnc_drill-.375-thru" "")
            )

         ((equal cr 0.25 0.00001)    ;1/2" DRILL
            (command "change" ent "" "property" "layer"
                     "cnc_DRILL-.500-THRU" "")
            )

         ((equal cr 0.3750 0.00001);3/4" DOWEL PINS
            (command "change" ent "" "property" "layer" "CNC_PLY-DOWEL"
                     "")
            )

         ((equal cr 0.453125 0.000001) ;29/32" HOLE LOCK IN DOOR
            (command "change" ent "" "property" "layer" "CNC_PLY-DOWEL"
                     "")
            )

         ((equal cr 0.4375 0.00001);7/8" RECESS FOR T-NUT
            (command "change" ent "" "property" "layer"
                     "CNC_PLY-T-NUT-RECESS" "")
            )

         ((equal cr 0.500 0.00001)   ;1.0" RECESS FOR T-NUT
            (command "change" ent "" "property" "layer"
                     "CNC_PLY-T-NUT-RECESS" "color" "YELLOW" "")
            )

         ((equal cr 0.52343750 0.00001)
                                       ; 1 3/64" HOLE PUSH LOCK IN DOOR
            (command "change" ent "" "property" "layer" "CNC_PLY-DOWEL"
                     "")
            )

         ((and (>= cr 0.5625) (<= cr 2.5)) ;GROMMETS
            (command "change" ent "" "property" "layer"
                     "CNC_PLY-GROMMET" "")
            )
         )                           ;foreach
         )
       (setvar "cmdecho" cm)
       (setvar "clayer" cl)
       (princ)
       )
   )
   )
(princ)
)
(princ "\nType C2L to put circles on standard CNC layers.")
(princ)

Tharwat 发表于 2022-7-5 19:59:46

塔瓦,先生,你太棒了。
 
你让它看起来很简单。。。
 
非常感谢你。

PDuMont 发表于 2022-7-5 20:00:43

 
很好,不客气。

Tharwat 发表于 2022-7-5 20:03:08

PDuMont 发表于 2022-7-5 20:07:38

Sorry Tharwat, there is a bit of error handling at the beginning I didn't include.
 
 

; -----------------------------------------------------------------------------                                ; |                               ERROR HANDLING                              |                                ; |                                                                           |                                ; -----------------------------------------------------------------------------(defun trap (errmsg) (if   (and errmsg (null   (member errmsg '("Function cancelled" "quit / exit abort")) )   )    (princ (strcat "\nError: " errmsg)) ) (setq errmsg " ") (princ)                                ;(command "undo" "end") (setvar "clayer" cl) (setvar "cmdecho" cecho) (setq *error* *old_error*) (prompt "\nResetting system settings..."))(defun C:C2L (/        a1 a2 n        index b1 b2 b3 d1 d2 cecho ss-circle ss-pline ent lst      enlist cr        i cl   )                                ;(command "undo" "be") (setq *old_error* *error*) (setq *error* trap)                                ;(command "undo" "be") (setq cl (getvar "clayer"))                                ; -----------------------------------------------------------------------------                                ; |                               CREATE LAYERS                               |                                ; |                                                                           |                                ; ----------------------------------------------------------------------------- (if                                        ; if layer CNC_DRILL-PILOT does not exist   (not   (tblsearch "LAYER" "CNC_DRILL-PILOT")   )    (command "-layer" "make" "CNC_DRILL-PILOT" "color" "9" "" ""   )                                ;create layer CNC_DRILL-PILOT    (command "-layer" "thaw" "CNC_DRILL-PILOT" "on"      "CNC_DRILL-PILOT" "set" "CNC_DRILL-PILOT" ""   ) ) (if                                        ; if layer CNC_DRILL-.1875 does not exist   (not   (tblsearch "LAYER" "CNC_DRILL-.1875-THRU")   )    (command "-layer" "make" "CNC_DRILL-.1875-THRU"        "color"        "CYAN"      "" ""   )                                ;create layer CNC_DRILL-.1875-THRU    (command "-layer" "thaw" "CNC_DRILL-.1875-THRU"        "on"      "CNC_DRILL-.1875-THRU"        "set" "CNC_DRILL-.1875-THRU"      ""   ) ) (if                                        ; if layer CNC_DRILL-.250 does not exist   (not   (tblsearch "LAYER" "CNC_DRILL-.250-PEG")   )    (command "-layer" "make" "CNC_DRILL-.250-PEG" "color" "RED" ""      ""   )                                ;create layer CNC_DRILL-.250-PEG    (command "-layer" "thaw" "CNC_DRILL-.250-PEG" "on"      "CNC_DRILL-.250-PEG" "set" "CNC_DRILL-.250-PEG" ""   ) ) (if                                        ; if layer CNC_DRILL-.3125 does not exist   (not   (tblsearch "LAYER" "CNC_DRILL-.3125-THRU")   )    (command "-layer" "make" "CNC_DRILL-.3125-THRU"        "color"        "GREEN"      "" ""   )                                ;create layer CNC_DRILL-.3125-THRU    (command "-layer" "thaw" "CNC_DRILL-.3125-THRU"        "on"      "CNC_DRILL-.3125-THRU"        "set" "CNC_DRILL-.3125-THRU"      ""   ) ) (if                                        ; if layer CNC_DRILL-.375 does not exist   (not   (tblsearch "LAYER" "CNC_DRILL-.375-THRU")   )    (command "-layer" "make" "CNC_DRILL-.375-THRU" "color" "MAGENTA"      "" ""   )                                ;create layer CNC_DRILL-.375-THRU    (command "-layer" "thaw" "CNC_DRILL-.375-THRU" "on"      "CNC_DRILL-.375-THRU" "set" "CNC_DRILL-.375-THRU" ""   ) ) (if                                        ; if layer CNC_DRILL-.500 does not exist   (not   (tblsearch "LAYER" "CNC_DRILL-.500-THRU")   )    (command "-layer" "make" "CNC_DRILL-.500-THRU" "color" "9" "" ""   )                                ;create layer CNC_DRILL-.375-THRU    (command "-layer" "thaw" "CNC_DRILL-.500-THRU" "on"      "CNC_DRILL-.375-THRU" "set" "CNC_DRILL-.500-THRU" ""   ) ) (if                                        ; if layer CNC_PLY-DOWEL does not exist   (not   (tblsearch "LAYER" "CNC_PLY-DOWEL")   )    (command "-layer" "make" "CNC_PLY-DOWEL" "color" "211" "" ""   )                                ;create layer CNC_DRILL-DOWEL    (command "-layer" "thaw" "CNC_PLY-DOWEL" "on" "CNC_PLY-DOWEL"      "set" "CNC_PLY-DOWEL" ""   )                               ) (if                                        ; if layer CNC_PLY-T-NUT-RECESS does not exist   (not   (tblsearch "LAYER" "CNC_PLY-T-NUT-RECESS")   )    (command "-layer" "make" "CNC_PLY-T-NUT-RECESS"        "color"        "YELLOW" "" ""                   )                                ;create layer CNC_PLY-T-NUT-RECESS    (command "-layer" "thaw" "CNC_PLY-T-NUT-RECESS"        "on"      "CNC_PLY-T-NUT-RECESS"        "set" "CNC_PLY-T-NUT-RECESS"      ""   )                         )                                       (if                                        ; if layer CNC_PLY-GROMMET does not exist   (not   (tblsearch "LAYER" "CNC_PLY-GROMMET")   )    (command "-layer" "make" "CNC_PLY-GROMMET"        "color"        "40" "" ""                   )                                ;create layer CNC_PLY-GROMMET    (command "-layer" "thaw" "CNC_PLY-GROMMET"        "on"      "CNC_PLY-GROMMET"        "set" "CNC_PLY-GROMMET"      ""   ) )(if                                        ; if layer CNC_PLY-SLOT does not exist   (not   (tblsearch "LAYER" "CNC_PLY-SLOT")   )    (command "-layer" "make" "CNC_PLY-SLOT"        "color"        "RED" "" ""                   )                                ;create layer CNC_PLY-SLOT    (command "-layer" "thaw" "CNC_PLY-SLOT"        "on"      "CNC_PLY-SLOT"        "set" "CNC_PLY-SLOT"      ""   ) )                                 ; -----------------------------------------------------------------------------                                ; |                               MAIN PROGRAM                              |                                ; |                                                                           |                                ; ----------------------------------------------------------------------------- (setq cecho (getvar "cmdecho")) (prompt "\nSelect Entities to be Changed : ") (command "setvar" "cmdecho" "0") (setq ss-circle   (ssget      '(   (-4 . "")                )   ))                    (setq index 0)                        ;(repeat n (setq i -1) (while (setq ent (ssname ss-circle (setq i (1+ i))))   (setq lst (cons ent lst)) ) (reverse lst) (foreach ent lst   (setq enlist (entget ent))   (setq cr (cdr (assoc 40 enlist)))   (setq bulge (cdr (assoc 42 enlist)))   (cond   ((equal cr 0.0625 0.00001)        ;1/8" PILOTDRILL      (command        "change" ent ""        "property" "layer" "cnc_drill-pilot"        ""       )   )   ((equal cr 0.09375 0.00001)        ;3/16" DRILL      (command        "change" ent ""        "property" "layer"        "cnc_drill-.1875-thru" ""       )   )   ((equal cr 0.125 0.00001)                ;1/4" DRILL BLIND      (command        "change" ent ""        "property" "layer"        "CNc_DRILL-.250-PEG"        ""       )   )   ((equal cr 0.15625 0.00001)                                ;((= cr 0.15625) ;5/16" DRILL      (command        "change" ent ""        "property" "layer"        "cnc_drill-.3125-thru" ""       )   )   ((equal cr 0.1875 0.00001)        ;3/8" DRILL      (command        "change" ent ""        "property" "layer"        "cnc_drill-.375-thru" ""       )   )   ((equal cr 0.25 0.00001)                ;1/2" DRILL      (command        "change" ent ""        "property" "layer"        "cnc_DRILL-.500-THRU" ""       )   )   ((equal cr 0.3750 0.00001)        ;3/4" DOWEL PINS      (command        "change" ent ""        "property" "layer" "CNC_PLY-DOWEL" ""       )   )   ((equal cr 0.453125 0.000001)        ;29/32" HOLE LOCK IN DOOR      (command        "change" ent ""        "property" "layer" "CNC_PLY-DOWEL" ""       )   )   ((equal cr 0.4375 0.00001)        ;7/8" RECESS FOR T-NUT      (command        "change" ent ""        "property" "layer"        "CNC_PLY-T-NUT-RECESS" ""       )   )   ((equal cr 0.500 0.00001)                ;1.0" RECESS FOR T-NUT      (command        "change" ent ""        "property" "layer"        "CNC_PLY-T-NUT-RECESS" "color" "YELLOW" ""       )   )   ((equal cr 0.52343750 0.00001)        ; 1 3/64" HOLE PUSH LOCK IN DOOR      (command        "change" ent ""        "property" "layer" "CNC_PLY-DOWEL" ""       )   )   ((and (>= cr 0.5625) (

Tharwat 发表于 2022-7-5 20:11:31

 
Forget it , I just added the simple required one .
 
Did not you try it yet ? I also modified the cmdecho system variable to the correct value.
页: [1] 2
查看完整版本: 帮助更改层Lisp