找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 570|回复: 3

[求助] [求助]:如何把下面用l的函数用ActiveX的方法实现

[复制链接]
发表于 2005-12-9 11:14:29 | 显示全部楼层 |阅读模式

马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。

您需要 登录 才可以下载或查看,没有账号?立即注册

×
因为我在工程中加了一个反应器,在反应器中回调这个函数,
但这个函数中调用了AutoCAD命令,反应器中不支持,
所以我想把下面函数实现的功能用ActiveX方法来实现,
由于不太熟练,时间又不多,就想到了这里,
请大家帮帮我,有对ActiveX较熟的,有时间帮我翻译一下,
谢谢!!
;******************************************************************
;*函 数 名:  fkqd_showtext ()                                        ;*
;*功    能:  显示圈定范围内的储量以及其它信息 ;*
;*说    明:  ptInsert:插入基点(圆心)                        ;*
;*           all_dzksl    :地质矿石量    all_scksl  :生产矿石量   ;*
;*           dzfepw       ;地质Fe品位    scfepw     :生产Fe品位  ;*
;*           dzspw        ;地质s品位     scspw      :生产s品位    ;*
;*           dzppw        ;地质p品位     scppw      :生产p品位   ;*
;*完成时间:  2005.06.10                                                ;*
;******************************************************************
(defun fkqd_showtext(ptInsert  all_dzksl dzfepw dzspw dzppw
                     all_scksl scfepw scspw scppw
                    / radius x y   y_dis textHigh jsl pw
                      group_num len y_dis pt1y Distan dy
                     step gc_block_name block_name ss ss_fkqd)
  (setq all_dzksl (rtos all_dzksl))
  (setq dzfepw    (rtos dzfepw   ))
  (setq dzspw     (rtos dzspw    ))
  (setq dzppw     (rtos dzppw    ))
  (setq all_scksl (rtos all_scksl))
  (setq scfepw    (rtos scfepw   ))
  (setq scspw     (rtos scspw    ))
  (setq scppw     (rtos scppw    ))   
  (setq x (nth 0 ptInsert)
        y (nth 1 ptInsert))
  (setq radius  20 )
  (command "color" "white")
  ;以下用于绘制范围储量数据输入的圆圈绘制以及框框划分
  (setq ss_fkqd (ssadd))
  (command "circle" ptInsert radius )
  (setq  ss (entlast))
  (ssadd ss ss_fkqd )
  (command "line"   (list (+ x 20) y) (list (- x 20) y) "")
  (setq  ss (entlast))
  (ssadd ss ss_fkqd )
  (command "line"   (list (+ x 12)(- y 16)) (list (+ x 12)(+ y 16)) "")
  (setq  ss (entlast))
  (ssadd ss ss_fkqd )
  (command "line"   (list (+ x 4 )(- y 19)) (list (+ x 4) (+ y 19)) "")
  (setq  ss (entlast))
  (ssadd ss ss_fkqd )
  (command "line"   (list (- x 4 )(- y 19)) (list (- x 4) (+ y 19)) "")
  (setq  ss (entlast))
  (ssadd ss ss_fkqd )
  (command "line"   (list (- x 12)(- y 16)) (list (- x 12)(+ y 16)) "")
  (setq  ss (entlast))
  (ssadd ss ss_fkqd )
  (command "style" "shl" "宋体" 3 "1" "" "y" "")
  (command "text" (list (+ x 14) (- y 10))  "270"  "地质")
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "text" (list (+ x 14) (+ y  2))  "270"  "生产")
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "style" "shl" "宋体" 2.5 "1" "" "y" "")
  (command "text" (list (+ x 6.5) (- y 16))  "270"  all_dzksl)
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "text" (list (+ x 6.5) (+ y  2))  "270"  all_scksl)
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "text" (list (- x 1.5) (- y 16))  "270"  dzfepw)
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "text" (list (- x 1.5) (+ y  2))  "270"  scfepw)
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "text" (list (- x 9.5) (- y 16))  "270"  dzspw)
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "text" (list (- x 9.5) (+ y  2))  "270"  scspw)
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "text" (list (- x 17.5) (- y 16))  "270"  dzppw)
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (command "text" (list (- x 17.5) (+ y  2))  "270"  scppw)
  (setq ss (entlast))
  (ssadd ss ss_fkqd)
  (if (= Str_InputNumber nil)
       (setq Str_InputNumber "R")
  )
  (if (= fkclqd_block_flag nil)
       (setq fkclqd_block_flag 0)
       (setq fkclqd_block_flag (+ fkclqd_block_flag 1))
  );end if(= zk_block_flag nil)
  (setq gc_block_name (itoa fkclqd_block_flag))
  (setq block_name (strcat "fkqd_" gc_block_name Str_InputNumber))
  (command "block" block_name ptInsert ss_fkqd "")
  (command "insert" block_name  ptInsert 1.0 1.0 "" )   
)
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!

