Jump to content

Can someone help? I don't speak lisp. I need to convert ALL 3D Faces to polylines.


bustr

Recommended Posts

I need a lisp that goes through a drawing and automatically converts all 3D Faces to polylines. I need the polylines to remain on the same layers as the 3D Faces. I have tried this one "3DF2L.lsp" and it causes more work than it saves.

Link to comment
Share on other sites

Here's a quick one:

(defun c:foo (/ o s sp)
 (if (and (setq s (ssget ":L" '((0 . "3DFACE"))))
   (setq sp (vlax-get (vla-get-activedocument (vlax-get-acad-object))
		      (if (= 1 (getvar 'cvport))
			'paperspace
			'modelspace
		      )
	    )
   )
     )
   (foreach x (vl-remove-if 'listp (mapcar 'cadr (ssnamex s)))
     (if (setq o (vlax-invoke sp 'add3dpoly (vlax-get (vlax-ename->vla-object x) 'coordinates)))
(progn (entdel x) (vlax-put o 'closed -1))
     )
   )
 )
 (princ)
)
(vl-load-com)

Edited by ronjonp
Link to comment
Share on other sites

ronjonp I like the idea of passing the co-ords I would have used a list and stepped through them much simpler no need for a seperate co-ord routine.

 

Saved it to my library just called it something I would find. Added your name as a header :)

Link to comment
Share on other sites

I have probably written this over the years.

 

But with a clean start :

 

[b][color=BLACK]([/color][/b]defun c:3df23dpl [b][color=FUCHSIA]([/color][/b]/ ss i en ed[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]and [b][color=NAVY]([/color][/b]setq ss [b][color=MAROON]([/color][/b]ssget [color=#2f4f4f]"X"[/color] [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"3DFACE"[/color][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]setq i 0[b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]princ [color=#2f4f4f]"\nSearching...\n"[/color][b][color=NAVY])[/color][/b]
      [b][color=NAVY]([/color][/b]while [b][color=MAROON]([/color][/b]setq en [b][color=GREEN]([/color][/b]ssname ss i[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]princ [color=#2f4f4f]"\t\t\r"[/color][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]prin1 en[b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]setq ed [b][color=GREEN]([/color][/b]entget en[b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]entmake [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]assoc 8 ed[b][color=BLUE])[/color][/b]
                            [b][color=BLUE]([/color][/b]cons 66 1[b][color=BLUE])[/color][/b]
                            [b][color=BLUE]([/color][/b]cons 70 9[b][color=BLUE])[/color][/b]
                            [b][color=BLUE]([/color][/b]list 10 0 0 0[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]foreach g '[b][color=GREEN]([/color][/b]10 11 12 13[b][color=GREEN])[/color][/b]
                 [b][color=GREEN]([/color][/b]entmake [b][color=BLUE]([/color][/b]list [b][color=RED]([/color][/b]cons 0 [color=#2f4f4f]"VERTEX"[/color][b][color=RED])[/color][/b]
                                [b][color=RED]([/color][/b]assoc 8 ed[b][color=RED])[/color][/b]
                                [b][color=RED]([/color][/b]cons 10 [b][color=PURPLE]([/color][/b]cdr [b][color=TEAL]([/color][/b]assoc g ed[b][color=TEAL])[/color][/b][b][color=PURPLE])[/color][/b][b][color=RED])[/color][/b]
                                [b][color=RED]([/color][/b]cons 70 32[b][color=RED])[/color][/b][b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]entmake [b][color=GREEN]([/color][/b]list [b][color=BLUE]([/color][/b]cons 0 [color=#2f4f4f]"SEQEND"[/color][b][color=BLUE])[/color][/b]
                            [b][color=BLUE]([/color][/b]assoc 8 ed[b][color=BLUE])[/color][/b][b][color=GREEN])[/color][/b][b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]entdel en[b][color=MAROON])[/color][/b]
             [b][color=MAROON]([/color][/b]setq i [b][color=GREEN]([/color][/b]1+ i[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]redraw[b][color=FUCHSIA])[/color][/b]
 [b][color=FUCHSIA]([/color][/b]prin1[b][color=FUCHSIA])[/color][/b][b][color=BLACK])[/color][/b]

 

This could tweaked for color. No linetypes or thicknesses allowed.

 

 

-David

Link to comment
Share on other sites

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