lisp将jpg放入sld图库_晓东CAD家园-论坛-A/VLISP-幻灯片SLD生成DWG(提取幻灯片数据用LINE画到图中)-读取幻灯数据,充满窗口绘制,有流文件读取的函数,和充满窗口的点的矩阵变...

该博客介绍了一个LISP函数`xd::slide:->dwg`,用于将AutoCAD Slide (SLD) 文件转换为DWG格式。通过读取SLD文件的二进制数据,该函数解析线条信息并将其在CAD中以线条形式绘制出来,同时考虑了窗口比例和适应性调整。
摘要由CSDN通过智能技术生成

(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)

)

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值