lsjjm 发表于 2003-7-16 04:49:19

[分享]:用程序自动生成带属性的图框(标题栏)一例

用程序自动生成带属性的图框(标题栏)一例

(defun c:test ()
(load "lsplib")
(vl-cmdf "ucs" "w" "")
(setq index (load_dialog (findfile "dial.dcl")))   
(if (not (new_dialog "dtbl" index))(exit))
(imagep)
(action_tile "accept" "(setq pa (get_tile \"pa\"))
                         (setq to (get_tile \"to\"))
                         (setq e (get_tile \"e\"))
                         (setq p (get_tile \"p\"))
                         (setq l (get_tile \"l\"))
                         (done_dialog)")
(action_tile "cancel" "(exit)")
(start_dialog)
(unload_dialog index)
(setvar "osmode" 0)
(if (= (getvar "tilemode") 1)(setvar "tilemode" 0))
(mlayer "title_block" "cyan" "continous")
(setq rp1 '(0.0 0.1))
(if (= p "1")(setq rp2 '(7.08 10.9))(setq rp2 '(10.95 7.3)))
(setq        rtop (list (/ (car rp2) 2)(+ (cadr rp2) 0.03125)))
(vl-cmdf "rectangle" rp1 rp2)          
(vl-cmdf "rectangle" (polar rtop pi 0.6) "@1.2,0.1")
(vl-cmdf "text" "s" "romand" "j" "mc" (polar rtop (/ pi 2) 0.05) 0.07 0 "IF IN DOUBT -ASK!" "")
(vl-cmdf "chprop" (entlast) "" "c" 6 "")
(vl-cmdf "rectangle" rp2 "@-2.83,-0.315");;top num box
(vl-cmdf "line" "@2.611,0" "@0,0.315" "")
(vl-cmdf "text" "romand" "j" "tl" "@0.02,-0.02" 0.06 0 "REV")
(vl-cmdf "-style" "romand" "" "" 1.2 "" "" "" "")
(vl-cmdf "text" "j" "tl" "@-2.611,0" 0.06 0"NUMBER")
(vl-cmdf "ucs" "n" rp1 "")
(vl-cmdf "line" '(0 0.315) "@2.55,0" "" "line" "@1.7,0" "@2.83,0" "line" "@-0.219,0" "@0,-0.315" "")
(vl-cmdf "line" '(2.55 0) "@0,0.748" "line" "@-2.55,0" "@4.25,0" "")
(vl-cmdf "line" '(4.25 0) "@0,1.693" "@2.83,0" "")
(vl-cmdf "line" '(0 0.748) "@4.25,0" "")
(vl-cmdf "line" '(0.85 0.748) "@0,0.63" "")
(vl-cmdf "array" (entlast) "" "r" 1 4 0.85 "")
(vl-cmdf "line" '(0 0.9055) "@3.4,0" "")
(vl-cmdf "rectangle" '(0 1.063) '(7.08 1.378))
(vl-cmdf "line" '(6.062 1.063) "@0,0.63" "" "line" "@-1.182,0" "@0,-0.63" "" "line" "@0.482,0" "@0,0.315" "")
(vl-cmdf "line" '(4.25 1.5355) "@2.83,0" "" "line" "@-0.308,0.1575" "@0,-0.315" "")
(vl-cmdf "line" '(4.565 1.378) "@0,0.315" "")
(vl-cmdf "-style" "romand" "" "" 1 "" "" "" "")
(vl-cmdf "text" "j" "mc" '(1.275 0.26) 0.052 0 "This drawing is the Property of PARKER HANNIFIN Crop.")
(vl-cmdf "text" "j" "mc" '(1.275 0.17) 0.052 0 "Any use or reproduction except by expressed")
(vl-cmdf "text" "j" "mc" '(1.275 0.08) 0.052 0 "permission of PARKER HANNIFIN Crop. is Hereby Prohibited.")
(parkerlogo '(0 0.428))
(vl-cmdf "text" "s" "romand" "j" "mc" '(0.425 0.37) 0.06 0 "Fluid Connectors" "")
(vl-cmdf "change" (entlast) "" "p" "c" 6 "")
(vl-cmdf "-style" "romand" "" "" 1.1 "" "" "" "")
(vl-cmdf "text" "s" "romand" "j" "mc" '(1.73 0.67) 0.055 0 "Parker Hannifin (N.Z) Ltd.")
(vl-cmdf "text" "j" "mc" '(1.73 0.58) 0.055 0 "PO Box 14-906 Panmure")
(vl-cmdf "text" "j" "mc" '(1.73 0.49) 0.055 0 "3 Bowden Road Mt. Wellington")
(vl-cmdf "text" "j" "mc" '(1.73 0.4) 0.055 0 "Auckland, New Zealand")
(vl-cmdf "text" "j" "tl" '(6.881 0.295) 0.06 0 "REV")
(vl-cmdf "-style" "romand" "" "" 1 "" "" "" "")
(vl-cmdf "text" "j" "tl" '(2.58 0.55) 0.06 0"MUST CONFORM")
(vl-cmdf "text" "j" "tl" '(2.58 0.45) 0.06 0"TO HS-99,ES-99")
(vl-cmdf "text" "j" "tl" '(2.58 0.35) 0.06 0"ANGLE %%P1/2%%D")
(vl-cmdf "text" "j" "tl" '(2.58 0.17) 0.06 0"DIMENSIONS IN")
(vl-cmdf "text" "j" "mc" '(5.121 1.2205) 0.18 0"A4")
(vl-cmdf "change" (entlast) "" "p" "c" 6 "")
(setvar "cecolor" "bylayer")
(vl-cmdf "-style" "romand" "" "" 1.2 "" "" "" "")
(vl-cmdf "text" "j" "tl" '(2.57 0.728) 0.06 0 "TOLERANCE" "")
(vl-cmdf "text" "j" "mc" '(0.4252 0.8267) 0.06 0 "MATERIAL" "")
(vl-cmdf "text" "j" "mc" "@0.85,0" 0.06 0 "STOCK SIZE" "")
(vl-cmdf "text" "j" "mc" "@0.85,0" 0.06 0 "HEAT TREAT" "")
(vl-cmdf "text" "j" "mc" "@0.85,0" 0.06 0 "FINISH" "")
(vl-cmdf "text" "j" "tl" '(3.41 1.043) 0.06 0 "SCALE" "")
(vl-cmdf "text" "j" "tl" '(0.02 1.358) 0.06 0 "DRAWN" "")
(vl-cmdf "text" "j" "tl" "@0.85,0" 0.06 0 "DATE" "")
(vl-cmdf "text" "j" "tl" "@0.85,0" 0.06 0 "CHECKED" "")
(vl-cmdf "text" "j" "tl" "@0.85,0" 0.06 0 "DATE" "")
(vl-cmdf "text" "j" "tl" "@0.85,0" 0.06 0 "APPROVED" "")
(vl-cmdf "text" "j" "tl" "@0.85,0" 0.06 0 "DATE" "")
(project '(5.712 1.2205))
(vl-cmdf "text" "j" "mc" '(4.4095 1.4568) 0.06 0 "ECN" "")
(vl-cmdf "text" "j" "mc" "@0.315,0" 0.06 0 "REV""")
(vl-cmdf "text" "j" "mc" "@0.748,0" 0.06 0 "DESCRIPTION" "")
(vl-cmdf "text" "j" "mc" "@0.9448,0" 0.06 0 "DATE" "")
(vl-cmdf "text" "j" "mc" "@0.5085,0" 0.06 0 "BY" "")
(cond
    ((= pa "1")
      (vl-cmdf "text" "j" "tl" '(4.27 0.295) 0.06 0 "NUMBER")
      (vl-cmdf "text" "j" "tl" "@0,0.748" 0.06 0 "TITLE" ""))
    ((= to "1")
      (vl-cmdf "line" '(4.565 0) "@0,0.315" "")
      (vl-cmdf "text" "j" "tl" '(4.27 0.295) 0.06 0 "HAND")
      (vl-cmdf "text" "j" "tl" "@0.315,0" 0.06 0 "NUMBER")
      (vl-cmdf "text" "j" "tl" '(4.27 0.728) 0.06 0 "TITLE" "")
      (vl-cmdf "line" '(4.25 0.748) "@2.83,0" "" "line" "@0,0.1575" "@-2.83,0" "")
      (vl-cmdf "line" '(4.88 0.748) "@0,0.315" "" "line" "@1.57,0" "@0,-0.315" ""
                "line" "@0.315,0" "@0,0.315" "")
      (vl-cmdf "text" "j" "mc" '(4.565 0.8268) 0.06 0 "PART NO.")
      (vl-cmdf "text" "j" "mc" "@0,0.1575" 0.06 0 "ENDSTYLE")
      (vl-cmdf "text" "j" "mc" '(6.6075 0.8268) 0.06 0 "REV")
      (vl-cmdf "text" "j" "mc" "@0,0.1575" 0.06 0 "REV"))
);c
(vl-cmdf "-style" "romand" "" "" 1 "" "" "" "")
(vl-cmdf "ucs" "w" "")
(setvar "cecolor" "6")
(entmake '((0 . "block")(410 . "Layout1")(2 . "*U")(70 . 1)(10 0 0 0)))
(setq blkn (entmake '((0 . "ENDBLK"))))
(entmake (append '((0 . "INSERT")(10 0 0 0)(66 . 1)) (list (cons 2 blkn))))
(entmake '((0 . "ATTRIB")(1 . "K3D78-30-16C-AU")(2 . "Part Num")(7 . "Romand")
             (10 0 0 0)(11 5.65 0.14 0)(40 . 0.15)(70 . 0)(72 . 1)))
(entmake '((0 . "ATTRIB")(1 . "-")(2 . "Rev")(7 . "Romand")
             (10 0 0 0)(11 6.972 0.16 0)(40 . 0.08)(70 . 0)(72 . 1)))
(cond
    ((= to "1")
      (entmake '((0 . "ATTRIB")(1 . "INTERNAL RECESS")(2 . "Title1")(7 . "Romand")
               (10 0 0 0)(11 5.68 0.68 0)(40 . 0.13)(70 . 0)(72 . 1)))
      (entmake '((0 . "ATTRIB")(1 . "FRONT BARBS")(2 . "Titledown")(7 . "Romand")
               (10 0 0 0)(11 5.59 0.45 0)(40 . 0.13)(70 . 0)(72 . 1))))
   ((= to "0")
   (entmake '((0 . "ATTRIB")(1 . "")(2 . "Titletop")(7 . "Romand")
                 (10 0 0 0)(11 5.81 0.95 0)(40 . 0.14)(70 . 0)(72 . 1)))
   (entmake '((0 . "ATTRIB")(1 . "")(2 . "Title1")(7 . "Romand")
                (10 0 0 0)(11 5.68 0.75 0)(40 . 0.14)(70 . 0)(72 . 1)))
   (entmake '((0 . "ATTRIB")(1 . "")(2 . "Titledown")(7 . "Romand")
                (10 0 0 0)(11 5.59 0.5 0)(40 . 0.14)(70 . 0)(72 . 1))))
);c
(entmake '((0 . "ATTRIB")(1 . "")(2 . "Ecn") (7 . "Romand")
             (10 0 0 0)(11 4.408 1.675 0)(40 . 0.06)(70 . 0)(72 . 1)))
(entmake '((0 . "ATTRIB")(1 . "-")(2 . "Erev")(7 . "Romand")
             (10 0 0 0)(11 4.72 1.675 0)(40 . 0.06)(70 . 0)(72 . 1)))      
(entmake '((0 . "ATTRIB")(40 . 0.06)(1 . "")(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 5.468 1.675 0)(2 . "Description")(70 . 0)))
(entmake '((0 . "ATTRIB")(1 . "10/06/03")(2 . "Date")(7 . "Romand")
             (10 0 0 0)(40 . 0.06)(72 . 1)(11 6.41 1.675 0)(70 . 0)))
(entmake '((0 . "ATTRIB")(40 . 0.06)(1 . "")(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 6.92 1.675 0)(2 . "By")(70 . 0)))
(entmake '((0 . "ATTRIB")(1 . "JOHN.S")(40 . 0.08)(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 0.425 1.24 0)(2 . "Drawn")(70 . 0)))
(entmake '((0 . "ATTRIB")(1 . "09/06/03")(40 . 0.08)(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 1.275 1.24 0)(2 . "Date")(70 . 0)))
(entmake '((0 . "ATTRIB")(1 . "")        (40 . 0.08)(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 2.125 1.24 0)(2 . "Checked")(70 . 0)))
(entmake '((0 . "ATTRIB")(1 . "")(40 . 0.08)(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 2.975 1.24 0)(2 . "Date")(70 . 0)))
(entmake '((0 . "ATTRIB")(1 . "")(40 . 0.08)(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 3.825 1.24 0)(2 . "Approved")(70 . 0)))
(entmake '((0 . "ATTRIB")(40 . 0.08)(1 . "05/06/03")(7 . "Romand")
             (10 0 0 0)(11 4.565 1.24 0.0)(2 . "Date")(70 . 0)(72 . 1)))
(entmake '((0 . "ATTRIB")(40 . 0.06)(1 . "316L")(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 0.425 1.045 0)(2 . "Material")(70 . 0)))
(entmake '((0 . "ATTRIB")(40 . 0.06)(1 . "36mm AF HEX")(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 1.275 1.045 0)(2 . "Size")(70 . 0)))
(entmake '((0 . "ATTRIB")(40 . 0.06)(1 . "-")(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 2.125 1.045 0)(2 . "Heat")(70 . 0)))
(entmake '((0 . "ATTRIB")(40 . 0.06)(1 . "-")(7 . "Romand")
             (72 . 1)(10 0 0 0)(11 2.975 1.045 0)(2 . "Finish")(70 . 0)))
(entmake '((0 . "ATTRIB")(40 . 0.12)(1 . "NTS")(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 4.0 0.9 0)(2 . "Scale")(70 . 0)))
(entmake '((0 . "ATTRIB")(40 . 0.21)(1 . "INCH")(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 6.57 1.23 0)(2 . "Unit")(70 . 0)))
(entmake '((0 . "ATTRIB")(1 . "X.X%%P0.04")(2 . "x.x")(7 . "Romand")
             (10 0 0 0)(11 3.85 0.59 0)(40 . 0.06)(70 . 0)(72 . 1)))
(entmake '((0 . "ATTRIB")(1 . "X.XX%%P0.008")(2 . "x.xx")(7 . "Romand")
             (10 0 0 0)(11 3.85 0.49 0)(40 . 0.06)(70 . 0)(72 . 1)))
(entmake '((0 . "ATTRIB")(40 . 0.06)(1 . "X.XXX%%P0.004")(7 . "Romand")
             (10 0 0 0)(11 3.85 0.39 0)(2 . "x.xxx")(70 . 0)(72 . 1)))
(entmake '((0 . "ATTRIB")(40 . 0.06)(1 . "INCH")(7 . "Romand")
             (10 0 0 0)(72 . 1)(11 3.4 0.21 0)(2 . "UNIT")(70 . 0)))
(if (<= (car rp2) 7.08)
    (progn
      (entmake '((0 . "ATTRIB")(1 . "K3D78-30-16C-AU")(2 . "Part Num")(7 . "Romand")
               (10 0 0 0)(11 5.65 10.63 0)(40 . 0.15)(70 . 0)(72 . 1)))
      (entmake '((0 . "ATTRIB")(1 . "-")(2 . "Rev")(7 . "Romand")
               (10 0 0 0)(11 6.972 10.65 0)(40 . 0.08)(70 . 0)(72 . 1)))
      (entmake '((0 . "ATTRIB")(1 . "K3D78-30-16C-AU")(2 . "Part Num")(7 . "Romand")
               (10 7.15 2.0 0)(11 7.15 0.8 0)(40 . 0.15)(70 . 0)(72 . 5))))
    (progn
      (entmake '((0 . "ATTRIB")(1 . "K3D78-30-16C-AU")(2 . "Part Num")(7 . "Romand")
               (10 0 0 0)(11 5.65 7.03 0)(40 . 0.15)(70 . 0)(72 . 1)))
      (entmake '((0 . "ATTRIB")(40 . 0.08)(1 . "-")(7 . "Romand")
               (10 0 0 0)(11 6.962 7.05 0)(2 . "Rev")(70 . 0)(72 . 1))))
);i
(if (= to "1")
    (progn
      (entmake '((0 . "ATTRIB")(10 0 0 0)(40 . 0.1)(1 . "T")(7 . "Romand")
               (72 . 1)(11 4.4075 0.18 0)(2 . "Hand")(70 . 0)))
      (entmake '((0 . "ATTRIB")(10 0 0 0)(40 . 0.07)(1 . "K9170-6-6-AU")(7 . "Romand")
               (72 . 1)(11 5.665 1.054 0)(2 . "Part No")(70 . 0)))
      (entmake '((0 . "ATTRIB")(10 0 0 0)(40 . 0.07)(1 . "-")(7 . "Romand")
               (72 . 1)(11 6.9225 1.054 0)(2 . "Rev")(70 . 0)))
      (entmake '((0 . "ATTRIB")(10 0 0 0)(40 . 0.07)(1 . "D83,31-6")(7 . "Romand")
               (72 . 1)(11 5.665 0.897 0)(2 . "Endstyle")(70 . 0)))
      (entmake '((0 . "ATTRIB")(10 0 0 0)(40 . 0.07)(1 . "a")(7 . "Romand")
               (72 . 1)(11 6.9225 0.897 0)(2 . "Rev")(70 . 0))))
);I
(entmake '((0 . "SEQEND")))
(if (> (car rp2) 7.08)(vl-cmdf "move" (entlast) "" '(0 0) '(3.87 0) ""))
(vl-cmdf "-style" "romand" "" "" 1.0 "" "" "" "")
(setvar "cecolor" "bylayer")
(setvar "osmode" 37)
(princ)
);defun

lijiao 发表于 2003-7-16 08:41:34

太麻烦了,还是做一图块方便。

正航 发表于 2003-7-16 10:28:14

是啊。做一个图块更方便,而且可以不分解,绘图时不会和其它实体混在一起

eachy 发表于 2003-7-16 13:33:13

最初由 正航 发布
是啊。做一个图块更方便,而且可以不分解,绘图时不会和其它实体混在一起
用程序生成图块更方便,只要有程序就可以生成图块。

msdg 发表于 2003-7-16 14:26:50

??

pandoit 发表于 2003-7-16 16:20:47

楼主很辛苦,可惜我等实在看不懂,也不知道怎么用

lsjjm 发表于 2003-7-16 16:38:40

不好意思。请将以下程序码行删掉,既可运行(如果在模型空间运行会自动转向图纸空间)。

删掉:
;(load "lsplib")
;(imagep)
;(mlayer "title_block" "cyan" "continous")
(parkerlogo '(0 0.428))
;(project '(5.712 1.2205))

另复制一对话框文件:dial.dal
dtbl : dialog {label = "Title Block";
: row {
    : radio_column {label = "Type:";
      : radio_button {label = "Part"; key = "pa"; value = "1";}
      : radio_button {label = "Tool"; key = "to";}
      : radio_button {label = "EDM"; key = "e";}
    } spacer;
    : radio_column {label = "Orientation:";
      : radio_button {label = "Po&rtrait"; key = "p"; value = "1";}
      : radio_button {label = "La&ndscape"; key = "l";}
      spacer; spacer; spacer;
    }
}
spacer;
ok_cancel;
: row {
    : image { key = "im" ; width = 4; fixed_width= true;}
    : paragraph {
      : text_part { label = "Designed and Created";alignment=right;}
      : text_part { label = "by Richard Liang";alignment=right;}
    }
}
}

msdg 发表于 2003-7-16 17:34:58

按提示进行改动,并将“另复制一对话框文件:dial.dal”中的DAL改为DCL文件,移到SUPPORT文件夹中,运行后出现下图:按确定后有点动静。但“未知命令”提示重复出现。
能否详细说说?

lsjjm 发表于 2003-7-16 17:49:21

dial.dal 应该是dial.dcl。
我刚在家又试了,可以呀,你再试试?有什么问题请告。

eachy 发表于 2003-7-17 02:03:55

**** Hidden Message *****

aeo 发表于 2003-7-17 08:26:22

图框每个地方的都不一样,要程序写出来,不可能.
自己的图框,画一遍存好就可以了.当然也要属性.
所以需要的不是画,而是改.

我写的我们院的

hqd9639 发表于 2003-7-17 11:17:52

有关图框及初始化的程序没有一个能通用的,所以还是自已写好些。

sqmjk 发表于 2003-7-20 14:30:47

学到了一种思路

sqmjk01 发表于 2003-7-25 12:43:58

图框及初始化的程序不难写,还是自己写吧

bridgewind 发表于 2003-8-25 10:05:13

同意15楼,还是自己写!
页: [1] 2 3 4 5 6
查看完整版本: [分享]:用程序自动生成带属性的图框(标题栏)一例