Jump to content

Recommended Posts

Posted (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 by Nikon
Posted

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.

Posted

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

Posted (edited)

Yes, there is a hatching without a outlines. Can it be converted to a polyline?

Edited by Nikon
Posted

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

Posted

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?

Posted
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

 

Posted (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...

 

 

 

Image 4.png

Image 5.png

Edited by Nikon
Posted

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?

Posted (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 by Nikon
Posted

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

  • Agree 1
Posted (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 by Nikon
Posted

"...then convert this outline into a solid polyline."   By this you mean a single continuous polyline entity containing both straight and arc segments, right?

Posted

You can simplify the task.

Is it possible for a closed outline to build a middle line by selecting this outline?

Image 7.png

Posted (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 by Steven P
Posted (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 by Nikon
Posted (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 by Steven P
Posted
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>

Posted

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)

)

 

Posted (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>

 

Image 2.png

Edited by Nikon

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.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...