乐筑天下

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

[编程交流] LISP Request Offset&Extrude&Su

[复制链接]

15

主题

105

帖子

122

银币

初来乍到

Rank: 1

铜币
49
发表于 2022-7-5 17:33:21 | 显示全部楼层 |阅读模式
Hello,
could You help me with LISP that will do stuff like this:
1) I have a some polylines on drawing. All are closed. I start the lisp and could select one.
2) Selected (1st) polyline should be _extrude 12 units to create 1st 3DSolid
3) then this selected 1st polyline should be _offset 0.8 units to create 2nd poly
4) 2nd poly should be extruded 12 units to create 2nd 3DSolid
5) 2nd poly should be offset 0.4 units to create 3rd poly. (or alternatively it could be that 1st should be offset 1.2 units)
6) 3rd poly should be extrude 5 units to create 3rd 3DSolid
7) 3rd poly should be offset 4.8 units (or arternatively 1st should be offset 6 units) to create 4th poly
8 ) 4th poly should be extrude 2 units.
9) last thing substract selects 2nd 3rd and 4rd 3Dsolids, and cut off 1st 3DSolid
 
All offset must be outside. All extrude should be up (Z axis possitive)
 
I will be gratefull if the lisp run command with "_" (_extrude, _offset, _substract) becouse I use not english version of autocad. But i could change it myself.
 
Cool thing will be if I can select not only one poly but few polylines and they all do as i written above. But it could be hard.
 
I think that the worst thing in this is to automaticaly select created 3DSolids so I think that LISP may only start substract command and I will select 3Dsolids manually.
 
If it is possible to select few polylines and do Offset&Extrude, and after that substract must be done manually it will be awesome if substract command is started few times (for example 3 polylines select and the lisp starts substract three times)
 
I've attached the file that shows the start&result of my work. I have to do all alphabet letters like this "&"
 
Now I' doing it with two lisp (which I moddified from lisps founded in the internet)
 
  1. (defun c:pof1 (/ plines ; selection set of polylines      ext ; extrnal point      poly ; a polyline from plines      plist ; the list of poly      del ; polyline to delete      int ; internal point      i) (command "undo" "begin") (princ "select polylines") (setq plines (ssget)i      0ext    (getvar "limmax") ) (repeat (sslength plines)   (setq poly (ssname plines i))   (setq plist (entget poly))   (command "_offset" 0.8 poly ext "")   (command "_offset" 1.2 poly ext "")   (command "_offset" 6 poly ext "") ))
  1. (defun c:pof2 (/ plines ; selection set of polylines      ext ; extrnal point      poly ; a polyline from plines      plist ; the list of poly      del ; polyline to delete      int ; internal point      i) (command "undo" "begin") (princ "select polylines") (setq plines (ssget)i      0ext    (getvar "limmax") ) (repeat (sslength plines)   (setq poly (ssname plines i))   (setq plist (entget poly))   (command "_extrude" poly "" 12 "")/ plines ; selection set of polylines      ext ; extrnal point      poly ; a polyline from plines      plist ; the list of poly      del ; polyline to delete      int ; internal point      i) (command "undo" "begin") (princ "select polylines") (setq plines (ssget)i      0ext    (getvar "limmax") ) (repeat (sslength plines)   (setq poly (ssname plines i))   (setq plist (entget poly))   (command "_extrude" poly "" 12 "")/ plines ; selection set of polylines      ext ; extrnal point      poly ; a polyline from plines      plist ; the list of poly      del ; polyline to delete      int ; internal point      i) (command "undo" "begin") (princ "select polylines") (setq plines (ssget)i      0ext    (getvar "limmax") ) (repeat (sslength plines)   (setq poly (ssname plines i))   (setq plist (entget poly))   (command "_extrude" poly "" 5 "")/ plines ; selection set of polylines      ext ; extrnal point      poly ; a polyline from plines      plist ; the list of poly      del ; polyline to delete      int ; internal point      i) (command "undo" "begin") (princ "select polylines") (setq plines (ssget)i      0ext    (getvar "limmax") ) (repeat (sslength plines)   (setq poly (ssname plines i))   (setq plist (entget poly))   (command "_extrude" poly "" 2 "")   (command "_subtract" ) ))
lisp.dwg
回复

使用道具 举报

77

主题

298

帖子

232

银币

后起之秀

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

铜币
394
发表于 2022-7-5 17:51:15 | 显示全部楼层
Without looking too deeply into the code you already have, I would recommend you explore SSGET "L" (last) to store each element (polyline & 3D solid) in a selection set, so you can recall them when coming to subtract from each other.
 
I'd be happy to take another look when I get to a computer, but chances are you'll be able to get some even better help from someone else on the forum before I can get back to it.
回复

使用道具 举报

15

主题

105

帖子

122

银币

初来乍到

Rank: 1

铜币
49
发表于 2022-7-5 18:16:57 | 显示全部楼层
@lamensterms that was everything that I need
I've modyfied code form lisp1 (pof1) to:
  1. (defun c:pof3 (/ plines ; selection set of polylines      ext ; extrnal point      poly1 ; a polyline from plines      poly2 ; a polyline from plines      poly3 ; a polyline from plines      poly4 ; a polyline from plines      extr1 ; a extrude from plines      extr2 ; a extrude from plines      extr3 ; a extrude from plines      extr4 ; a extrude from plines      plist ; the list of poly      del ; polyline to delete      int ; internal point      i) (command "undo" "begin") (princ "select polylines") (setq plines (ssget)i      0ext    (getvar "limmax") ) (repeat (sslength plines)   (setq poly1 (ssname plines i))   (setq plist (entget poly1))   (command "_offset" 0.8 poly1 ext "") (setq poly2 (ssget "_L"))   (command "_extrude" poly1 "" 12 "") (setq extr1 (ssget "_L"))   (command "_offset" 0.4 poly2 ext "") (setq poly3 (ssget "_L"))   (command "_extrude" poly2 "" 12 "") (setq extr2 (ssget "_L"))   (command "_offset" 4.8 poly3 ext "") (setq poly4 (ssget "_L"))   (command "_extrude" poly3 "" 5 "") (setq extr3 (ssget "_L"))   (command "_extrude" poly4 "" 2 "") (setq extr4 (ssget "_L"))   (command "_subtract" extr2 extr3 extr4 "" extr1 "") ))
everything works great  Maybe code is not the simplest but its works
回复

使用道具 举报

77

主题

298

帖子

232

银币

后起之秀

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

铜币
394
发表于 2022-7-5 18:22:18 | 显示全部楼层
Well done, glad you got it going.
回复

使用道具 举报

106

主题

1万

帖子

101

银币

顶梁支柱

Rank: 50Rank: 50

铜币
1299
发表于 2022-7-5 18:33:54 | 显示全部楼层
Just a suggestion (Setq ent1 (entlast)) no need for ssget
 
You are setting a variable to a entity so no need to use a selection set
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-13 04:19 , Processed in 0.467069 second(s), 73 queries .

© 2020-2025 乐筑天下

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