Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

convert 3d to 2d polylines with same coordinates

0 views
Skip to first unread message

Jasmina Subotic

unread,
Oct 3, 1999, 3:00:00 AM10/3/99
to
Could someone help me?
I use Auto CAD R14.I have a file drawing (input was dxf file), with lots of
3D polylines, with same X coordinates at each vertex. I need to put them
into 2D polylines with same coordinates. I have a process, but it愀 very
slow. I EXPLODE all the 3dpoly. Then, I have to PEDIT all the lines one by
one to transform them into 2D polylines. Are there a process or a lisp that
transform 3Dpoly (with one same coordinate) into 2Dpoly?
If there are, tell me, please.

Thank you in advance.
Jasmina
P.S. Sorry for bad English

Ibro Vehabovic

unread,
Oct 3, 1999, 3:00:00 AM10/3/99
to
Jasmina,

This code +ACI-flats+ACI- selected 3DPolylines, e.g. changes
Z-coordinates of all vertices to zero. If you need X-coords
to be zero just move up 2 semicolons (+ADs-) 2 lines.
Anyway, let me know how it works.


(defun c:3DPoly-flat ( / ss i e eg)
(cond
((setq ss (ssget '((0 . +ACI-polyline+ACI-)(-4 . +ACIAJgA9ACI-)(70 . 8))))
(setq i -1)
(repeat (sslength ss)
(setq e (ssname ss (setq i (1+- i))))
(while (eq (cdr (assoc 0 (setq eg (entget (setq e (entnext
e)))))) +ACI-VERTEX+ACI-)
(entmod (append eg (list (cons 10 (list (car (cdr (assoc 10
eg))) +ADs-Z+AD0-0
(cadr (cdr (assoc 10
eg))) 0.0)))))
+ADs- (entmod (append eg (list (cons 10 (list 0.0 (cadr (cdr
(assoc 10 eg))) +ADs-X+AD0-0
+ADs- (caddr (cdr (assoc 10
eg))))))))
)+ADs-while
)+ADs-repeat
)+ADs-ss
(t (princ +ACIAXA-nNo 3DPolylines selected.+ACI-))
)+ADs-cond
(princ)
)


Best Regards,

Ibro Vehabovic
ibrov+AEA-flash.net
Jasmina Subotic wrote in message +ADw-7t8g00+ACQ-nac4+AEA-adesknews2.autodesk.com+AD4-...
+AD4-Could someone help me?
+AD4-I use Auto CAD R14.I have a file drawing (input was dxf file), with lots of
+AD4-3D polylines, with same X coordinates at each vertex. I need to put them
+AD4-into 2D polylines with same coordinates. I have a process, but it+ALQ-s very
+AD4-slow. I EXPLODE all the 3dpoly. Then, I have to PEDIT all the lines one by
+AD4-one to transform them into 2D polylines. Are there a process or a lisp that
+AD4-transform 3Dpoly (with one same coordinate) into 2Dpoly?
+AD4-If there are, tell me, please.
+AD4-
+AD4-Thank you in advance.
+AD4- Jasmina
+AD4-P.S. Sorry for bad English
+AD4-
+AD4-
+AD4-
+AD4-
+AD4-
+AD4-

Vladimir Nesterovsky

unread,
Oct 4, 1999, 3:00:00 AM10/4/99
to
You would assume big CAD system like ACAD
should have some conversion routines
of this sort built in, but it doesn't.
After all, you're having a planar POLYLINE
here, no matter it's described as 3DPOLY,
right? :-)

May be it's possible to cast a 3dpoly into a 2d
with ARX, I don't know.

But the only option AFAIK is to write
a LISP code:

(defun c:x2d() ; put locals there... :))
(setq e (car (entsel))
ds (edlgetsubent e)
d1 (car ds)
vs (cdr ds)
f (cdr(assoc 70 d1))
p0 (get 10 (car vs))
n '(1 0 0)
q0 (trans p0 e n)
z (last q0)
)
(entmake
(append
(list
'(0 . "LWPOLYLINE") '(100 . "AcDbEntity")
(assoc 8 d1)
'(100 . "AcDbPolyline")
(cons 90 (length vs))
(cons 70 (logand 129 f))
(cons 38 z)
)
(if (assoc 48 d1) (list (assoc 48 d1)))
(mapcar '(lambda(d / p q)
(setq p (cdr(assoc 10 d))
q (trans p e n))
(list 10 (car q) (cadr q))) vs)
(list (cons 210 n))
))
(entdel e)
(princ))