已领礼包: 593个

财富等级: 财运亨通

发表于 2005-12-9 13:05:42 | 显示全部楼层
未经测试

  1. ;|
  2. ******************************************************************
  3. *函 数 名: fkqd_showtext () ;*
  4. *功 能: 显示圈定范围内的储量以及其它信息 ;*
  5. *说 明: ptInsert:插入基点(圆心) ;*
  6. * all_dzksl :地质矿石量 all_scksl :生产矿石量 ;*
  7. * dzfepw ;地质Fe品位 scfepw :生产Fe品位 ;*
  8. * dzspw ;地质s品位 scspw :生产s品位 ;*
  9. * dzppw ;地质p品位 scppw :生产p品位 ;*
  10. *完成时间: 2005.06.10 ;*
  11. ******************************************************************
  12. |;
  13. (defun fkqd_showtext (ptinsert            all_dzksl          dzfepw
  14.                       dzspw            dzppw          all_scksl
  15.                       scfepw            scspw          scppw
  16.                       /                    blkdef          block_name
  17.                       fkclqd_block_flag                  gc_block_name
  18.                       modelspace    radius          str_inputnumber
  19.                       sty            thisdrawing          xdl-addline
  20.                       xdl-addtext
  21.                      )
  22.   (defun xdl-addline (obj p1 p2)
  23.     (vla-addline
  24.       obj
  25.       (vlax-3d-point p1)
  26.       (vlax-3d-point p2)
  27.     )
  28.   )
  29.   (defun xdl-addtext (obj str p / txt)
  30.     (setq txt (vla-addtext obj str (vlax-3d-point p)))
  31.     (vla-put-rotation txt (* 1.5 pi))
  32.   )
  33.   (if (= Str_InputNumber nil)
  34.     (setq Str_InputNumber "R")
  35.   )
  36.   (if (= fkclqd_block_flag nil)
  37.     (setq fkclqd_block_flag 0)
  38.     (setq fkclqd_block_flag (+ fkclqd_block_flag 1))
  39.   ) ;_end if(= zk_block_flag nil)
  40.   (setq gc_block_name (itoa fkclqd_block_flag))
  41.   (setq        all_dzksl   (rtos all_dzksl)
  42.         dzfepw            (rtos dzfepw)
  43.         dzspw            (rtos dzspw)
  44.         dzppw            (rtos dzppw)
  45.         all_scksl   (rtos all_scksl)
  46.         scfepw            (rtos scfepw)
  47.         scspw            (rtos scspw)
  48.         scppw            (rtos scppw)
  49.         x            (car ptInsert)
  50.         y            (cadr ptInsert)
  51.         radius            20
  52.         thisdrawing (vla-get-activedocument (vlax-get-acad-object))
  53.         modelspace  (vla-get-modelspace thisdrawing)
  54.   )
  55.   (vla-setvariable thisdrawing "color" "white")
  56.   (setq        blkdef (vla-add        (vla-get-blocks thisdrawing)
  57.                         (vlax-3d-point '(0. 0. 0.))
  58.                         (strcat "fkqd_" gc_block_name Str_InputNumber)
  59.                )
  60.   )
  61.   ;;(command "color" "white")
  62.   ;;以下用于绘制范围储量数据输入的圆圈绘制以及框框划分
  63.   ;;(command "circle" ptInsert radius)  
  64.   (vla-addcircle blkdef (vlax-3d-point '(0. 0. 0.)) radius)
  65.   (mapcar '(lambda (x)
  66.              (xdl-addline blkdef (car x) (cadr x))
  67.            )
  68.           '(((20 0) (-20 0))
  69.             ((12 -16) (12 16))
  70.             ((4 -19) (4 19))
  71.             ((-4 -19) (-4 19))
  72.             ((-12 -16) (-12 16))
  73.            )
  74.   )
  75.   ;|
  76.   (command "line" (list (+ x 20) y) (list (- x 20) y) "")
  77.   (command "line"
  78.              (list (+ x 12) (- y 16))
  79.              (list (+ x 12) (+ y 16))
  80.              ""
  81.   )
  82.    (command "line"
  83.            (list (+ x 4) (- y 19))
  84.            (list (+ x 4) (+ y 19))
  85.            ""
  86.   )
  87.   (command "line"
  88.            (list (- x 4) (- y 19))
  89.            (list (- x 4) (+ y 19))
  90.            ""
  91.   )
  92.   (command "line"
  93.            (list (- x 12) (- y 16))
  94.            (list (- x 12) (+ y 16))
  95.            ""
  96.   )
  97.   |;
  98.   (if (not (tblsearch "textstyle" "shl"))
  99.     (progn
  100.       (setq sty (vla-add (vla-get-textstyle thisdrawing) "shl"))
  101.       (vla-put-fontfile sty "宋体")
  102.       (vla-setvariable thisdrawing "teststyle" "shl")
  103.       (vla-put-height sty 3.)
  104.       (vla-put-TextGenerationFlag sty acTextFlagBackward)
  105.     )
  106.     (vla-setvariable thisdrawing "teststyle" "shl")
  107.   )
  108.   (mapcar '(lambda (a b)
  109.              (xdl-addtext blkdef a b)
  110.            )
  111.           (list        "地质"          "生产"    all_dzksl all_scksl        dzfepw
  112.                 scfepw          dzspw            scspw     dzppw        scppw
  113.                )
  114.           '((14 -10)
  115.             (14 2)
  116.             (6.5 -16)
  117.             (6.5 2)
  118.             (-1.5 -16)
  119.             (-1.5 2)
  120.             (-9.5 -16)
  121.             (-9.5 2)
  122.             (-17.5 -16)
  123.             (-17.5 2)
  124.            )
  125.   )
  126.   (vla-insertblock
  127.     modelspace
  128.     (vlax-3d-point ptinsert)
  129.     block_name
  130.     1.
  131.     1.
  132.     1.
  133.     0.
  134.   )
  135.   ;|
  136.   (command "style" "shl" "宋体" 3 "1" "" "y" "")
  137.   (command "text" (list (+ x 14) (- y 10)) "270" "地质")
  138.   (command "text" (list (+ x 14) (+ y 2)) "270" "生产")
  139.   (command "style" "shl" "宋体" 2.5 "1" "" "y" "")
  140.   (command "text" (list (+ x 6.5) (- y 16)) "270" all_dzksl)
  141.   (command "text" (list (+ x 6.5) (+ y 2)) "270" all_scksl)
  142.   (command "text" (list (- x 1.5) (- y 16)) "270" dzfepw)
  143.   (command "text" (list (- x 1.5) (+ y 2)) "270" scfepw)
  144.   (command "text" (list (- x 9.5) (- y 16)) "270" dzspw)
  145.   (command "text" (list (- x 9.5) (+ y 2)) "270" scspw)
  146.   (command "text" (list (- x 17.5) (- y 16)) "270" dzppw)
  147.   (command "text" (list (- x 17.5) (+ y 2)) "270" scppw)
  148.   (command "block" block_name ptInsert ss_fkqd "")
  149.   (command "insert" block_name ptInsert 1.0 1.0 "")
  150.   |;
  151. )
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

使用道具 举报

已领礼包: 593个

财富等级: 财运亨通

发表于 2005-12-9 18:51:24 | 显示全部楼层
程序中的作块部分应该只有一次,如果图中已存在该图块则直接 InsertBlock
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2025-9-28 22:03 , Processed in 0.169728 second(s), 38 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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