TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: domenicomaria on May 31, 2021, 04:43:14 AM
-
(defun C:LINE,PLINE
>ZETA
-ZERO
( / i ind n
-rep new
-el p10 p11 ss x
-el x
-en x
-et x
-pt
) (setq ss
(LM:
SSGET "\nselect LINEs and POLYLINEs to SET VERTEXES to ZETA=0 : " '
(((0 .
"LINE,LWPOLYLINE"))) ) ) x-et (:DXF 0 x-el )
)
( (= x-et "LINE")
(setq p10
(:DXF
10 x
-el
) p11
(:DXF
11 x
-el
) )
)
( (= x-et "LWPOLYLINE")
i
)
)
x-el
)
)
; (setq new-el-s new-el)
)
)
)
)
Why with LWPOLYLINE it doesn't work ?
-
ok
I need to change the elevation too !
38 !
And if the LWPOLYLINE is 3D-rotated and its UCS is not WCS ?
what to do to project it in the XY plane?
TRANS ? i suppose ! :idiot2:
-
Untested, you are missing sub functions (LM:ssget) and (:DXF)...
(defun C:LINE,PLINE
>ZETA
-ZERO
( / i ind n
-rep new
-el p10 p11 ss x
-el x
-en x
-et x
-pt
) (setq ss
(LM:
SSGET "\nselect LINEs and POLYLINEs to SET VERTEXES to ZETA=0 : " '
(((0 .
"LINE,LWPOLYLINE"))) ) ) x-et (:DXF 0 x-el )
)
( (= x-et "LINE")
(setq p10
(:DXF
10 x
-el
) p11
(:DXF
11 x
-el
) )
)
( (= x-et "LWPOLYLINE")
i
)
)
x-el
)
)
)
)
)
)
-
;; ssget - Lee Mac
;; A wrapper for the ssget function to permit the use of a custom selection prompt
;; msg - [str] selection prompt
;; arg - [lst] list of ssget arguments
(defun LM:ssget ( msg arg / sel )
(princ msg)
(setvar 'nomutt 1)
(setq sel (vl-catch-all-apply 'ssget arg))
(setvar 'nomutt 0)
(if (not (vl-catch-all-error-p sel)) sel)
)
(defun :DXF (code elist) (cdr (assoc code elist)))
-
(defun C:LINE,PLINE
>ZETA
-ZERO
( / i ind n
-rep new
-el p10 p11 ss x
-el x
-en x
-et x
-pt
) ; (:UNDO-GROUP-BEGIN)
(setq ss
(LM:
ssget "\nselect LINEs and POLYLINEs to SET VERTEXES to ZETA=0 : " '
(((0 .
"LINE,LWPOLYLINE"))) ) ) x-et (:DXF 0 x-el )
)
( (= x-et "LINE")
(setq p10
(:DXF
10 x
-el
) p11
(:DXF
11 x
-el
) )
)
( (= x-et "LWPOLYLINE")
)
)
(t i)
)
)
x-el
)
)
; (setq new-el-s new-el)
)
)
)
; (:UNDO-GROUP-END)
ind
)
this is the working code . . .
. . .
but i want understand
if the LWPOLYLINE is 3D-rotated and its CS is not parallel to WCS
what to do to project it to get its projection in the XY plane . . .
. . .
I suppose I have to study some Lee Mac code . . .
-
i am trying to project a (3d rotated) lwpolyline in the XY plane.
The following code, works.
It modifies the lwpolyline and the result is the projection of it, in the XY plane
. . .
but the good result, is TRANSLATED along the Y axis !
And I am not able to understand why this happens !
I probably omit a displacement . . .
When I use TRANS ?
(defun C:LWP
>XY
( / i new
-el x
-210 x
-el x
-en x
-pt
) (setq x
-en
(car (entsel "\nselect a LWPOLYLINE to project into XY plane : ")) x-210 (:DXF 210 x-el )
)
)
( (= (car i
) 210) (cons 210 '
(0 0 1) ) ) (t i)
)
)
x-el
)
)
)
-
you need to translate the points as 3D points. IOW you need to add the elevation to the 2D GC 10 points, translate, and then remove the Z.
-
you need to translate the points as 3D points. IOW you need to add the elevation to the 2D GC 10 points, translate, and then remove the Z.
(defun C:LWP
>XY
( / i new
-el x
-38 x
-el x
-en x
-pt
)
(setq x
-en
(car (entsel "\nselect POLYLINEs to project into XY plane : ")) x-38 (:DXF 38 x-el )
)
(setq x
-pt
(:PT
-SET
-Z
(cdr i
) x
-38) ) )
(cons 10 (:PT
-3D
>2D x
-pt
) ) )
( (= (car i
) 210) (cons 210 '
(0 0 1) ) ) (t i)
)
)
x-el
)
)
)
(defun c:k
() (C:LWP
>XY
) )
roy_043
thank you.
It works well, now .
But I have still to understand well, why it works . . .
ciao
-
however, I found this SUPERFLATTEN, which is "slightly" :? :lol: better. . .
http://www.theswamp.org/index.php?topic=18153.0