TheSwamp
Code Red => AutoLISP (Vanilla / Visual) => Topic started by: lamarn on October 21, 2009, 03:11:02 PM
-
Is there a way, code, to turn "normal Z" from -1 to 1?
We are not able to join arc's and lines into pline because of the difference...
-
Hi,
Something like this ?
(defun InvNormal (obj)
(or (= (type obj) 'VLA-OBJECT)
(setq obj (vlax-ename->vla-object obj))
)
(vla-transformBy
obj
(vlax-tmatrix '((1. 0. 0. 0.)
(0. 1. 0. 0.)
(0. 0. -1. 0.)
(0. 0. 0. 1.)
)
)
)
)
-
How do you use this code as a command?
-
Nice code Gile as always :-)
An example for you Lammerts:
(defun c:RevNorm (/ InvNormal doc ss)
(vl-load-com)
(defun InvNormal (obj) ;;Gile
(or (= (type obj) 'VLA-OBJECT)
(setq obj (vlax-ename->vla-object obj))
)
(vla-transformBy obj
(vlax-tmatrix '((1. 0. 0. 0.)
(0. 1. 0. 0.)
(0. 0. -1. 0.)
(0. 0. 0. 1.)
)
)
)
)
(if (ssget "_:L")
(progn
(vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))
(vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc))
(InvNormal obj))
(vla-delete ss)
(vla-EndUndoMark doc)))
(princ))
-
This code mirrors the z-value also!
usable in 2d, for 3d you have to watch out and restore z value ..
-
Nice code Gile as always :-)
An example for you Lammerts:
(defun c:RevNorm (/ InvNormal doc ss)
(vl-load-com)
(defun InvNormal (obj) ;;Gile
(or (= (type obj) 'VLA-OBJECT)
(setq obj (vlax-ename->vla-object obj))
)
(vla-transformBy obj
(vlax-tmatrix '((1. 0. 0. 0.)
(0. 1. 0. 0.)
(0. 0. -1. 0.)
(0. 0. 0. 1.)
)
)
)
)
(if (ssget "_:L")
(progn
(vla-StartUndoMark (setq doc (vla-get-ActiveDocument (vlax-get-acad-object))))
(vlax-for obj (setq ss (vla-get-ActiveSelectionSet doc))
(InvNormal obj))
(vla-delete ss)
(vla-EndUndoMark doc)))
(princ))
Um, yeah, but if the segments are not joining it means the normal vectors are incompatible on at least two segments.
So, reversing all the normals will not solve the problem, ¿qué no?
-
¿qué no?
wow, long time did not read anything in Spanish... :)
-
.. just want to reverse normal (without chanching xyz values) ...
What other problem???
-
Do you just want to use the UCS command to rotate your UCS 180 degrees around the x axis?
That still won't allow you to turn lines etc. into polylines.
To do that you'd need to either adjust your UCS to match the object in question, or adjust the objects to all have the same z value
What exactly are you trying to do?
dJE
-
Is there a way, code, to turn "normal Z" from -1 to 1?
We are not able to join arc's and lines into pline because of the difference...
This will reverse arc normals:
;fliparcs by KWL
(defun c:fliparcs (/ ss hpi en el)
(princ "\nSelect arcs to flip")
(setq
ss (ssget (list (cons 0 "ARC")))
hpi (* 0.5 pi)
)
(cond
(
(not (null ss))
(repeat (sslength ss)
(ssdel (setq en (ssname ss 0)) ss)
(setq el (entget en))
(entmod
(mapcar
(function
(lambda (x / g)
(setq g (car x))
(cond
((= g 10) (cons 10 (mapcar '* (list -1.0 1.0 -1.0) (cdr x))))
((= g 210) (cons 210 (mapcar '- (cdr x))))
((= g 50) (cons 50 (+ hpi (- hpi (cdr (assoc 51 el))))))
((= g 51) (cons 51 (+ hpi (- hpi (cdr (assoc 50 el))))))
(t x)
)
)
)
el
)
)
)
(princ "\nDone")
)
(t (princ "\nNothing selected"))
)
(princ)
)