; transptucs & transptwcs by M.R. (Marko Ribar, d.i.a.)
; arguments :
; pt - point to be transformed from WCS to imaginary UCS with transptucs and from imaginary UCS to WCS with transptwcs
; pt1 - origin of imaginary UCS
; pt2 - point to define X axis of imaginary UCS (vector pt1-pt2 represents X axis)
; pt3 - point to define Y axis of imaginary UCS (vector pt1-pt3 represents Y axis)
; important note : angle between X and Y axises of imaginary UCS must always be 90 degree for correct transformation calculation
;; Unit Vector - M.R.
;; Args: v - vector in R^n
)
)
;; Matrix x Vector - Vladimir Nesterovsky
;; Args: m - nxn matrix, v - vector in R^n
)
;; Vector Cross Product - Lee Mac
;; Args: u,v - vectors in R^3
)
)
(defun transptucs
( pt p1 p2 p3
/ ux uy uz
)
)
(defun transptwcs
( pt pt1 pt2 pt3
/ pt1n pt2n pt3n
) (setq pt1n
(transptucs '
(0.0 0.0 0.0) pt1 pt2 pt3
)) (setq pt2n
(transptucs '
(1.0 0.0 0.0) pt1 pt2 pt3
)) (setq pt3n
(transptucs '
(0.0 1.0 0.0) pt1 pt2 pt3
)) (transptucs pt pt1n pt2n pt3n)
)
(defun entmakelwpoly3dpts
( ptlst 70dxfflag
/ ux uy uz uptlst
) (if (equal uz '
(0.0 0.0 1.0) 1e
-8
) (setq ux '
(1.0 0.0 0.0) uy '
(0.0 1.0 0.0))) (if (equal uz '
(0.0 0.0 -1.0) 1e
-8
) (setq ux '
(-1.0 0.0 0.0) uy '
(0.0 1.0 0.0))) (if (not (or (equal uz '
(0.0 0.0 1.0) 1e
-8
) (equal uz '
(0.0 0.0 -1.0) 1e
-8
))) (setq ux
(unit
(v
^v '
(0.0 0.0 1.0) uz
)))) (setq uptlst
(mapcar '
(lambda ( p
) (transptucs p '
(0.0 0.0 0.0) ux uy
)) ptlst
)) '(0 . "LWPOLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDbPolyline")
'(62 . 3)
)
)
)
)
(defun c:lwpoly23dpoly
( / lwpol lwdxf lwptl lwel ux uy uz ptlst
) (setq lwpol
(car (entsel "\nPick lwpolyline to convert to 3dpolyline"))) (if (equal uz '
(0.0 0.0 1.0) 1e
-8
) (setq ux '
(1.0 0.0 0.0) uy '
(0.0 1.0 0.0))) (if (equal uz '
(0.0 0.0 -1.0) 1e
-8
) (setq ux '
(-1.0 0.0 0.0) uy '
(0.0 1.0 0.0))) (if (not (or (equal uz '
(0.0 0.0 1.0) 1e
-8
) (equal uz '
(0.0 0.0 -1.0) 1e
-8
))) (setq ux
(unit
(v
^v '
(0.0 0.0 1.0) uz
)))) '(0 . "POLYLINE")
'(100 . "AcDbEntity")
'(100 . "AcDb3dPolyline")
'(66 . 1)
'(62 . 1)
'(10 0.0 0.0 0.0)
'(210 0.0 0.0 1.0)
)
)
'(0 . "VERTEX")
'(100 . "AcDbEntity")
'(100 . "AcDbVertex")
'(100 . "AcDb3dPolylineVertex")
'(70 . 32)
)
)
)
'(0 . "SEQEND")
'(100 . "AcDbEntity")
)
)
)
(prompt "\nNo lwpolyline picked") )
)
(defun c:3dpoly2lwpoly
( / pol vert pt ptlst
) (setq pol
(car (entsel "\nPick 3dpolyline to convert to lwpolyline"))) )
)
(prompt "\nNo 3dpolyline picked") )
)
(prompt "\nDefined functions are c:lwpoly23dpoly and c:3dpoly2lwpoly")