PDuMont 发表于 2022-7-5 20:12:31

 
Sorry Tharwat, I am pretty new to lisp. Not sure where to change this.

David Bethel 发表于 2022-7-5 20:18:00

I think you're heading for possible troubles with the bulge filter.
 
Even the simplest LWPOLYLINE has (2) DXF 42 values.So you are in effect selecting any LWPOLYLINE that has a 180 degree bend included.Are you trying to include doughnut type shapes only?
 
-David

Tharwat 发表于 2022-7-5 20:18:53

 
As I said in my last reply that I already changed it . just try the codes that I posted and let me know .

PDuMont 发表于 2022-7-5 20:24:46

Yes Tharwat, that did the trick.
 
Thank you so much.

Tharwat 发表于 2022-7-5 20:26:06

 
You are most welcome .

PDuMont 发表于 2022-7-5 20:29:27

 
Hi David, thanks.
 
This is not exactly the way I wanted to go, but the majority of polylines with 180 degree bends would be the correct entity I want changed.
 
I wanted to filter by area, as this entity has a unique area and would filter any other polyline with bulge, but I was struggling with that.

PDuMont 发表于 2022-7-5 20:32:57

Hello,
 
Sorry to resurrect this thread...
 
With the wonderful help from Tharwat, the lisp is working fine, but as David Bethel suggested, the bulge filter is grabbing a bit more in the drawing than I had anticipated.
 
I found and modified this routine from Lee Mac that works wonders, but I am too much of a novice to figure out how to "combine" the two.
 
Any help would be greatly appreciated.
 
 

(defun c:S2L ( / ent idx sel tar )      (setq tar 2.17691944) ;; Target area value   (if (setq sel (ssget '((0 . "LWPOLYLINE") (42 . 1.0))))       (repeat (setq idx (sslength sel))         (if (not (equal tar (vlax-curve-getarea (setq ent (ssname sel (setq idx (1- idx))))) 1e-6))               (ssdel ent sel)        (command "change" ent "" "property" "layer" "CNC_PLY-SLOT" "")         )       )   )      (princ))(vl-load-com) (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 . "")                )            )         )   (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) (

Tharwat 发表于 2022-7-5 20:37:18

Hi,
Just replace/add this modified part .
 

(if (eq (cdr (assoc 0 enlist)) "LWPOLYLINE") (if (equal 2.17691944 (vlax-curve-getarea ent) 1e-6) (command "change" ent "" "property" "layer" "CNC_PLY-SLOT" "")) (cond    ((equal (setq cr (cdr (assoc 40 enlist)))    ....................

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

Tharwat, you sir, are great.
 
You make it seem so easy...
 
Thank you very much.

Tharwat 发表于 2022-7-5 20:43:23

 
Nice, you are very welcome.
页: 1 [2]
查看完整版本: 帮助更改层Lisp