Jump to content

Recommended Posts

Posted

Good morning,

I want to know: Is there any lisp that erases/deletes collinear points by distance and angle on 3D Polylines?

I found a lisp that does this but only on 2d polylines.

Posted (edited)

Here is how I would approach it :

 

[b][color=BLACK]([/color][/b]defun c:3dpv [b][color=FUCHSIA]([/color][/b]/ ss i en ed vn vd vl ld el p[b][color=FUCHSIA])[/color][/b]

[b][color=FUCHSIA]([/color][/b]defun is_pt_online [b][color=NAVY]([/color][/b]pt l1 l2 fz[b][color=NAVY])[/color][/b]
 [b][color=NAVY]([/color][/b]and [b][color=MAROON]([/color][/b]numberp fz[b][color=MAROON])[/color][/b]
      [b][color=MAROON]([/color][/b]equal [b][color=GREEN]([/color][/b]distance l1 l2[b][color=GREEN])[/color][/b]
             [b][color=GREEN]([/color][/b]+ [b][color=BLUE]([/color][/b]distance l1 pt[b][color=BLUE])[/color][/b]
                [b][color=BLUE]([/color][/b]distance l2 pt[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b] fz[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]

 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]not ss[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"POLYLINE"[/color][b][color=BLUE])[/color][/b]
                              [b][color=BLUE]([/color][/b]cons 70 8[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]setq i 0[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]while [b][color=NAVY]([/color][/b]setq en [b][color=MAROON]([/color][/b]ssname ss i[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq ed [b][color=MAROON]([/color][/b]entget en[b][color=MAROON])[/color][/b]
              vn [b][color=MAROON]([/color][/b]entnext en[b][color=MAROON])[/color][/b]
              vd [b][color=MAROON]([/color][/b]entget vn[b][color=MAROON])[/color][/b]
              vl nil[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]= [color=#2f4f4f]"VERTEX"[/color] [b][color=GREEN]([/color][/b]cdr [b][color=BLUE]([/color][/b]assoc 0 vd[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
               [b][color=MAROON]([/color][/b]setq vl [b][color=GREEN]([/color][/b]cons [b][color=BLUE]([/color][/b]cdr [b][color=RED]([/color][/b]assoc 10 vd[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b] vl[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
               [b][color=MAROON]([/color][/b]setq vn [b][color=GREEN]([/color][/b]entnext vn[b][color=GREEN])[/color][/b]
                     ld vd
                     vd [b][color=GREEN]([/color][/b]entget vn[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]

        [b][color=NAVY]([/color][/b]setq p 0
             el [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]car vl[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]repeat [b][color=MAROON]([/color][/b]- [b][color=GREEN]([/color][/b]length vl[b][color=GREEN])[/color][/b] 2[b][color=MAROON])[/color][/b]
           [b][color=MAROON]([/color][/b]if [b][color=GREEN]([/color][/b]not [b][color=BLUE]([/color][/b]is_pt_online [b][color=RED]([/color][/b]nth [b][color=PURPLE]([/color][/b]+ p 1[b][color=PURPLE])[/color][/b] vl[b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]nth [b][color=PURPLE]([/color][/b]+ p 0[b][color=PURPLE])[/color][/b] vl[b][color=RED])[/color][/b]
                                  [b][color=RED]([/color][/b]nth [b][color=PURPLE]([/color][/b]+ p 2[b][color=PURPLE])[/color][/b] vl[b][color=RED])[/color][/b] 1e-8[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b]
               [b][color=GREEN]([/color][/b]setq el [b][color=BLUE]([/color][/b]cons [b][color=RED]([/color][/b]nth [b][color=PURPLE]([/color][/b]+ p 1[b][color=PURPLE])[/color][/b] vl[b][color=RED])[/color][/b] el[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
           [b][color=MAROON]([/color][/b]setq p [b][color=GREEN]([/color][/b]1+ p[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]setq el [b][color=MAROON]([/color][/b]cons [b][color=GREEN]([/color][/b]last vl[b][color=GREEN])[/color][/b] el[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]

        [b][color=NAVY]([/color][/b]entdel en[b][color=NAVY])[/color][/b]

        [b][color=NAVY]([/color][/b]entmake ed[b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]foreach a el
          [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]subst [b][color=BLUE]([/color][/b]cons 10 a[b][color=BLUE])[/color][/b] [b][color=BLUE]([/color][/b]assoc 10 ld[b][color=BLUE])[/color][/b] ld[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
        [b][color=NAVY]([/color][/b]entmake [b][color=MAROON]([/color][/b]list [b][color=GREEN]([/color][/b]cons 0 [color=#2f4f4f]"SEQEND"[/color][b][color=GREEN])[/color][/b][b][color=GREEN]([/color][/b]cons 8 [color=#2f4f4f]"0"[/color][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]

        [b][color=NAVY]([/color][/b]setq i [b][color=MAROON]([/color][/b]1+ i[b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b][b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

There could be a few drawbacks ie color was BYLAYER for the source PLINE but set to say RED when the rotuione is run.

-David

Edited by David Bethel

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