(defun xd::slide:->dwg (sld)
(defun _init ()
(xd::file:seek 18)
(setq lever (car (xd::file:read 1)))
(if (= lever 1)
(progn)
(progn (setq limit_x (xd::file:bin2int (xd::file:read 2))
limit_y (xd::file:bin2int (xd::file:read 2))
aspratio (xd::file:bin2int (xd::file:read 4))
)
)
)
(setq aspratio (/ aspratio 1000000.0))
(setq box (XD::Doc:GetView4Pnt)
origin (car box)
h (distance (nth 1 box) (nth 2 box))
w (distance (nth 0 box) (nth 1 box))
)
(if (< h w)
(progn (setq sy (/ limit_x (* aspratio limit_y))
sx 1
limit_y (/ limit_x aspratio)
sx (/ h limit_y)
sy (* sy sx)
)
)
(progn (setq sy 1
sx (* limit_y aspratio)
sy (/ w limit_x)
sx (* sx sy)
)
)
)
(xd::file:seek "4")
)
(defun _draw_line ()
(setq from_x (xd::file:bin2int fcode))
(setq val (xd::file:read 2))
(setq from_y (xd::file:bin2int val))
(setq val (xd::file:read 2))
(setq to_x (xd::file:bin2int val))
(setq val (xd::file:read 2))
(setq to_y (xd::file:bin2int val))
(setq p1 (list (atof (itoa from_x)) (atof (itoa from_y)) 0.0)
p2 (list (atof (itoa to_x)) (atof (itoa to_y)) 0.0))
(setq points (cons (list p1
p2
)
points
)
)
(command "line" (_trans p1) (_trans p2) "")
(command "chprop" (entlast) "" "color" m_cadcolor "")
(setq lastx to_x
lasty to_y
)
)
(defun _chg_color ()
(setq m_cadcolor oper)
)
(defun _draw_offset ()
(setq offx1 oper)
(setq val (xd::file:read 1))
(setq offy1 (car val))
(setq val (xd::file:read 1))
(setq offx2 (car val))
(setq val (xd::file:read 1))
(setq offy2 (car val))
(setq fromx (+ lastx offx1)
fromy (+ lasty offy1)
tox (+ lastx offx2)
toy (+ lasty offy2)
lastx fromx
lasty fromy
y1 fromy
y2 toy
p1 (list (atof (itoa fromx)) y1 0.0)
p2 (list (atof (itoa tox)) y2 0.0)
)
(if (not (equal p1 p2 1e-3))
(progn (command "line" (_trans p1) (_trans p2) "")
(command "chprop" (entlast) "" "color" m_cadcolor "")
)
)
)
(defun _draw_common_pt ()
(setq fromx lastx
fromy lasty
offx2 oper
)
(setq val (xd::file:read 1))
(setq offy2 (car val))
(setq tox (+ lastx offx2)
toy (+ lasty offy2)
lastx tox
lasty toy
y1 fromy
y2 toy
p1 (list fromx y1 0)
p2 (list tox y2 0)
)
(if (not (equal p1 p2 1e-3))
(progn (command ".line" (_trans p1) (_trans p2) "")
(command "chprop" (entlast) "" "color" m_cadcolor "")
)
)
)
(defun _eof_code () (princ))
(defun _trans (pt)
(setq ljb pt
scl (min sx sy)
pt (mapcar '(lambda (x) (* scl x)) pt)
)
(setq m (xd::mat:identity 3))
(setq m (xd::mat:translation origin))
(setq pt (xd::point:transform pt m))
pt
)
(defun _trans1 (pt) pt)
(if (and (setq sld (findfile sld))
(xd::file:open sld 1)
(= (xd::file:bin2str (xd::file:read 17))
"AutoCAD Slide\r\n\032"
)
)
(progn (_init)
(setq tf t
points nil
)
(while (and tf (setq fcode (xd::file:read 2)))
(setq oper (car fcode)
func (cadr fcode)
)
(cond ((and (>= func 128) (<= func 250)) (setq tf nil))
((<= func 127) (_draw_line))
((= func 251) (_draw_offset))
((= func 252) (_eof_code))
((= func 253) (_draw_solid))
((= func 254) (_draw_common_pt))
((= func 255) (_chg_color))
)
)
(xd::file:close)
)
)
(princ)
)