乐筑天下

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

[编程交流] LISP to break multiple lines (

[复制链接]

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-5 19:53:33 | 显示全部楼层 |阅读模式
Currently using the below LISP to break lines. The selection of lines is picking 1 line at a time. As some polylines are overlapped, i may need to repeat the command 2 or 3 times.
 
If someone could advise on how to include a code to select the lines through a cross window selection that would be great time saver
 
  1. (defun c:BB ( / oldos ent1 p1) (setq oldos (getvar "osmode")) (while (setq ent1 (entsel "\nSelect object to break...    "))        (initget 1)        (setq p1 (getpoint "\nPoint at which to break...    "))        (setvar "osmode" 0)        (command "_.BREAK" ent1 "_f" p1 "@" "")        (setvar "osmode" oldos)) (princ "\nBreak at Done") (princ))
To clarify further I also tried Charles Alan Butler LISP, but there were some issues:-
 
1)  I can select line to be break but my breaking object is an xref, therefore it cannot be selected.
 
2) i bind the xref into the drawing so now can be selected but the lines to break & breaking object criss cross each other & break point is only at selected points of the lines.
 
3) Since it is only at selected points, i also try to instead draw a line connecting each desired break point. So then this line can be now a breaking object.
But now it take me twice as long to break this lines since i have to draw additional lines for very break point (i time myself)
 
So would appreciate if someone can help me to amend the LISP to allow cross window selection.
 
Thanks
回复

使用道具 举报

5

主题

956

帖子

963

银币

初来乍到

Rank: 1

铜币
35
发表于 2022-7-5 20:01:12 | 显示全部楼层
did you try
command: ncopy before runing lisp?
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-5 20:05:32 | 显示全部楼层
 
If you mean to run ncopy & select the desired lines from the xref as breaking objects before running the Charles Alan Butler LISP command, it does not work.  
 
That would not help as the breaking object criss cross with the lines that need to break.
 
 
And to clarify further, if you mean to use the posted break LISP after ncopy, that is unnecessary steps since I can select "point" to break on the xref object.  
 
So The main issue is the first posted BREAK lisp cannot select multiple lines that I want to break.
 
And although Charles Alan Butler LISP can select multiple lines that I want to break, it does not work on "points" as a break but instead on whole lines as a break
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 20:07:08 | 显示全部楼层
Maybe, untested...
 
  1. (defun c:BB ( / *error* el ss p i ent ) (vl-load-com) (defun *error* ( msg )   (vla-endundomark (vla-get-activedocument (vlax-get-acad-object)))   (if msg (prompt msg))   (princ) ) (vla-startundomark (vla-get-activedocument (vlax-get-acad-object))) (setq el (entlast)) (if (null el)   (progn     (alert "DWG has no entities... Add some curve entities and restart routine...")     (exit)   ) ) (prompt "\nSelect curve entities you want to apply break at point to...") (setq ss (ssget "_:L")) (while (not ss)   (if (and ss (not (vl-every '(lambda ( x ) (eq x t)) (mapcar '(lambda ( x ) (not (vl-catch-all-error-p (vl-catch-all-apply 'vlax-curve-getstartparam (list x))))) (vl-remove-if 'listp (mapcar 'cadr (ssnamex ss)))))))     (progn       (prompt "\nSome of selected entities doesn't belong to curves... Try selecting exlusively curve entities again...")       (setq ss (ssget "_:L"))     )     (if (not ss)       (progn         (prompt "\nEmpty sel.set... Try selecting curve entities again...")         (setq ss (ssget "_:L"))       )     )   ) ) (setq p t) (while p   (setq p (getpoint "\nPick or specify point at which you want to break multiple curve entities - ENTER to finish : "))   (if p     (repeat (setq i (sslength ss))       (setq ent (ssname ss (setq i (1- i))))       (if (vlax-curve-getparamatpoint ent p) (command "_.BREAK" ent "_non" p "_non" p))       (if (not (eq el (entlast))) (ssadd (entlast) ss))     )   ) ) (*error* nil))
M.R.
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-5 20:11:47 | 显示全部楼层
Thanks marko.
 
Will test it immediately when I reach office.
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-5 20:16:36 | 显示全部楼层
Hi marko.
 
Tested & does not seem to work.
 
1)when i select 2 lines, both seems highlighted.
2)But when i click the break point (Base on only 1 break point) it gave me an error
 
 
3) So i continue clicking the same break point (it seem to ask for 2 point regardless of how many lines I selected)
 
4) Command ends. Only 1 line is broken.
 
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 20:18:34 | 显示全部楼层
Code updated, retest it...
 
M.R.
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-5 20:23:54 | 显示全部楼层
Just tested it marko.
 
No error but lines did not break.
 
回复

使用道具 举报

5

主题

1334

帖子

1410

银币

限制会员

铜币
-20
发表于 2022-7-5 20:28:42 | 显示全部楼层
Have you turned OSNAP on... You should pick "int" between curves or "nea" on just single curve... I had no problems with A2014...
 
Regards, try to debug - I think that there may be differences in line (command "_.BREAK"...), but it's just a hunch...
回复

使用道具 举报

48

主题

304

帖子

256

银币

后起之秀

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

铜币
240
发表于 2022-7-5 20:29:46 | 显示全部楼层
Hi marko. Yes the osnap was turn on. i also did base on INT for the break point but still no avail. I am not sure what is wrong.
 
edit
 
I tried on autocad architecture 2014 & it works. But why my office's AutoCAD 2014 do not?
回复

使用道具 举报

发表回复

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

本版积分规则

  • 微信公众平台

  • 扫描访问手机版

  • 点击图片下载手机App

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

GMT+8, 2025-3-12 01:15 , Processed in 0.545544 second(s), 83 queries .

© 2020-2025 乐筑天下

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