Check for Closed Polylines & lines?

Check for Closed Polylines & lines?

kzD1219
Collaborator Collaborator
6,273 Views
4 Replies
Message 1 of 5

Check for Closed Polylines & lines?

kzD1219
Collaborator
Collaborator

We are doing a large project where some of the specs are to make sure all polylines are closed and all lines used are closed as well.  It is a mixture of the two and that will not change.  We need to come up with a checking process that before we submit the drawing, we can check if all polylines and lines are closed (no gaps).  That way we can fix those issues before submission. I am hoping there is something in autocad for quality control.

0 Likes
6,274 Views
4 Replies
Replies (4)
Message 2 of 5

rkmcswain
Mentor
Mentor

This lisp code should create a selection set of closed polylines.

 

(sssetfirst nil (ssget "_X" '((0 . "POLYLINE,LWPOLYLINE")(-4 . "&")(70 . 1))))
R.K. McSwain     | CADpanacea | on twitter
0 Likes
Message 3 of 5

Kent1Cooper
Consultant
Consultant

Or, if what you need is to identify those that are not closed so you can fix them:

(sssetfirst nil (ssget "_X" '((0 . "LWPOLYLINE") (-4 . "<NOT") (-4 . "&") (70 . 1) (-4 . "NOT>"))))

 

But that's only Polylines.  And a Polyline could be drawn back around to where it started without being "closed" as AutoCAD means the word -- one like that would be included in the selection above, but should it be?  Or if its ends meet, should it be considered closed, even if not "properly" but only visually?

 

What you're asking for in relation to Lines sounds like a hugely more complicated evaluation.  Do you want to have no Lines at all with any end that doesn't meet an end of another Line?  Or an end of an open-ended Polyline?  Or of an Arc?  Would a Line ever "T" into another object, so that the Line's end is not "floating free" but touching something, but not at an end of the something?  That would make a closed area [something Hatch or Boundary could work with] without any "free" end, but wouldn't be "closed" by some definitions.  It seems like a routine would need to look at both ends of every Line, and check whether there's something else there, but only certain kinds of something else would qualify.  Can it be limited by Layer or something?

 

Maybe a small sample drawing is in order, showing all the different kinds of conditions that you would consider "closed."

Kent Cooper, AIA
Message 4 of 5

kzD1219
Collaborator
Collaborator

I have attached a sample.  Thought might be something easy, like showing vertices that may not be complete or something.  I just have 2 new drafters that may not catch that stuff and I will need to when checking the plans.

0 Likes
Message 5 of 5

hak_vz
Advisor
Advisor

@Kent1Cooper  has pointed on some of potential troubles.

 

First thing that has to be checked is to see that all elements inside particular layer are drawn as correct entities.

For example all walls should have closed edges and being created as polylines. In this situation what may happen is that drafter closes polyline by picking end point instead of using close command inside polyline command. Since object snaps are used there is a sligth chance that start and end point differ.

Here you can use lisp fuction that checks if polylines are created that way and close them, so walls can later be hatched or what ever needed.

 

 

 

 

(defun c:closeApparentlyClosedPolylines ( / ss i eo start end)
(setq ss (ssget "_X" '((0 . "POLYLINE,LWPOLYLINE"))) i -1)
(while (< (setq i (1+ i)) (sslength ss))
	(setq
		eo (vlax-ename->vla-object (ssname ss i))
		start (vlax-curve-getstartpoint eo)
		end (vlax-curve-getendpoint eo)
	)
	(cond 
		((= (apply '+ (mapcar '- start end)) 0.0) (vlax-put eo 'Closed :vlax-true))
	)
)
(princ)
)

 

 

 

This code can be updated with other rules to check if drawing complies with drafting standards.

 

If walls are created using lines instead polylines then those lines have to be joined .......

checking hundreds of drawings and just marking errors can take a lot of time.

 

Miljenko Hatlak

EESignature

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.