找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

楼主: urljit

[LISP程序]:如何让lsp找到dcl文件

[复制链接]
发表于 2003-8-29 18:06:08 | 显示全部楼层
最初由 aeo 发布
[B]其实如果dcl比较简单,可以在lisp里定义一个变量.直接就用了.
这样就省掉了dcl.
自己研究吧.我以前看过这样的程序. [/B]


用 OPEN FILLE "W"
然後再寫入
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-9-1 08:52:15 | 显示全部楼层
16楼能具体说说吗?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-12-10 15:31:07 | 显示全部楼层
我明白了:就是每次运行时生成新的dcl文件。好办法!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-12-11 10:16:11 | 显示全部楼层
看我的一个带有问题(征解)的小例子:
http://www.xdcad.net/forum/showthread.php?s=&threadid=120834
运行时生成DCL文件还有一个更大的妙用,就是可以使用动态的对话框,满足一些需要对话框有较多变化的要求。
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-12-11 10:34:46 | 显示全部楼层
最初由 coolzhb 发布
[B]

我也看见过,一个lisp程序,运行时出现dcl,... [/B]



一个把DCL写在LISP里面的属性编辑程序:


  1.   [FONT=courier new]
  2. (defun c:dclatt ( / theblock thelist n taglist txtlist lg fname fn nu dcl_id l relist)

  3. ;load the visual lisp extensions
  4. (vl-load-com)

  5. ;get the entity and entity name
  6. (setq theblock (car (entsel)))

  7. ;convert to vl object
  8. (setq theblock (vlax-ename->vla-object theblock))

  9. ;check if it's a block
  10. (if (= (vlax-get-property theblock 'ObjectName) "AcDbBlockReference")

  11.         ;if it is, do the following
  12.         (progn

  13.                 ;check if it has attributes
  14.                 (if (= (vlax-get-property theblock 'HasAttributes) :vlax-true)

  15.                      ;if it has attributes, do the following
  16.                      (progn

  17.                         ;get the attributes
  18.                         (getatt theblock)

  19.                         ;create the dialog
  20.                         (create_dialog)

  21.                         ;run the dialog
  22.                         (run_the_dialog)

  23.                         ;update the attributes
  24.                         (upatt)

  25.                      );progn

  26.                         ;No attributes, inform the user
  27.                         (alert "This Block has No Attributes!! - Please try again.")
  28.                 );if

  29.         );progn

  30.         ;it's not a block, inform the user
  31.         (alert "This is not a Block!! - Please try again.")

  32. );if

  33. (princ)

  34. );defun

  35. ------------------------

  36. (defun getatt (enam)

  37. ;retrieve the attributes
  38. (setq thelist (vlax-safearray->list
  39.                  (variant-value
  40.                         (vla-getattributes enam))))

  41.          ;process each attribute
  42.          (foreach n thelist

  43.            ;get the tag attribute data
  44.            (setq taglist (cons (vla-get-tagString n) taglist)

  45.            ;get the text attribute data
  46.                     txtlist (cons (vla-get-textString n) txtlist)

  47.                  ;how many attributes?
  48.                  lg (length taglist)

  49.            );setq
  50.          );foreach

  51.          ;reverse the lists
  52.          (setq taglist (reverse taglist) txtlist (reverse txtlist))

  53. );defun
  54. -------------------------
  55. (defun create_dialog ()

  56. ;create a temp DCL file
  57. (setq fname (vl-filename-mktemp "dcl.dcl"))

  58. ;open it to write
  59. (setq fn (open fname "w"))

  60. ;write the dialog header coding
  61. (write-line "temp : dialog { label = "Edit Attributes";" fn)

  62. ;reset the incremental control number
  63. (setq nu 0)

  64. ;start the loop to create the edit boxes
  65. (repeat lg

  66. ;create the edit boxes
  67. (write-line ": edit_box {" fn)
  68. (setq l (strcat """ "eb" (itoa nu) """ ";"))
  69. (write-line (strcat "key = " l)  fn)
  70. (setq l (nth nu taglist))
  71. (write-line (strcat "label = " """ l """ ";") fn)
  72. (setq l (nth nu txtlist))
  73. (write-line (strcat "value = " """ l """ ";") fn)
  74. (write-line "alignment = centered; edit_width = 20; }" fn)

  75. ;increment the counter
  76. (setq nu (1+ nu))

  77. );repeat

  78. ;ok and cancel button
  79. (write-line "ok_only; }" fn)

  80. ;close the temp DCL file
  81. (close fn)

  82. );defun
  83. ------------------------------

  84. (defun run_the_dialog ()

  85. ;load the dialog file and definition
  86. (setq dcl_id (load_dialog fname))
  87.      (if (not (new_dialog "temp" dcl_id))
  88.          (exit )
  89.      );if

  90. (mode_tile "eb0" 2)

  91. ;if the OK button is selected
  92. (action_tile "accept" "(retatt)")


  93. ;start the dialog
  94. (start_dialog)

  95. ;unload the dialog
  96. (unload_dialog dcl_id)

  97. ;delete the temp DCL file
  98. (vl-file-delete fname)

  99. );defun
  100. ---------------------------

  101. (defun retatt ()

  102. ;reset the increment counter
  103. (setq nu 0)

  104. start the loop
  105. (repeat lg

  106.         ;retrieve the tile value
  107.         (setq l (get_tile (strcat "eb" (itoa nu))))

  108.         ;add it to the list
  109.         (setq relist (cons l relist))

  110.         ;increment the counter
  111.         (setq nu (1+ nu))

  112. );repeat

  113. (setq relist (reverse relist))

  114. ;close the dialog
  115. (done_dialog)

  116. );defun
  117. -----------------------------------------

  118. (defun upatt ()

  119. ;reset the increment counter
  120. (setq nu 0)

  121. ;start the loop
  122. (repeat lg

  123.   ;update the attribute
  124.   (vla-put-textstring (nth nu thelist) (nth nu relist))

  125.   ;increment the counter
  126.   (setq nu (1+ nu))

  127. );repeat

  128. ;update the block
  129. (vla-update theblock)

  130. );defun
  131.   [/FONT]
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-12-12 11:03:33 | 显示全部楼层
很好,可是我还没有进行过vlisp编程,但能看懂大概,感谢!
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

发表于 2003-12-12 11:18:40 | 显示全部楼层

Re: [LISP程序]:如何让lsp找到dcl文件

最初由 urljit 发布
[B]我自己编辑了一个lsp文件,能运行dcl了,很高兴。但朋友用了说,如果不在搜索路径中就找不到dcl,能不能让lsp和dcl在同一个目录中,虽然不是搜索路径,可lsp能找到dcl呢?
望高手指点。敬礼! [/B]


11楼的 findfile是正解, REFER TO:
  (if (findfile "dial.dcl")(setq index (load_dialog (findfile "dial.dcl"))))
   ...
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-12-12 11:26:23 | 显示全部楼层

Re: Re: [LISP程序]:如何让lsp找到dcl文件

要求不是搜索路径但能找到dcl,findfile还可以吗?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

 楼主| 发表于 2003-12-15 11:06:10 | 显示全部楼层
最初由 hxj111111 发布
[B]okokok [/B]

ok那就是能吗?
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|申请友链|Archiver|手机版|小黑屋|辽公网安备|晓东CAD家园 ( 辽ICP备15016793号 )

GMT+8, 2025-9-26 19:18 , Processed in 0.214677 second(s), 40 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表