I'm _assuming_ all your points here have
equal X coordinates.

If anyone would like to contribute more here,
make it automatically find the plane PLINE
is in, and use 'N accordingly. :)

A tip (for a few here who need it): it's
easy to find all points of the original
pline with

(setq ps (mapcar
'(lambda(d)(cdr(assoc 10 d))) vs))

Tricky part would be to find if they all belong
to some plane, and to find that plane's normal
vector, then to use it as 'N in the code above. :-)

Tested, :-)

-------
(defun edlgetsubent(en / d dl )
"all ents data, w/out SEQEND"
(setq d (entget en) dl (list d))
(if (= 1 (cdr(assoc 66 d)))
(while (/= "SEQEND"
(cdr(assoc 0 (setq d(entget
(setq en (entnext en)))))))
(setq dl (cons d dl))))
(reverse dl)
)
-------


On Sun, 3 Oct 1999 22:52:40 +0200, "Jasmina Subotic" <ja...@EUnet.yu>
wrote:

>Could someone help me?


>I use Auto CAD R14.I have a file drawing (input was dxf file), with lots of

>3D polylines, with same X coordinates at each vertex. I need to put them

>into 2D polylines with same coordinates. I have a process, but it愀 very


>slow. I EXPLODE all the 3dpoly. Then, I have to PEDIT all the lines one by

>one to transform them into 2D polylines. Are there a process or a lisp that

>transform 3Dpoly (with one same coordinate) into 2Dpoly?

>If there are, tell me, please.

---
Vlad http://www.netvision.net.il/php/vnestr/
Splines can be converted into tangential arcs
with arbitrary precision. :-)

Jasmina Subotic

unread,
Oct 4, 1999, 3:00:00 AM10/4/99
to
Hello!
Yes, you was perfectly right...but I don't know how to use your code. I
don't understand: "put lockals there...". I didn't put anything. I just
tried your code. But nothing was happen. See what was in AutoCAD Text Window
(I can't select object?):
Command: x2d

Select object: error: null function
(EDLGETSUBENT E)
(SETQ E (CAR (ENTSEL)) DS (EDLGETSUBENT E) D1 (CAR DS) VS (CDR DS) F (CDR
(ASSOC 70 D1)) P0 (GET 10 (CAR VS)) N (QUOTE (1 0 0)) Q0 (TRANS P0 E N) Z
(LAST
Q0))
(C:X2D)
*Cancel*

Best Regards,
Jasmina

Vladimir Nesterovsky <vne...@netvision.net.il> wrote in message
news:37fb1ce8...@adesknews.autodesk.com...

> After all, you're having a planar POLYLINE
> here, no matter it's described as 3DPOLY,
> right? :-)

> But the only option AFAIK is to write

Vladimir Nesterovsky

unread,
Oct 5, 1999, 3:00:00 AM10/5/99
to
You missed this function from
my previous post:

-------
(defun edlgetsubent(en / d dl )
"all ents data, w/out SEQEND"
(setq d (entget en) dl (list d))
(if (= 1 (cdr(assoc 66 d)))
(while (/= "SEQEND"
(cdr(assoc 0 (setq d(entget
(setq en (entnext en)))))))
(setq dl (cons d dl))))
(reverse dl)
)
-------

You need to load it too, then use X2D command.
You can ignore the "Put locals there" remark. :-)


On Mon, 4 Oct 1999 23:14:17 +0200, "Jasmina Subotic" <ja...@EUnet.yu>
wrote:

>Hello!


