• This forum is the machine-generated translation of www.cad3d.it/forum1 - the Italian design community. Several terms are not translated correctly.

lisp to break multiple lines in intersection points

  • Thread starter Thread starter Betoniera
  • Start date Start date

Betoniera

Guest
Hello, everyone.
I'm a strutturist.
to calculate the structures both in c.a, and in steel amount the three-dimensional model unifilare (constituted by lines) in my calculation programs.
I need all lines to be broken at intersection points.
I tried to download the pkbreak.lsp program from the site. that program works well only if you break 2 lines with only one intersection point.
if the lines are many, the program does not work and goes even wrong.
I tried repeatedly to put hands on it without being able to fix it or to understand why it is wrong.
in any way the question is:
you have, kindly, a program that breaks lines in intersections.
If it worked for a 3d chassis it would be ideal, but I would also settle for a program that works in 2d i.e. that breaks the lines in the intersection points in the plane.
I found a similar program in arx, but now I use progecad that does not support arx files.
therefore the request is for file lisp.
Thank you in advance for any answers.
Hello, everyone.
 
the file that breaks the lines is "spezzalinee .lsp" (not pkbreak.lsp as mistakenly I indicated earlier).
attach the original file below
here the list

(defun c:sl ()
(setvar "cmdecho" 0)
(princ "\n selects lines to break...")
(setq gr-selez(sget '(0 . "line")))))
(Sectq i 0)
(repeat (sslength gr-selez)
(Sectq eei(sname gr-selez i))
(setq pi1(cdr(assoc 10(entget eei))))))
(setq pi2(cdr(assoc 11(entget eei))))))
(setq k (+ i 1))
(repeat (- (sslength gr-selez) i 1)
(setq eek(sname gr-selez k))
(setq pk1(cdr(assoc 10(entget eek))))))
(setq pk2(cdr(assoc 11(entget eek))))))
(if (setq pint(inters pi1 pi2 pk1 pk2))
(progn)
(command "_break" (eval eei) pint "@")
(command "_break" (eval eek) pint "@")
)
)
(setq k(1+ k))
)
(seq i(1+) (i)
)
(princ "\n work performed!")
(princ)
)
(princ) <copyright: claudio="" granuzzo="" ing.=""> "
(princ "\n type sl to launch the program. "
(princ)

this file function well for 2 lines, but it does not work if the lines are multiple. I tried to change it by planning a repeated execution, but it doesn't work.
Does anyone have any ideas about it? .
Hello, everyone.</copyright:>
 

Attachments

I have not tested the list, but I think it does not work because when you break a line, the resulting (or the resulting ones, I am not sure) change the entity name, so the lisp does not know on which (new) object intervene.
you should first find the name (or the handle) of the new created entities, before looping the intersection size.
 
What you're looking for is quite complicated.
I have a lisp that does this but uses vl commands that I think progecad does not manage.
to obtain the desired result manually, you can follow this method:
1) with the bpoly command, create the contours of the frame panels.
2) Exploding rectangles
3) with overkill eliminate doubles

If you want the file lisp contact me that in addition to sending it to you I will explain a minimum of logic of what it does.

bye
 
I have not tested the list, but I think it does not work because when you break a line, the resulting (or the resulting ones, I am not sure) change the entity name, so the lisp does not know on which (new) object intervene.
you should first find the name (or the handle) of the new created entities, before looping the intersection size.
hello crystal
Thanks for the answer.
Obviously I thought about it and thought about solving the problem by creating a new selection for each cycle so that the program would break the lines in a second intersection, then in a third and so on.
to do this I memorized the p1 and p2 points of the selection rectangle
as you see below for a cycle of 10 times
the strange thing is that that program also works by selecting multiple lines, but it only breaks the first.
from the second on it goes wrong.
It seems a mistake as if a closing bracket was missing, but I'm not sure.
Anyway, I've made a lot of attempts without getting to the solution.
Of course, I don't expect you to find the difficult mistake.
I ask only if you have some similar program that can be adapted.
Hi.

(princ "\nselect lines to break...")
(setq count 0)
(while (< count 10)
(setq p1 (getpoint "\nimmetti primo punto di selection "))
(setq p2 (getcorner p1 "\nimmetti second point of selection "))
(setq ss3(ssget "c" p1 p2 '(0 . "line")))))

...... (here the instructions to break the lines)

(setq count (+ 1 count)
);
 
gap distance if place to 0, break line and leave no space... Unlike what you see in the gif.
 

Attachments

  • Bmcut.lsp
    Bmcut.lsp
    1.6 KB · Views: 12
  • Bmcut.gif
    Bmcut.gif
    135.3 KB · Views: 17
hi x11start
the file works in progecad even if it contains vl instructions.
the problem, as you can see in the gif, is that it breaks one line of the two that intersect, leaving the other whole.
is it that with a simple instruction you can cut the other too? .
Anyway, thank you.
It's a good program to work on to get to the result.
Bye.
 
I think the problem is what raised crystal: once the line is broken, it changes its name, so the solutions that come to my mind are:
- keep the selection window stored (e.g. point below left and top right), to remake the solution automatically, which includes the new lines generated by the first division
- every time you break a line memorize a (entlast) to catch the last created entity (this idea may also not work! )
- mark the original (line) entities, putting us a group code 1000 - 1001, so as to give it a unique name that remains even after breaking them... idea even more science fiction and the uncertain outcome!

I remember that there was already a similar problem, when I saw a discussion on the forum: It is a lisp that serves to make a "salt" to polylinea that intersects another: see Annexes
 

Attachments

  • LineJump.gif
    LineJump.gif
    182.1 KB · Views: 17
  • LineJump.lsp
    LineJump.lsp
    2.6 KB · Views: 6
I found mbreak of john f. uhden... but also for him it is necessary to throw 2 times the lisp to cut both vertical and horizontal lines: see the gif
 

Attachments

  • MBreak.gif
    MBreak.gif
    354.6 KB · Views: 17
  • MBREAK.LSP
    MBREAK.LSP
    10.7 KB · Views: 20
hi x11start
the program you posted works perfectly.
Of course you have to throw it 2 times to break all the lines, but it is little thing and it works.
I took a look at the list, but it's so complex that I gave up understanding what he does.
there are instructions in vl, but it works on progecad that, evidently implemented many vl functions.
Thank you very much for your commitment to find me the program
and thank John f. uhden (American?) who wrote it.
Thank you for finding it and making it available to everyone.
I discovered that it also works for 3d frames. Good.
hello and congratulations to all for professionalism.
 
Last edited:

Forum statistics

Threads
44,997
Messages
339,767
Members
4
Latest member
ibt

Members online

No members online now.
Back
Top