Jump to content

Recommended Posts

Posted

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.

Posted

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))

Posted

qselect.PNG

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)
)

Posted

LoL

Lee, I see we went the same route for filtering to avoid converting to vla-object. :)

Posted

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.

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

Posted

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.

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