> Yes, you was perfectly right...but I don't know how to use your code. I
>don't understand: "put lockals there...". I didn't put anything. I just
>tried your code. But nothing was happen. See what was in AutoCAD Text Window
>(I can't select object?):
>Command: x2d
>
>Select object: error: null function
>(EDLGETSUBENT E)

---
Vlad http://www.netvision.net.il/php/vnestr/

Ibro Vehabovic

unread,
Oct 5, 1999, 3:00:00 AM10/5/99
to
Vladimir,
I have just refreshed my "analytical geometry" and look at
what I did. Maybe it is not perfect but it works.


;returns nil if all points do not belong to the same plane
;otherwise returns normal vector of the plane
(defun pts-in-plane ( pts / fuzz x a b c tmp)
(setq fuzz 0.00001)
(command "_.UCS" "_3" (car pts) (cadr pts) (caddr pts)) ;sets UCS through
first 3 points
;should be checked
if points are colinear
(setq x (getvar "UCSXDIR") y (getvar "UCSYDIR")
a (- (* (cadr x) (caddr y)) (* (caddr x) (cadr y))) ;calcs X value
of normal vector
b (- (* (caddr x) (car y)) (* (car x) (caddr y))) ;calcs Y value
of normal vector
c (- (* (car x) (cadr y)) (* (cadr x) (car y))) ;calcs Z value
of normal vector
);setq
(command "_.UCS" "_P")
(foreach x pts
(if (null (equal (+ (* a (- (car x) (car (car pts))))
(* b (- (cadr x) (cadr (car pts))))
(* c (- (caddr x) (caddr (car pts))))) 0.0 fuzz))
(setq tmp T)
);if
);foreach
(if tmp nil (list a b c))
);defun (pts-in-plane)

Here is your modified routine:

;by Vladimir Nesterovsky
(defun c:x2d ( / e ds d1 vs f p0 pts n q0 z p q)


(setq e (car (entsel))
ds (edlgetsubent e)
d1 (car ds)
vs (cdr ds)
f (cdr(assoc 70 d1))
; p0 (get 10 (car vs))

p0 (cdr (assoc 10 (car vs)))
pts (mapcar '(lambda (d) (cdr (assoc 10 d))) vs)
n (pts-in-plane pts)
; if n=nil 3DPoly does not lay in one plane ...


q0 (trans p0 e n)
z (last q0)

);setq


(entmake
(append
(list
'(0 . "LWPOLYLINE") '(100 . "AcDbEntity")
(assoc 8 d1)
'(100 . "AcDbPolyline")
(cons 90 (length vs))
(cons 70 (logand 129 f))
(cons 38 z)
)
(if (assoc 48 d1) (list (assoc 48 d1)))
(mapcar '(lambda(d / p q)
(setq p (cdr(assoc 10 d))
q (trans p e n))
(list 10 (car q) (cadr q))) vs)
(list (cons 210 n))
))
(entdel e)
(princ))

(defun edlgetsubent(en / d dl ) ;"all ents data, w/out SEQEND"


(setq d (entget en) dl (list d))
(if (= 1 (cdr(assoc 66 d)))
(while (/= "SEQEND"
(cdr(assoc 0 (setq d (entget
(setq en (entnext en)))))))
(setq dl (cons d dl))))
(reverse dl)
)


--
Ibro Vehabovic
ib...@flash.net


Vladimir Nesterovsky <vne...@netvision.net.il> wrote in message
news:37fb1ce8...@adesknews.autodesk.com...

> You would assume big CAD system like ACAD
> should have some conversion routines
> of this sort built in, but it doesn't.

> After all, you're having a planar POLYLINE
> here, no matter it's described as 3DPOLY,
> right? :-)
>

> May be it's possible to cast a 3dpoly into a 2d
> with ARX, I don't know.
>

