Author Topic: Convert Polylines to lines  (Read 6413 times)

0 Members and 1 Guest are viewing this topic.

venus

  • Guest
Convert Polylines to lines
« on: September 26, 2005, 06:04:06 PM »
Hey all,
I've got a bunch of plines in an old drawing that are "non coplanar" - I'm not able to fillet them and flattening them turns the entire drawing into a jumbled mess.  Is there a way to convert them into lines and have them be coplanar?  Any better suggestions?
Thanks

Bob Wahr

  • Guest
Re: Convert Polylines to lines
« Reply #1 on: September 26, 2005, 06:14:27 PM »
what about changing the elevation property?
.CHANGE
ALL
P
E
0 (zero not o)

venus

  • Guest
Re: Convert Polylines to lines
« Reply #2 on: September 26, 2005, 06:18:28 PM »
Thanks for the suggestion Bob but it didn't work - when I attempt to fillet them, they're still non coplanar.

Bob Wahr

  • Guest
Re: Convert Polylines to lines
« Reply #3 on: September 26, 2005, 06:30:16 PM »
Wierd.  I thought that would work.  Any way you can email it to me to play with?

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Convert Polylines to lines
« Reply #4 on: September 26, 2005, 06:55:09 PM »
Have you tried this routine to flatten the plines?
http://www.theswamp.org/forum/index.php?topic=1176.msg15206#msg15206
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

venus

  • Guest
Re: Convert Polylines to lines
« Reply #5 on: September 26, 2005, 07:06:07 PM »
Bob:  your email is "hidden"

CAB: I've got that lisp routine and have tried it.  some of the objects flattened get turned into objects receeding to the 0,0 coordinate and the rest of them are not able to be flattened.  I think this drawing originally came from Aris CAD, if that helps.

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Convert Polylines to lines
« Reply #6 on: September 26, 2005, 07:12:00 PM »
If you care to post the drawing or a copy with a few of these objects someone will check it out
to see if there is a solution.
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

venus

  • Guest
Re: Convert Polylines to lines
« Reply #7 on: September 26, 2005, 07:26:19 PM »
You got it!
thanks

CAB

  • Global Moderator
  • Seagull
  • Posts: 10401
Re: Convert Polylines to lines
« Reply #8 on: September 26, 2005, 10:09:46 PM »
The problem was the extrusion dxf 210 which needed to be 0 0 1
but simply forcing that and the elevation (dxf 38) to zero did not work.
I did find some code that would correct the vertex (dxf 10).
 
Code: [Select]
;; by . Jon Fleming
 (setq Elevation (cdr (assoc 38 elst))
        FirstVertexInWCS (trans (append (cdr (assoc 10 elst))
                                        (list Elevation)
                                )
                                (cdr (assoc 210 elst))
                                0
                         )
  )
 
  But after all that I discovered that exploding the pline to make a line
  resulted in the correct elevation, zero. So all I did was
 
 
