Nikon Posted September 3, 2023 Posted September 3, 2023 (edited) Good afternoon. There are many hatches SOLID without a outline, they look like a polyline. Is it possible to programmatically convert the selected hatches into polylines with a given global width (or with a width of 0), or with the ability to specify the width. If this is not feasible, is it possible to convert the outline of a polyline into a polyline with a global width, like a outline (or with a width of 0)? I can use AutoCAD to create a outline for these hatches, but is it possible to do it programmatically: 1 - create outlines for hatches 2 - replace outlines with polylines Lee Mac has a PolyOutline program http://www.lee-mac.com/polyoutline.html This program will create one or more LWPolylines along the boundary of an LWPolyline with varying or constant width. Is the reverse process possible: converting a contour into a polyline? Thank you.Hatching - polyline.dwg Edited September 4, 2023 by Nikon Quote
BIGAL Posted September 3, 2023 Posted September 3, 2023 A contour is a civil engineering term so makes your request harder to understand, a countour is a line/s describing a Z value. So are you saying want a pline width converted to a outline pline with capped ends. Quote
Steven P Posted September 3, 2023 Posted September 3, 2023 Or is it a hatch with no associated boundary converted to a polyline with an associated width? Recreate boundary to create a boundary round the hatch, and the boundary converted to a single line rather than a polyline with capped ends? Delete the original hatch Quote
Nikon Posted September 3, 2023 Author Posted September 3, 2023 (edited) Yes, there is a hatching without a outlines. Can it be converted to a polyline? Edited September 4, 2023 by Nikon Quote
BIGAL Posted September 3, 2023 Posted September 3, 2023 language problem remove word contour should use "Outline" in future. Yes, there is a hatching. Can it be converted to a polyline? There is a lisp HatchB that makes a boundary of a hatch. HatchB.lsp Quote
Nikon Posted September 4, 2023 Author Posted September 4, 2023 BIGAL, thanks. I know this lisp. I can use AutoCAD to create an outline for these hatches. Is it possible to replace outlines with polylines? Quote
exceed Posted September 4, 2023 Posted September 4, 2023 48 minutes ago, Nikon said: BIGAL, thanks. I know this lisp. I can use AutoCAD to create an outline for these hatches. Is it possible to replace outlines with polylines? hatchB makes 2D Polyline, this is 2d polyline to lw polyline routine. merge 2 code in 1 lsp file. https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-to-convert-2d-polyline-to-polyline/m-p/7124592/highlight/true#M353918 https://forums.autodesk.com/t5/visual-lisp-autolisp-and-general/lisp-routine-to-convert-2d-polyline-to-polyline/m-p/7124661/highlight/true#M353924 Quote
Nikon Posted September 4, 2023 Author Posted September 4, 2023 (edited) Probably a bad translation... I need to convert the outline of the hatching into a polyline with a global width. It is necessary that the object has a length... Edited September 4, 2023 by Nikon Quote
exceed Posted September 4, 2023 Posted September 4, 2023 Ah, now I understand. It may be a bit difficult because it is like the process of picking up spilled water. look for Lisp to draw a center line between two lines or I think need to use an offset, it can be easy if it is a simple shape or a sample where both straight and elbow are separated but If there are intersections or complex shapes, it may be difficult to know which side is the tray(pipe) and which side is blank. this is just idea. explode all of outline then offsetting all lines in both directions saving the lines in list and then remaining only when the two exact start point and end point overlap? Quote
Nikon Posted September 4, 2023 Author Posted September 4, 2023 (edited) exceed, thanks. There are a lot of SOLID hatches in the drawing. Editing manually will take a long time, unfortunately... Is it possible to write a reverse program http://www.lee-mac.com/polyoutline.html? Edited September 4, 2023 by Nikon Quote
Steven P Posted September 4, 2023 Posted September 4, 2023 Haven't had a chance to look at this one, but I'd be tempted to go with recreate the boundary - loads of examples out there for that, then offset but I think you'd need a polyline to offset and make it work well rather than explode to individual lines. perhaps have to look at each vertex, compare with the ones either side to find 2 that are the right length (as above, say, 50) and at right angles to the other - break the polylines here giving 2 ends plus 2 polylines then offset one of them 1 Quote
Nikon Posted September 4, 2023 Author Posted September 4, 2023 (edited) The drawings were not created in the AutoCAD program, there is no connection with the developers ... Hatching is the reinforcing bars , there are straight lines, there are arcs ... I can't determine the length of this reinforcing bars, so such a task arose. I need to create a outline for all the hatches, and then convert this outline into a solid polyline, it can be zero width, not 50. Edited September 4, 2023 by Nikon Quote
ReMark Posted September 4, 2023 Posted September 4, 2023 "...then convert this outline into a solid polyline." By this you mean a single continuous polyline entity containing both straight and arc segments, right? Quote
Nikon Posted September 4, 2023 Author Posted September 4, 2023 You can simplify the task. Is it possible for a closed outline to build a middle line by selecting this outline? Quote
Steven P Posted September 4, 2023 Posted September 4, 2023 (edited) Just putting this here as a part LISP: Steps to do before this: Recreate the hatch boundary with a polyline - can do easily enough via LISP, probably it is out on the internet anyway Set the polyline to open - can modify assoc list for the polyline to do this Then run this to split the polyline into 2 parts. Offset one of these the distance of the last vertex of the other. Delete the original polylines, and that should be it done.... however time for lunch first.... However this is the main part that needs to be done, get one line that can be offset (defun c:testthis ( / MyPoly VertexList SplitHere ) ;;https://www.cadtutor.net/forum/topic/24364-vertices-of-a-polyline/ (defun mAssoc ( key lst / l x ) (foreach x lst (if (= key (car x)) (setq l (cons (cdr x) l)) ) ) (reverse l) ) (setq APoly (car (entsel "Select Polyline"))) (setq MyPoly (entget APoly)) (setq VertexList (massoc 10 MyPOly)) (setq SplitHere (nth (/ (length VertexList) 2) VertexList)) (princ SplitHere) (command "breakatpoint" APOly SplitHere) (princ) ) Edited September 4, 2023 by Steven P Quote
Nikon Posted September 4, 2023 Author Posted September 4, 2023 (edited) Steven P, thanks. But nothing happens. Writing on the command line: "Сommand: TESTTHIS Select Polyline(15566.3 6176.2)(15566.3 6176.2)" ...I'm not a programmer at all... Edited September 4, 2023 by Nikon Quote
Steven P Posted September 4, 2023 Posted September 4, 2023 (edited) Yup, that's what it is meant to do! Just a part of the solution. The coordinates it gives are the point to split the hatch outline polyline. Part code because the laptop is being an idiot today and crashing. Edited the code above to split the polyline. Noting that is appears to be the last entity created (entlast) is the line to offset - need to confirm this though Edited September 4, 2023 by Steven P Quote
Nikon Posted September 4, 2023 Author Posted September 4, 2023 14 minutes ago, Steven P said: Edited the code above to split the polyline. Noting that is appears to be the last entity created (entlast) is the line to offset - need to confirm this though Unfortunately Command: TESTTHIS Select Polyline(15566.3 6176.2)Unknown command "BREAKATPOINT". <object name: FEBF6C60> Quote
Steven P Posted September 4, 2023 Posted September 4, 2023 Try this one: (defun c:testthis ( / MyPoly VertexList SplitHere ) ;;https://www.cadtutor.net/forum/topic/24364-vertices-of-a-polyline/ (defun mAssoc ( key lst / l x ) (foreach x lst (if (= key (car x)) (setq l (cons (cdr x) l)) ) ) (reverse l) ) (setq APoly (car (entsel "Select Polyline"))) (setq MyPoly (entget APoly)) (setq VertexList (massoc 10 MyPOly)) (setq SplitHere (nth (/ (length VertexList) 2) VertexList)) (princ SplitHere) ;; (command "breakatpoint" APOly SplitHere) (command "._break" APOly SplitHere SplitHere) (entdel APoly) ) Quote
Nikon Posted September 4, 2023 Author Posted September 4, 2023 (edited) command: TESTTHIS Select Polyline(13406.0 5227.07)._break Select an object: The first break point: The second break point: Command: <Object Name: 7ffffb06460> Edited September 4, 2023 by Nikon Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.