> If anyone would like to contribute more here,
> make it automatically find the plane PLINE
> is in, and use 'N accordingly. :)
>
> A tip (for a few here who need it): it's
> easy to find all points of the original
> pline with
>
> (setq ps (mapcar
> '(lambda(d)(cdr(assoc 10 d))) vs))
>
> Tricky part would be to find if they all belong
> to some plane, and to find that plane's normal
> vector, then to use it as 'N in the code above. :-)
>
> Tested, :-)
>

> -------
> (defun edlgetsubent(en / d dl )
> "all ents data, w/out SEQEND"
> (setq d (entget en) dl (list d))
> (if (= 1 (cdr(assoc 66 d)))
> (while (/= "SEQEND"
> (cdr(assoc 0 (setq d(entget
> (setq en (entnext en)))))))
> (setq dl (cons d dl))))
> (reverse dl)
> )
> -------
>
>

Reinaldo Togores

unread,
Oct 5, 1999, 3:00:00 AM10/5/99
to
I have something writen about this in http://start.at/autolisp/ including
the case in which the 3d polyline is coplanar, but not parallell to the WCS
XY plane.
The paper is in spanish, but the code will work in any language version.


--
Reinaldo Togores
AutoCAD based CAD - GIS Training & Consulting
Spanish-English Software translation & localization

Jasmina Subotic <ja...@EUnet.yu> escribió en el mensaje de noticias
7t8g00$na...@adesknews2.autodesk.com...


> Could someone help me?
> I use Auto CAD R14.I have a file drawing (input was dxf file), with lots
of
> 3D polylines, with same X coordinates at each vertex. I need to put them

> into 2D polylines with same coordinates. I have a process, but it´s very


> slow. I EXPLODE all the 3dpoly. Then, I have to PEDIT all the lines one by
> one to transform them into 2D polylines. Are there a process or a lisp
that
> transform 3Dpoly (with one same coordinate) into 2Dpoly?
> If there are, tell me, please.
>

Jasmina Subotic

unread,
Oct 6, 1999, 3:00:00 AM10/6/99
to
Hello Vladimir!
Thanks! In the meantime Ibro send me your code with this function.He
knows how my knowledge is little and how my English is bad :) We speak the
same language. Code works just how I ask. But I thought that I can change
UCS, surprise...it works everything in World UCS. I have 3D polylines, with
same Y or Z coordinates at each vertex also...and 5% of planar POLYLINE
which is no parallel with to the WAS planes.Maybe Reinaldo's code could help
:) I start to learn Spanish :(

Vladimir Nesterovsky <vne...@netvision.net.il> wrote in message

news:37fa5983...@adesknews.autodesk.com...


> You missed this function from
> my previous post:

> You can ignore the "Put locals there" remark. :-)

I can't ignore this Ibro put your name here :)
Best Regards,
Jasmina


Vladimir Nesterovsky

unread,
Oct 6, 1999, 3:00:00 AM10/6/99
to
Hi Ibro,

Here, you've come to the rescue once again! Thanks!
I hope the code will work now as it should. :-)

Good luck,

On Tue, 5 Oct 1999 09:07:58 -0700, "Ibro Vehabovic" <ib...@flash.net>
wrote:

>Vladimir,
>I have just refreshed my "analytical geometry" and look at
>what I did. Maybe it is not perfect but it works.

---
Vlad http://www.netvision.net.il/php/vnestr/
-== Let the Corman LISP be with you. ==-

Bob Schaefer

unread,
Oct 9, 1999, 3:00:00 AM10/9/99
to
mpedit
All
O(pen)
C(lose)
X(exit)


Jasmina Subotic <ja...@EUnet.yu> wrote in message
news:7t8g00$na...@adesknews2.autodesk.com...


> Could someone help me?
> I use Auto CAD R14.I have a file drawing (input was dxf file), with lots
of
> 3D polylines, with same X coordinates at each vertex. I need to put them

> into 2D polylines with same coordinates. I have a process, but it愀 very

Bob Schaefer

unread,
Oct 9, 1999, 3:00:00 AM10/9/99
to
Sorry, I forgot yes to convert.

mpedit
all
y es (to convert)
o
c
x


Bob Schaefer <rcsch...@att.com> wrote in message
news:7tn9gu$t...@adesknews2.autodesk.com...

Terry W. Dotson

unread,
Oct 9, 1999, 3:00:00 AM10/9/99
to
Bob Schaefer wrote:

> Sorry, I forgot yes to convert.

I sorry, but I don't see that converting 3Dpolylines to 2D/LW.

Terry

Jasmina Subotic

unread,
Oct 10, 1999, 3:00:00 AM10/10/99
to
Sorry, but it don't convert 3d to 2d polylines. Ibro send me (to my
address) ingenious code. Now I just try to find some mistake, but I can't.
Code works more than I was expecting. I think that he will put it on
autodesk.autocad.customer-file.

Jasmina
P.S. Sorry for bad English

Bob Schaefer <rcsch...@att.com> wrote in message
news:7tna1m$t...@adesknews2.autodesk.com...


> Sorry, I forgot yes to convert.
>

0 new messages