[求助]斑竹 。帮忙编个程序好吗??
背面是图幅
通过 点击 “图幅对话框”的 确定 来 将 一张图幅插入的CAD中。 A0 A1 A2...............代表的是 固定大小尺寸的 图幅
分 “横向 纵向” 总共14张。
例如: 点击 A1 纵向 后这是一张图, 当点击 不同的 比例时 这张图幅 随着 所选的 比例 变化。
就是这个 要求。。谢谢斑竹
这样的程序应该不太困难,给个思路,最好你自己亲自编程
首先你可以手工制作14张图并以不同的文件名存盘。在用户点击“确定”后,根据图幅、方向控件组中各控件值来决定插入不同的存盘文件,根据比例输入决定插入的比例。你若熟悉LISP语言的话,很容易编写出自己的程序。若还不太熟悉LISP,也应该利用LISP帮助尝试自己编程。你已经能够编写不错的DCL,可以循序渐近地学习LISP语言了。在编程过程中有什么具体问题,欢迎继续提问。
斑竹 我自己也编了一段 但是 怎么让图幅随所选比例插入不会
本帖最后由 作者 于 2003-5-14 13:55:45 编辑斑竹我自己也编了一段但是 怎么让图幅随所选比例插入不会写。请指教!!谢谢!1[求助]请你看一下 请 指教图幅随所选比例插入 这段代码怎么写?
Re:
我不是学机械的,对于不同的比例,图幅有什么不同,我不太清楚。但是我认为你能回答这个问题,把比例和图幅的关系整理出来并数学化,然后将数学语言转换成程序设计语言,这就是通常的算法设计方法。我现没ACAD,没看你的程序,但我想可以如内解决
1、如果用leeyeafu的思路,则使用图块插入命令把图框作为图块插入,插入命令有比例选项。2、如果是用程序完成绘图过程,则首先确定一个基准点,然后用实际尺寸X比例因子所得的数值来计算其余点的坐标。
不知现在回答是否有些晚? 这个程序好做,可以参照教程。 我的工具中有这个程序,只和你的要求有一点点不同
LISP代码给你,也可以在LISP中去找,以前我发过
;这是一个基于AutoCad 14.0下关于图框的插入的程序
;它可以插入A0-A4的图框;同时删除以前的图框
;本程序作者b.w
;本程序无偿使用
;如有更好建议,请联系b.w
;版本:1.1.00
;日期:27/12-2001
(cond
((and ai_dcl (listp ai_dcl))) ; it's already loaded.
((not (findfile "ai_utils.lsp")) ; find it
(ai_abort "DDMODIFY"
(strcat "Can't locate file AI_UTILS.LSP."
"\n Check support directory.")))
((eq "failed" (load "ai_utils" "failed")) ; load it
(ai_abort "DDMODIFY" "Can't load file AI_UTILS.LSP"))
)
(defun B_DRAWING_HILITE
(
B_drawing_tile
/
)
(if (/= B_drawing_last_slide B_drawing_tile)
(progn
(mode_tile B_drawing_tile 4)
(if (/= B_drawing_last_slide nil)
(mode_tile B_drawing_last_slide 4)
);end-if
);end-progn
);end-if
(setq B_drawing_last_slide B_drawing_tile)
);end-B_DRAWING_HILITE
(defun B_DRAWING_STAR;启动幻灯片
(
/
)
(foreach B_DRAWING '("B_DRAWING_A4" "B_DRAWING_A3" "B_DRAWING_A2" "B_DRAWING_A1" "B_DRAWING_A0" "B_DRAWING_A4_ZP" "B_DRAWING_A3_ZP" "B_DRAWING_A2_ZP" "B_DRAWING_A1_ZP" "B_DRAWING_A0_ZP"
);对幻灯片库中的各幻灯片建立图象
(start_image B_DRAWING)
(slide_image 0 0 (dimx_tile B_DRAWING) (dimy_tile B_DRAWING) (strcat "B_DRAWING("B_DRAWING")")
);end-silde_image从幻灯片库中调入幻灯片
(end_image)
);end-foreach
);end-B_DRAWING_STAR
(defun B_DRAWING_INIT;起动DCL,选择图框并分别赋值
(
/
B_drawing_id
B_drawing_old_cmd
stat
)
(setq B_drawing_old_cmd (getvar "CMDECHO"))
(setvar "CMDECHO" 0)
(setq B_drawing_id (load_dialog "B_DRAWING"));装入B_DRAWING.DCL
(if (not (new_dialog "B_DRAWING" B_drawing_id))
(exit)
);end-if
(B_DRAWING_STAR)
(setq stat 0)
(set_tile "B_DRAWING_SCALE_DCL"(ai_rtos (setq B_drawing_scale 1.0)))
(set_tile "B_DRAWING_A4" (ai_rtos (setq stat 10104)))
(action_tile "B_DRAWING_A4" "(B_DRAWING_HILITE B_DRAWING_A4) (setq stat 10104)")
(action_tile "B_DRAWING_A3" "(B_DRAWING_HILITE B_DRAWING_A3) (setq stat 10103)")
(action_tile "B_DRAWING_A2" "(B_DRAWING_HILITE B_DRAWING_A2) (setq stat 10102)")
(action_tile "B_DRAWING_A1" "(B_DRAWING_HILITE B_DRAWING_A1) (setq stat 10101)")
(action_tile "B_DRAWING_A0" "(B_DRAWING_HILITE B_DRAWING_A0) (setq stat 10100)")
(action_tile "B_DRAWING_A4_ZP" "(B_DRAWING_HILITE B_DRAWING_A4_ZP) (setq stat 10114)")
(action_tile "B_DRAWING_A3_ZP" "(B_DRAWING_HILITE B_DRAWING_A3_ZP) (setq stat 10113)")
(action_tile "B_DRAWING_A2_ZP" "(B_DRAWING_HILITE B_DRAWING_A2_ZP) (setq stat 10112)")
(action_tile "B_DRAWING_A1_ZP" "(B_DRAWING_HILITE B_DRAWING_A1_ZP) (setq stat 10111)")
(action_tile "B_DRAWING_A0_ZP" "(B_DRAWING_HILITE B_DRAWING_A0_ZP) (setq stat 10110)")
(action_tile "B_DRAWING_SCALE_DCL" "(setq B_drawing_scale (distof $value))")
(action_tile "cancel" "(done_dialog)(exit)")
(action_tile "accept" "(done_dialog stat)");初始化ACCDPT
(setq B_drawing_what (start_dialog))
(setvar "USERR1" B_drawing_scale)
(cond
((= B_drawing_what 10100)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A0")
(setq B_drawing_date_x (* B_drawing_scale 999.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 10.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10101)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A1")
(setq B_drawing_date_x (* B_drawing_scale 651.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 10.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10102)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A2")
(setq B_drawing_date_x (* B_drawing_scale 404.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 10.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10103)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A3")
(setq B_drawing_date_x (* B_drawing_scale 235.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 5.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10104)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A4")
(setq B_drawing_date_x (* B_drawing_scale 25.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 5.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10110)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A0_ZP")
(setq B_drawing_date_x (* B_drawing_scale 999.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 10.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10111)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A1_ZP")
(setq B_drawing_date_x (* B_drawing_scale 651.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 10.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10112)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A2_ZP")
(setq B_drawing_date_x (* B_drawing_scale 404.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 10.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10113)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A3_ZP")
(setq B_drawing_date_x (* B_drawing_scale 235.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 5.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
((= B_drawing_what 10114)
(setvar "USERI1" 1)
(setq B_drawing_name "*B_DRAWING_A4_ZP")
(setq B_drawing_date_x (* B_drawing_scale 25.0))
(setq B_drawing_date (list B_drawing_date_x (* B_drawing_scale 5.0) 0.0))
(setq B_drawing_x_scale 1)
(setq B_drawing_y_scale 1)
)
);end-cond
);end-B_DRAWING_INIT
(defun B_DRAWING_INS;无图框时插入图框
(
/
)
(if (null B_INITVAR_SYS) (load "B_INITVAR_SYS"))
(B_INITVAR_SYS)
(setvar "OSMODE" 0)
(command "insert" B_drawing_name "0,0,0" B_drawing_scale "0")
(command "zoom" "e")
(setvar "ATTDIA" 1)
(setq B_drawing_date_layer (getvar "CLAYER"))
(if (tblsearch "layer" "P_TEMPLATE")
(setvar "CLAYER" "P_TEMPLATE")
);end-if
(command "insert" "B_DRAWING_DATA" B_drawing_date B_drawing_date_scale_x0 B_drawing_date_scale_y0 "0")
(setvar "CLAYER" B_drawing_date_layer)
(setvar "OSMODE" 51)
);end-B_DRAWING_INS
(defun B_DRAWING_CHANGE;更改图框
(
/
B_drawing_block_sset
B_drawing_attrib_ent
B_drawing_attrib_data
B_drawing_attrib_list
B_drawing_dwgset
B_drawing_attrib_input
)
(if (ssget "x" (list (cons 0 "INSERT") (cons 2 "B_DRAWING_DATA")))
(progn
(setq B_drawing_block_sset (ssget "x" (list (cons 0 "INSERT") (cons 2 "B_DRAWING_DATA"))))
(setq B_drawing_attrib_ent (entnext (ssname B_drawing_block_sset 0)))
(while (/= (cdr (assoc 0 (entget B_drawing_attrib_ent))) "SEQEND")
(setq B_drawing_attrib_data (cdr (assoc 1 (entget B_drawing_attrib_ent))))
(setq B_drawing_attrib_list (append B_drawing_attrib_list (list B_drawing_attrib_data)))
(setq B_drawing_attrib_ent (entnext B_drawing_attrib_ent))
);end-while取B_DRAWING_DATA块的属性值
(setq B_drawing_dwgset (ssget "x" (list (cons 8 "P_TEMPLATE"))))
(if B_drawing_dwgset
(command "erase" B_drawing_dwgset B_drawing_block_sset "")
(command "erase" B_drawing_block_sset "")
);end-if
(setvar "OSMODE" 0)
(command "insert" B_drawing_name "0,0,0" B_drawing_scale "0")
(command "zoom" "e")
(setvar "attdia" 0)
(setq B_drawing_date_layer (getvar "CLAYER"))
(if (tblsearch "layer" "P_TEMPLATE")
(setvar "CLAYER" "P_TEMPLATE")
);end-if
(command "insert" "B_DRAWING_DATA" B_drawing_date B_drawing_date_scale_x0 B_drawing_date_scale_y0 "0")
(setvar "OSMODE" 51)
(while B_drawing_attrib_list
(setq B_drawing_attrib_input (car B_drawing_attrib_list))
(setq B_drawing_attrib_list (cdr B_drawing_attrib_list))
(command B_drawing_attrib_input)
);end-while
);end-progn
(progn
(setq B_drawing_dwgset (ssget "x" (list (cons 8 "P_TEMPLATE"))))
(if B_drawing_dwgset
(command "erase" B_drawing_dwgset "")
);end-if
(setvar "OSMODE" 0)
(command "insert" B_drawing_name "0,0,0" B_drawing_scale "0")
(command "zoom" "e")
(setvar "attdia" 1)
(setq B_drawing_date_layer (getvar "CLAYER"))
(if (tblsearch "layer" "P_TEMPLATE")
(setvar "CLAYER" "P_TEMPLATE")
);end-if
(command "insert" "B_DRAWING_DATA" B_drawing_date B_drawing_date_scale_x0 B_drawing_date_scale_y0 "0")
(setvar "OSMODE" 51)
);end-progn
);end-if
(setvar "CLAYER" B_drawing_date_layer)
(setvar "attdia" 1)
);end-B_DRAWING_CHANGE
(defun B_DIM_INS;无标注时插入标注
(
/
)
(B_INITVAR_DIM)
(setvar "DIMTIH" 1)
(setvar "DIMTOH" 1)
(setvar "DIMFIT" 2)
(command "dimstyle" "S" (strcat B_drawing_dim "$3"))
(command "dimstyle" "S" (strcat B_drawing_dim "$4"))
(setvar "DIMFIT" 3)
(setvar "DIMTIH" 0)
(setvar "DIMTOH" 0)
(command "dimstyle" "S" B_drawing_dim)
);end-B_DIM_INS
(defun B_DIM_MAKE;循环更改标注
(
B_drawing_den_sset
B_dim_before
B_dim_after
/
B_drawing_dim_sset_list
B_dim_repeat_i
)
(setq B_dim_repeat_i 0)
(repeat (sslength B_drawing_den_sset)
(setq B_drawing_dim_sset_list (entget (ssname B_drawing_den_sset B_dim_repeat_i)))
(cond
((= (cdr (assoc 3 B_drawing_dim_sset_list)) B_dim_before)
(setq B_drawing_dim_sset_list (subst (cons 3 B_dim_after) (assoc 3 B_drawing_dim_sset_list) B_drawing_dim_sset_list))
)
((= (cdr (assoc 3 B_drawing_dim_sset_list)) (strcat B_dim_before "$3"))
(setq B_drawing_dim_sset_list (subst (cons 3 (strcat B_dim_after "$3")) (assoc 3 B_drawing_dim_sset_list) B_drawing_dim_sset_list))
)
((= (cdr (assoc 3 B_drawing_dim_sset_list)) (strcat B_dim_before "$4"))
(setq B_drawing_dim_sset_list (subst (cons 3 (strcat B_dim_after "$4")) (assoc 3 B_drawing_dim_sset_list) B_drawing_dim_sset_list))
)
);end-cond
(entmod B_drawing_dim_sset_list)
(setq B_dim_repeat_i (1+ B_dim_repeat_i))
);end-repeat
);end-B_DIM_MAKE
(defun B_DIM_CHANGE;更改标注
(
/
B_drawing_dim_sset
B_drawing_lea_sset
B_drawing_tol_sset
B_dim_repeat_i
B_drawing_dim_t
)
(setq B_drawing_dim_sset (ssget "x" (list (cons 0 "DIMENSION") (cons 3 (strcat B_drawing_dim "*")))))
(setq B_drawing_lea_sset (ssget "x" (list (cons 0 "LEADER") (cons 3 (strcat B_drawing_dim "*")))))
(setq B_drawing_tol_sset (ssget "x" (list (cons 0 "TOLERANCE") (cons 3 (strcat B_drawing_dim "*")))))
(setq B_drawing_dim_t (or B_drawing_dim_sset B_drawing_lea_sset B_drawing_tol_sset))
(if B_drawing_dim_t
(progn
(command "dimstyle" "S" (strcat B_dim_temp "$3"))
(command "dimstyle" "S" (strcat B_dim_temp "$4"))
(command "dimstyle" "S" B_dim_temp)
(if B_drawing_dim_sset
(B_DIM_MAKE B_drawing_dim_sset B_drawing_dim B_dim_temp)
);end-if
(if B_drawing_lea_sset
(B_DIM_MAKE B_drawing_lea_sset B_drawing_dim B_dim_temp)
);end-if
(if B_drawing_tol_sset
(B_DIM_MAKE B_drawing_tol_sset B_drawing_dim B_dim_temp)
);end-if
(command "dimstyle" "r" "STANDARD")
(command "purge" "d" (strcat B_drawing_dim "$3") "n")
(command "purge" "d" (strcat B_drawing_dim "$4") "n")
(command "purge" "d" B_drawing_dim "n")
(B_INITVAR_DIM)
(setvar "DIMTIH" 1)
(setvar "DIMTOH" 1)
(setvar "DIMFIT" 2)
(command "dimstyle" "S" (strcat B_drawing_dim "$3"))
(command "dimstyle" "S" (strcat B_drawing_dim "$4"))
(setvar "DIMFIT" 3)
(setvar "DIMTIH" 0)
(setvar "DIMTOH" 0)
(command "dimstyle" "S" B_drawing_dim)
(if (/= B_drawing_lea_sset nil)
(B_DIM_MAKE B_drawing_lea_sset B_dim_temp B_drawing_dim)
);end-if
(if (/= B_drawing_dim_sset nil)
(B_DIM_MAKE B_drawing_dim_sset B_dim_temp B_drawing_dim)
);end-if
(if (/= B_drawing_tol_sset nil)
(B_DIM_MAKE B_drawing_tol_sset B_dim_temp B_drawing_dim)
);end-if
(command "purge" "d" (strcat B_dim_temp "$3") "n")
(command "purge" "d" (strcat B_dim_temp "$4") "n")
(command "purge" "d" B_dim_temp "n")
);end-progn
(progn
(command "dimstyle" "r" "STANDARD")
(command "purge" "d" (strcat B_drawing_dim "$3") "n")
(command "purge" "d" (strcat B_drawing_dim "$4") "n")
(command "purge" "d" B_drawing_dim "n")
(B_INITVAR_DIM)
(setvar "DIMTIH" 1)
(setvar "DIMTOH" 1)
(setvar "DIMFIT" 2)
(command "dimstyle" "S" (strcat B_drawing_dim "$3"))
(command "dimstyle" "S" (strcat B_drawing_dim "$4"))
(setvar "DIMFIT" 3)
(setvar "DIMTIH" 0)
(setvar "DIMTOH" 0)
(command "dimstyle" "S" B_drawing_dim)
);end-progn
);end-if
);end-B_DIM_CHANGE
(defun B_DRAWING
(
/
B_drawing_what
B_drawing_name
B_drawing_exist
B_drawing_last_slide
B_drawing_tile
B_drawing_date
B_drawing_scale
B_drawing_date_x
B_drawing_x_scale
B_drawing_y_scale
B_drawing_date_scale_x0
B_drawing_date_scale_y0
B_drawing_date_layer
B_drawing_dim
B_dim_temp
)
(setvar "ATTDIA" 1)
(B_DRAWING_INIT)
(if (null B_INITVAR_DIM) (load "B_INITVAR_DIM"))
(setq B_drawing_dim "B_DRAWING_DIM")
(setq B_dim_temp "B_DIM_TEMP")
(if (= (tblsearch "DIMSTYLE" B_drawing_dim) nul)
(B_DIM_INS)
(B_DIM_CHANGE)
);end-if
(setq B_drawing_date_scale_x0 (* B_drawing_scale B_drawing_x_scale))
(setq B_drawing_date_scale_y0 (* B_drawing_scale B_drawing_y_scale))
(setq B_drawing_exist (tblsearch "BLOCK" "B_DRAWING_DATA"))
(if B_drawing_exist
(B_DRAWING_CHANGE)
(B_DRAWING_INS)
);end-if
(setvar "ORTHOMODE" 1)
(setvar "ATTDIA" 1)
(princ)
);end-B_DRAWING 根据我这多年的经验,计算程序都好做,但设计一个项目就难多了
趁年轻,还是多做项目吧!项目做多了,你就对程序不敢兴趣了 我个人认为用VB编这个程序更直观简单
页:
[1]