Code: [Select]
Command: (setq ss (ssget "X" '((0 . "LWPOLYLINE,POLYLINE"))))
<Selection set: 3>

Command: explode

Select objects: p
4402 found

Select objects:


Command: Flat
Initializing...
FLATTEN version 2k.01f loaded.  Type FLATTEN to run it.
FLATTEN sets the Z coordinates of most objects to zero.
Do you want to continue <Y>:

Choose objects to FLATTEN [press return to select all objects in the drawing]
Select objects: Specify opposite corner: 11704 found

Select objects:

Working
 Done.
11704 object(s) flattened.
0 object(s) not flattened.


PS the flatten was just to make sure, I don't think it was needed.
See the attached zip file of the result in A2K
« Last Edit: September 26, 2005, 10:15:35 PM by CAB »
I've reached the age where the happy hour is a nap. (°¿°)
Windows 10 core i7 4790k 4Ghz 32GB GTX 970
Please support this web site.

Keith™

  • Villiage Idiot
  • Seagull
  • Posts: 16899
  • Superior Stupidity at its best
Re: Convert Polylines to lines
« Reply #9 on: September 26, 2005, 10:30:56 PM »
Indeed I found that by exploding the polylines to lines, then running flatten, the result is as expected.
Proud provider of opinion and arrogance since November 22, 2003 at 09:35:31 am
CadJockey Militia Field Marshal

Find me on https://parler.com @kblackie

venus

  • Guest
Re: Convert Polylines to lines
« Reply #10 on: September 27, 2005, 02:36:20 PM »
flippin' amazing.  you rock CAB.  I'll be keepin that one in my back pocket.
thanks

deegeecees

  • Guest
Re: Convert Polylines to lines
« Reply #11 on: September 27, 2005, 02:52:46 PM »
I was gonna say "EXPLODE", but i digress... :roll:

venus

  • Guest
Re: Convert Polylines to lines
« Reply #12 on: September 27, 2005, 03:00:15 PM »
It was all too simple, really.

Crank

  • Water Moccasin
  • Posts: 1503
Re: Convert Polylines to lines
« Reply #13 on: September 27, 2005, 03:19:20 PM »
I was thinking of something like:
Code: [Select]
(defun C:flatpoly (/ SS cmde)
(command "_undo" "_begin")
(setq cmde (getvar "CMDECHO"))(setvar "CMDECHO" 0)
(setq SS (ssget "X" '((0 . "*POLYLINE"))))
(command "_.UCS" "W")
(command "_.move" SS "" '(0 0 1e99) "" "_.move" "_p" "" '(0 0 -1e99) "")
(command "_.UCS" "P")
(setvar "CMDECHO" cmde)
(command "_undo" "_end")
(princ)
)
This worked fine for a POLYLINE, but this was the result for a LWPOLYLINE:
Code: [Select]
Command: li
LIST 1 found

                  LWPOLYLINE  Layer: "0"
                            Space: Model space
                   Handle = e7
              Open
    Constant width     0.000
Extrusion direction relative to UCS:
                   X=   -0.614  Y=   -0.642  Z=   -0.459
              area   0.000
            length   0.000

          at point  X=-5.084E+83  Y=-1.214E+83  Z=5.392E+67
          at point  X=-5.084E+83  Y=-1.214E+83  Z=5.392E+67
          at point  X=-5.084E+83  Y=-1.214E+83  Z=5.392E+67
          at point  X=-5.084E+83  Y=-1.214E+83  Z=5.392E+67
          at point  X=-5.084E+83  Y=-1.214E+83  Z=5.392E+67
          at point  X=-5.084E+83  Y=-1.214E+83  Z=5.392E+67
          at point  X=-5.084E+83  Y=-1.214E+83  Z=5.392E+67

Command:
Every time the routine is run you get a different result. Has anyone an idea why a LWPOLYLINE behaves like this?
Vault Professional 2023     +     AEC Collection

MP

  • Seagull
  • Posts: 17750
  • Have thousands of dwgs to process? Contact me.
Re: Convert Polylines to lines
« Reply #14 on: September 27, 2005, 04:21:30 PM »
Every time the routine is run you get a different result. Has anyone an idea why a LWPOLYLINE behaves like this?

Created in a non world UCS?

Running osnap?

Perhaps --

(command "_.move" SS "" "_non" '(0 0 1e99) "" "_.move" "_p" "" "_non" '(0 0 -1e99) "")

-------------------------------------------------------------------------------------------------------------------

Just a quick note of acknowledgement -- afaik Randy Richardson was the first to publicise the use of

(command "_.move" SS "" '(0 0 1e99) "" "_.move" "_p" "" '(0 0 -1e99) "")

as a quick flattener of sorts.

-------------------------------------------------------------------------------------------------------------------

Myself I've penned many many flatteners over the years, at one point it was a major career activity. This is a very simple / less ambitious one (I have penned some that go tho whole 9 yards, de-xref, de-paperspace, remove hidden lines, retain original layering yada ...) from sometime 1999/2000:

Code: [Select]
(defun c:Splat ( / _children _splat ss i )

    (defun _children ( ename / data result )
        (if (assoc 66 (entget ename))
            (reverse
                (while
                    (/= "SEQEND"
                        (cdr
                            (assoc 0
                                (setq data
                                    (entget
                                        (setq ename   
                                            (entnext ename)
                                        )
                                    )
                                )
                            )
                        )
                    )
                    (setq result (cons ename result))
                )
            )
        )
    )
   
    (defun _splat ( ename )
        (foreach ename (cons ename (_children ename))
            (entmod
                (mapcar
                   '(lambda ( lst / key )
                        (cond
                            (   (member
                                    (setq key (car lst))
                                   '(10 11 12 13)
                                )
                                (cons
                                    (car lst)
                                    (mapcar '* '(1.0 1.0 0.0) (cdr lst))
                                )
                            )
                            (   (eq 38 key) '(38 . 0.0))
                            (   t lst  )
                        )
                    )
                    (entget ename)
                )
            )
        )
        (entupd ename)
    )   

    (if (setq ss (ssget))
        (repeat (setq i (sslength ss))
            (_splat
                (ssname ss
                    (setq i (1- i))
                )
            )
        )     
    )
   
    (princ)
   
)

Doesn't do 3dsolids, but does do attributes, polyline vertices etc., honours locked layers.
Engineering Technologist • CAD Automation Practitioner
Automation ▸ Design ▸ Drafting ▸ Document Control ▸ Client
cadanalyst@gmail.comhttp://cadanalyst.slack.comhttp://linkedin.com/in/cadanalyst

Andrea

  • Water Moccasin
  • Posts: 2372
Re: Convert Polylines to lines
« Reply #15 on: September 28, 2005, 09:37:06 AM »
why not just use the FLATTEN command ?
Keep smile...