Hangman Posted April 26, 2010 Posted April 26, 2010 Hey guys, How would you go about filtering out and finding a zero length pline ?? I have several drawings converted from Microstation and when I run Eduard's "FLAT.lsp" to flatten the thing, I get a zero length PLine about 25.563245e27 ... long distance away that reduces my drawing to two dots on a black screen. I want to add a piece of code to the end to simply filter out and find that one stupid pline of zero length and delete it. Any help would be appreciated. Thanks. Quote
Lee Mac Posted April 26, 2010 Posted April 26, 2010 Maybe something similar to this? (defun c:FindZeroLengthPlines ( / i ss e zro ) (if (setq i -1 zro (ssadd) ss (ssget "_X" '((0 . "LWPOLYLINE")))) (while (setq e (ssname ss (setq i (1+ i)))) (and (equal 0.0 (vlax-curve-getDistatParam e (vlax-curve-getEndParam e)) 1e-14) (ssadd e zro)))) (sssetfirst nil zro) (princ)) Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 I didn't think about QSelect until I had already coded this, and I notice Lee already did one, but since I took the time, I'll post it anyway. (defun c:SZP (/ ss) ;; Select Zero Length LWPolylines ;; Alan J. Thompson, 04.26.10 (if (setq ss (ssget "_X" '((0 . "LWPOLYLINE") (90 . 2)))) ((lambda (i ss2) (while (setq e (ssname ss (setq i (1+ i)))) (or (> (vlax-curve-GetDistAtParam e (vlax-curve-GetEndParam e)) 0.) (ssadd e ss2) ) ) (and (sssetfirst nil ss2) (princ (strcat "\n" (itoa (sslength ss2)) " zero length LWPolyline(s) selected.")) ) ) -1 (ssadd) ) ) (princ) ) Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 LoL Lee, I see we went the same route for filtering to avoid converting to vla-object. Quote
Hangman Posted April 26, 2010 Author Posted April 26, 2010 Now that is interesting Alan, ... what does the DXF code (90 . 2) refer to ?? I can't find anything regarding this other than a 32 bit integer. My PLine DXF code reads (90 . 22) ?.? I like the way you guys think so much alike, but so differently. I just wish I knew half of what you guys know already, I wouldn't have to bug you so much. Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 Now that is interesting Alan, ... what does the DXF code (90 . 2) refer to ??I can't find anything regarding this other than a 32 bit integer. My PLine DXF code reads (90 . 22) ?.? I like the way you guys think so much alike, but so differently. I just wish I knew half of what you guys know already, I wouldn't have to bug you so much. dxf code 90 is the number of points it includes. Even a zero length LWPolyline will have 2 points. I just thought I'd ignore all LWPolylines with more than 1 segment from the start, just to make things a little faster. I only know what I know because I asked a lot of questions. The only bad questions are the ones unasked. Quote
alanjt Posted April 26, 2010 Posted April 26, 2010 I know a PLine can have more than 1 segment and have a zero length, but when such things are created, they are single segment, zero length objects. Which is the only reason I added that filter. However, it could easily be removed. 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.