马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
本帖最后由 newer 于 2016-12-9 20:05 编辑
最近接个活,要做1万8千个点的63公里的高速路的用地坐标标注,100多张1号图,不是人干的活,写了个程序,几秒钟编号,表格生成完毕,交给同事布置图面出图。
工作中,布置图面也是一种累人的活,又写了个工具,逐步完善到选择边界根据图面空白地方自动把表格排好. 好多人几个月的工作量几天就完成了。
本程序不只是支持ACAD的TABLE实体,还支持TABLE变成块后的实体(图块),因为工作中发现,几百行的表格ACAD打开图就很慢了,再多基本就打不开图了,所以把表格变成了图块,打开图快多了。
[sell](defun c:XDTB_TableBrk (/ brkHeight brkSpacing datarows direc e e1 e2 ee g h
i in insert ints j key nums p1 p2 pt pts rc row
rows start str tf vx w x
)
(defun _prompt ()
(xdrx_prompt "\n当前模式: " (cond
((= #table_brk_mode 0)
"按行"
)
((= #table_brk_mode 1)
"手描边界"
)
(t
"选边界"
)
)
)
)
(defun _keyword (key)
(setq tf nil)
(cond
((= key "RO")
(setq #table_brk_mode 0)
)
((= key "LI")
(setq #table_brk_mode 1)
)
((= key "SE")
(setq #table_brk_mode 2)
)
)
(_prompt)
)
(defun _brk (e1 row tf)
(setq e2 (xdrx_entity_copy e1)
e2 (entlast)
start row
rows (xdrx_table_numrows e1)
datarows (xdrx_table_NumDataRows e1)
brkHeight (xdrx_table_breakheight e1 0)
brkSpacing (xdrx_table_breakSpacing e1)
w (xdrx_table_width e1)
h (xdrx_table_height e1)
vx (xdrx_table_direction e1)
p1 (xdrx_getpropertyvalue e1 "position")
)
(xdrx_table_deleteRows e1 start rows)
(xdrx_table_deleteRows e2 (cadr datarows) (- start 2))
(if (not brkheight)
(setq p2 (mapcar
'+
p1
(xdrx_vector_product vx (+ w (/ w 10.0)))
)
)
(progn
(setq nums (+ 1 (fix (/ h brkheight)))
p2 (mapcar
'+
p1
(xdrx_vector_product vx (+ (* nums w) (* (- nums 1)
brkspacing
) brkspacing
)
)
)
)
)
)
(xdrx_entity_move e2 p1 p2)
(if tf
(progn
(mapcar
'(lambda (x)
(setq str (xdrx_getpropertyvalue x "handle"))
(xdrx_block_make (strcat "XTABLE-" str) x
(xdrx_getpropertyvalue x "position") t
)
)
(list e1 e2)
)
)
)
(setq e1 (entlast))
)
(xdrx_begin)
(xdrx_sysvar_push '("osmode" 0))
(if (not #table_brk_mode)
(setq #table_brk_mode 0)
)
(_prompt)
(xdrx_initssget "\n请拾取要拆分的表格[按行[(RO)/手描断线(LI)/选边界(SE)]<退出>:"
"RO LI SE" "" "_KEYWORD"
)
(if (and
(setq e (xdrx_ssget ":E:S" '((-4 . "<or") (-4 . "<and")
(0 . "INSERT")
(2 . "*TABLE-*")
(-4 . "and>")
(0 . "ACAD_TABLE")
(-4 . "or>")
)
)
)
(setq e1 (ssname e 0))
)
(progn
(cond
((= #table_brk_mode 0)
(setq pt (getpoint "\n点取要拆分的行<退出>:"))
(setq pt (trans pt 1 0))
(if (not (xdrx_object_isa e1 "AcDbTable"))
(setq e1 (xdrx_entity_explode e1 t)
e1 (entlast)
tf t
)
)
(if (setq rc (xdrx_table_hittest e1 pt '(0 0 1.0) 1.0 1.0))
(progn
(_brk e1 (car rc) tf)
)
)
)
((= #table_brk_mode 1)
(if (setq pts (xd::doc:getfence "打断线第一点" "下一点" 1))
(progn
(setq insert e1)
(setq pts (xd::pnts:ucs2wcs pts)
g (xdge::constructor "kcompositecrv3d" pts)
)
(xdrx_statusbar_begin "处理中" 20)
(setq i 0)
(while (and
(progn
(if (not (xdrx_object_isa e1 "AcDbTable"))
(setq e1 (xdrx_entity_explode e1 t)
e1 (entlast)
tf t
)
t
)
)
(setq ints (xdrx_entity_intersectwith e1 g))
)
(xdrx_statusbar_setpos (setq i (1+ i)))
(setq rc (xdrx_table_hittest e1 (car ints) '(0 0 1) 1 1))
(setq e1 (_brk e1 (car rc) tf))
)
(xdrx_statusbar_end)
(xdge::free g)
)
)
)
(t
(if (and
(setq ee (car (xdrx_entsel "\n选取拆分边界<退出>:" '
((0 . "*LINE,ARC,SPLINE"))
)
)
)
(setq g (xdge::constructor ee))
)
(progn
(xdrx_statusbar_begin "处理中" 20)
(setq j 0)
(xdge::entity:make g)
(setq i 0)
(while (and
(progn
(if (not (xdrx_object_isa e1 "AcDbTable"))
(setq e1 (xdrx_entity_explode e1 t)
e1 (entlast)
tf t
)
t
)
)
(setq ints (xdrx_entity_intersectwith e1 g))
)
(xdrx_statusbar_setpos (setq i (1+ i)))
(setq direc (xdrx_curve_getfirstderiv ee (car ints)))
(if (and
(> (xdrx_vector_angle direc) PI)
(< (xdrx_vector_angle direc) (* 2 PI))
)
(setq in (car ints))
(setq in (last ints))
)
(setq rc (xdrx_table_hittest e1 in '(0 0 1) 1 1))
(setq e1 (_brk e1 (car rc) tf))
)
(xdrx_statusbar_end)
(xdge::free g)
)
)
)
)
)
)
(xdrx_sysvar_pop)
(xdrx_end)
(princ)
)
[/sell]
|