TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: Peter2 on October 22, 2019, 12:31:05 PM
-
On Acad 2008 we have an old app (which can not be fixed ...) which causes sometimes a crash.
When we open the crashed DWG again (with 2008 or 2018) we get the message:
Einer 2D-Polylinie (1C8FB5) mit nur einem Kontrollpunkt wurde ein Kontrollpunkt hinzugefügt.
To a 2D-polyline (..) with only one vertex was added a vertex.
Anyone here who has experience and solutions with this problem?
I think I can't avoid it, but I hope to fix it before crashing ....
-
Without code (sorry, it's too late for me):
You can oen drawging by ObjectDBX and check all entities within all block definitions. In cse entity is LWPOLYLINE and has only one vertex, erase this enity or add one more vertex to it.
-
Try running the following routine in the drawing. Let me know if this solves the issue. EDIT. Forgot to add the (pjk-Massoc) routine - corrected.
(defun c:NULLP ( / bad cnt el en et fuzz pel pen pl ss tcnt)
(setq cnt 0 tcnt 0 fuzz 1e-11)
(princ "\n\nSearching Zero Length Polylines...")
(if (setq ss (ssget "X" (list (cons 0 "*POLYLINE"))))
(repeat (sslength ss)
(setq en (ssname ss cnt) el (entget en) et (cdr (assoc 0 el)) cnt (1+ cnt) bad nil)
(cond
((= et "LWPOLYLINE")
(setq pl (mapcar 'cdr (pjk-Massoc el 10))
f (car pl)
bad (or (= (length pl) 1)(apply '= (mapcar (function (lambda (x)(equal x f fuzz))) pl)))
)
)
((= et "POLYLINE")
(setq pen (entnext en))
(while (and pen (= (cdr (assoc 0 (setq pel (entget pen)))) "VERTEX"))
(setq pl (reverse (cons (cdr (assoc 10 pel)) (reverse pl)))
pen (entnext pen)
)
)
(setq f (car pl)
bad (or (= (length pl) 1)(apply '= (mapcar (function (lambda (x)(equal x f fuzz))) pl)))
)
)
)
(if bad (progn (entdel en)(setq tcnt (1+ tcnt))))
)
)
(princ (strcat "\nRemoved (" (itoa tcnt) ") Zero Length Polylines"))
(princ)
)
(defun pjk-Massoc (el dxf)
(vl-remove-if 'null
(mapcar (function (lambda (x)(if (= (car x) dxf) x nil))) el)
)
)
-
@PKENEWELL
thanks a lot - works fine.
In the meantime I found out that
- "qselect" for "polylines with length = 0" also find these lines
- "_audit" does not care about these lines (although opening a file with 1-vertex-plines stars an automatic repair)
-
Another code:
(defun t1
(/ adoc layers count
) (setq count '
(("len" .
0) ("txt" .
0))) ) ;_ end of lambda
) ;_ end of function
'("freeze" "lock")
) ;_ end of mapcar
) ;_ end of list
layers
) ;_ end of cons
) ;_ end of setq
) ;_ end of vlax-for
)
) ;_ end of and
)
) ;_ end of cond
) ;_ end of vlax-for
) ;_ end of if
) ;_ end of vlax-for
) ;_ end of foreach
) ;_ end of foreach
(cond ((= (car x
) "len") " entities with zero length") ((= (car x
) "txt") " text with empty strings") ) ;_ end of cond
) ;_ end of strcat
) ;_ end of lambda
) ;_ end of function
) ;_ end of mapcar
) ;_ end of apply
) ;_ end of princ
) ;_ end of if
) ;_ end of defun
Without testing.
-
@PKENEWELL
thanks a lot - works fine.
In the meantime I found out that
- "qselect" for "polylines with length = 0" also find these lines
- "_audit" does not care about these lines (although opening a file with 1-vertex-plines stars an automatic repair)
Great to hear it worked for you! :-)
Also cool bit of knowledge with the "qselect" command - I did not know you could do that.
-
Doesn't purge remove zero length objects?
-
Doesn't purge remove zero length objects?
On later versions yes .. not sure when it was introduced :)
-
At least 2010 I am thinking release 9 but that I can't be sure of.
-
My remarks to "purge zero-length plines"
a) in 2008 it does not exist in "purge"
b) for me, I need to find and select the lines, not the purge them
Thanks again for contributions.
-
My remarks to "purge zero-length plines"
a) in 2008 it does not exist in "purge"
b) for me, I need to find and select the lines, not the purge them
Thanks again for contributions.
Just curious - Why would you need to keep Zero length Polylines? Are they being used to identify something in the imported drawing that you need?
-
...Are they being used to identify something in the imported drawing that you need?
Yes. They come out of a database with incorrect data, and with the lines we can find the problems in the database.
-
This helps U :
)
)
)
)
)
(princ " No Single Vertex Polylines Found !! ") )
)
-
@ahsattarian FWIW, You should localize your variables in your code:
(defun c:a (/ i k n s ss)