乐筑天下

搜索
欢迎各位开发者和用户入驻本平台 尊重版权,从我做起,拒绝盗版,拒绝倒卖 签到、发布资源、邀请好友注册,可以获得银币 请注意保管好自己的密码,避免账户资金被盗
楼主: PDuMont

[编程交流] 帮助更改层Lisp

[复制链接]

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 20:12:31 | 显示全部楼层
 
Sorry Tharwat, I am pretty new to lisp. Not sure where to change this.
回复

使用道具 举报

26

主题

1495

帖子

20

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
118
发表于 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
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 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 .
回复

使用道具 举报

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 20:24:46 | 显示全部楼层
Yes Tharwat, that did the trick.
 
Thank you so much.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 20:26:06 | 显示全部楼层
 
You are most welcome .
回复

使用道具 举报

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 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.
回复

使用道具 举报

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 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.
 
 
  1. (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)

 
 
 

[code](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" PILOT  DRILL            (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) (
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 20:37:18 | 显示全部楼层
Hi,
Just replace/add this modified part .
 
  1. (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)))    ....................
回复

使用道具 举报

16

主题

99

帖子

83

银币

初露锋芒

Rank: 3Rank: 3Rank: 3

铜币
80
发表于 2022-7-5 20:38:49 | 显示全部楼层
Tharwat, you sir, are great.
 
You make it seem so easy...
 
Thank you very much.
回复

使用道具 举报

63

主题

6297

帖子

6283

银币

后起之秀

Rank: 20Rank: 20Rank: 20Rank: 20

铜币
358
发表于 2022-7-5 20:43:23 | 显示全部楼层
 
Nice, you are very welcome.
回复

使用道具 举报

发表回复

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

QQ|关于我们|小黑屋|乐筑天下 繁体中文

GMT+8, 2025-3-12 01:18 , Processed in 0.844522 second(s), 70 queries .

© 2020-2025 乐筑天下

联系客服 关注微信 帮助中心 下载APP 返回顶部 返回列表