- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
Hello everyone,
When I offset a self-intersecting polyline, AutoCAD trims the offset where it crosses the original polyline. Currently, there isn't a system variable that I can set to turn off this trimming behavior. Is there a LISP routine that can offset a self-intersecting polyline without trimming the offset at the intersection points as shown in the attachment?
¡Resuelto! Ir a solución.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
I expect that is going to require BREAKing the original Polyline into two pieces at some vertex such that neither remaining piece is self-intersecting, then OFFSETting each piece, and JOINing the original back together and PEDIT / Multiple / Joining the Offset results together with a fuzz distance in case the Break was at a non-tangent change in direction [i.e. the Offset results don't meet].
In your example, any vertex would do. But how complex do these things get? There are certainly configurations in which some Break points would leave at least one portion still self-intersecting. If that's a possible result, it may be possible to find a way for a routine to determine whether that happened, and try a different vertex.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
Offset creates geometry to one side or the other of a polyline. Since AutoCAD does not support the ability to apply a local twist angle enabling the creation of something akin to a mobius strip I suggest creating an offset to both sides and delete what you do not want and join what you keep.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
@leeminardi wrote:
... I suggest creating an offset to both sides and delete what you do not want and join what you keep.
That doesn't give complete "coverage" of the desired path. In this analagous situation, white is the original, red the result of Offsetting to one side, green to the other:
If OFFSET's goal is a result in which every part is the same distance away from the original, it can't fill in those gaps, because the entire length of each missing part would be at incorrect distances from the original.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
@Kent1Cooper The OP provided the following:
After taking another look at the post I see that the main issue for the OP was choosing the wrong side for the offset and using "both" as I suggested isn't necessary. Filling the gaps using extend as neeeded and then join provides the desired solution.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
To repair the "cryptic" result I'd go this way:
Instead ot the lenghten command you also can use the extend command.
IMO it is not worth the trouble to put these handfull steps into a macro or LISP, of course you can do it if it you want.
Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
It is possible to perform this offset operation manually in a few steps. Actually, what I'm looking for is a LISP routine that can offset the self-intersecting polyline without trimming with a single click. I don't understand why AutoCAD hasn't defined this option as a system variable.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
@j.palmeL29YX wrote:
.... Instead ot the lenghten command you also can use the extend command. ....
In many cases those would work, but there are lots of configurations in which it becomes a little more complex, particularly if a vertex with a change in direction falls inside the Offset gap, like the red result here:
After Exploding the red resulting Polylines, for the Arc and the lower-left Line, Lengthen would need APParent-intersection Osnap, but that doesn't work, or Extend could be used, but only in Standard mode with its Edge option set to Extend. Or Fillet with zero radius.
In the green situation, the lower-leftward Line and the longer Arc happen to be able to intersect [Extend with the same settings, or Fillet], but if the white arc segment were of smaller-enough radius [grip-edit its midpoint leftward], that intersection wouldn't exist, and it would need to be Filleted with a non-zero radius like the upper right corner.
Etc., etc. I doubt a routine could be made to work under any geometric configuration, but if there are only limited possible relationships, maybe something could be worked out. But I agree, it may not be worth trying to automate -- lots and lots of these could be handled manually in less time than it would take to come up with a routine.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
The reason I require a LISP routine that offsets a self-intersecting polyline without trimming is specific to my needs. I've developed a LISP program that successfully generates 2D G code program for a selected polyline. However, for tool compensation, it must be capable of offsetting the polyline in the specified direction. If the polyline doesn't self-intersect, then there's no problem. However, if it does, the G code program cannot generate the correct codes.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
Here are the steps on how to offset a self-intersecting polyline without trimming the crossing lines:
- Offset the polyline by the desired distance. This can be done using a variety of methods, such as the offset_polyline() function from the shapely library.
- Identify any self-intersections in the offset polyline. This can be done using a variety of methods, such as the self_intersect() function from the shapely library.
- For each self-intersection, create a new vertex at the intersection point. This can be done using the intersection() function from the shapely library.
- Update the offset polyline to include the new vertices. This can be done by appending the new vertices to the offset polyline array.
Here is an example of how to offset a self-intersecting polyline without trimming the crossing lines using the shapely library:
As you can see, the offset polyline now includes the new vertices at the intersection points. This means that the polyline has been offset by 0.5 units without trimming the crossing lines.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
@theilt20uae wrote:
.... Here is an example ....
No example included. While we wait to see it, I'll raise a question. In the original example on this topic, and possibly in any self-intersecting Polyline Offset result, Step 2 would need to identify self-intersections in more than one resulting Polyline [three in their example, and depending on the original configuration, possibly a large number of them]. Since you also don't include any link to the "shapely library," I need to ask whether it can do that.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
@bbcorhitter wrote:
....
(command "_.OFFSET" "_B" your_polyline "_")
....
[Acad2020 that I have here does not have that option. I'll try in Acad2024 from elsewhere later.]
But doesn't that require a distance input between the "_.OFFSET" and the "_B"?
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
Here's a simple lisp program that will create a single polyline all to one side of a selfintersecting polyline. You must select the polyline at a point of the loop. For example, the green dot not the red dot. It's best if the point specifed for the side is near the selection point.
(defun c:offset2 (/)
; creates an offset all to one side of a selfintersecting polyline
(setq ent (entsel
"\nSelect polyline at point on self intersecting loop."
)
p2 (getpoint "\nSpecify point to the side you want the offset."
)
d (getreal "\nSpecify offset distance: ")
en1 (car ent)
p1 (cadr ent)
)
(command "_break" en1 p1 "@")
(setq en2 (entlast))
(command "_offset" d en1 p2 "e")
(setq en3 (entlast))
(command "_offset" d en2 p2 "e")
(setq en4 (entlast))
(command "_join" en3 en4 "")
(princ)
)
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
That's the idea from Message 2. A couple of suggestions:
Also re-JOIN the source en1 and en2 Polylines back together.
Go to the nearest vertex to the pick point for the Break, so that the Joined end results don't have an extra vertex at the pick point. [That has the risk that if there's a non-tangent change in direction there, the Offset results won't touch at their ends, so a fuzz distance would be needed in the JOINing.]
@ltastan1 , would your originals ever self-intersect more than once? Depending on the specifics and exactly where you pick, this approach would sometimes not have the desired result on such a Polyline.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
@ltastan1 - a question, back to the roots:
Where is your polyline coming from? What about the idea not to create a polyline and then offset this polyline, but from the beginning immediately draw two parallel curves (similar to the MLINE command, but including arc segements too)?
I found an old LISP "DLINE" (DoubleLine) - unfortunately still in german - which can do that. Perhaps it would be helpful for you ... ?
Jürgen Palme
Did you find this post helpful? Feel free to Like this post.
Did your question get successfully answered? Then click on the ACCEPT SOLUTION button.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
@Kent1Cooper wrote:That's the idea from Message 2.
But no code? You're a much better LISP prgrammer than me so after a few days of not seeig any code I thought I would give it a try.
A couple of suggestions:
Also re-JOIN the source en1 and en2 Polylines back together.
You're right, I didn't need to define en3 and en4 as en1 and en2 were avaialable!
Go to the nearest vertex to the pick point for the Break, so that the Joined end results don't have an extra vertex at the pick point. [That has the risk that if there's a non-tangent change in direction there, the Offset results won't touch at their ends, so a fuzz distance would be needed in the JOINing.]
But if you go to the nearest vertex you also run the risk of that vertex being on the other side of the self-intersection point. A select point snapped to a vertex could cause a problem as the ends of the two offset polylines may not be coincident. Perhaps osnap should be turned off during selection.
@ltastan1 , would your originals ever self-intersect more than once? Depending on the specifics and exactly where you pick, this approach would sometimes not have the desired result on such a Polyline.
The "break" approach could be modified by asking for the user to identify mutiple loops if they exist.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
I don't have a chance to draw Polylines as Double Lines from the beginning since the drawings are already prepared. With a LISP routine, it might be possible to calculate the coordinates of each vertex for all entities in the polyline and then apply an offset, but this involves complex calculations, and it is really not easy.
- Marcar como nuevo
- Favorito
- Suscribir
- Silenciar
- Suscribirse a un feed RSS
- Resaltar
- Imprimir
- Denunciar
The original polyline has only one self-intersection point..
Leeminardi's "break" approach gives good results as long as the selected point is on the polyline loop. However, when I pick the point near the endpoints of the polyline, it doesn't provides the desired offset.