找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 1407|回复: 1

通过ActiveX创建LWPOLYLINE对象

[复制链接]

已领礼包: 40个

财富等级: 招财进宝

发表于 2021-1-12 13:02:31 | 显示全部楼层 |阅读模式

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

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

×

问题:

Is the method of passing a list of points from ActiveX to addLWPolyline in
AutoCAD 2000 that same way as in AutoCAD R14 using Visual LISP?

The following error occurs when passing a list:
Error: lisp value has no coercion to VARIANT with this type:
      (17509.1 11009.0 17484.1 11009.0 17484.1 11109.0 17509.1 11109.0)


解答:

The passing of lists to ActiveX methods has changed in AutoCAD 2000. You need to
use the vlax-make-safearray, vlax-safearray-fill, vlax-make-variant functions to
pass a list to ActiveX functions. The following code does this:

  1. (vl-load-com)
  2. (defun T_LWPoly        ()
  3.   (setq        acadapp             (vlax-get-Acad-Object)

  4.         acaddoc             (vla-get-ActiveDocument acadapp)

  5.         *ModelSpace* (vla-get-ModelSpace acaddoc)

  6.   )
  7.   (setq pt1 (list 5.18379 1.76186))
  8.   (setq pt2 (list 1.39797 4.08785))
  9.   (setq pt3 (list 4.71491 7.61156))
  10.   (setq pt4 (list 8.63965 6.48328))
  11.   (setq pt5 (list 8.65702 3.49767))
  12.   (setq pt6 (list 5.46165 3.93163))
  13.   (setq pt7 (list 5.58321 5.73688))
  14.   (setq pt8 (list 5.23589 6.03197))
  15.   (setq pt9 (list 4.52388 4.9384))
  16.   (setq pt10 (list 4.73227 2.99429))
  17.   (setq pt11 (list 7.63242 1.90072))
  18.   (setq pt12 (list 7.25036 1.29318))
  19.   (setq        Points (apply 'append
  20.                       (list pt1        pt2 pt3        pt4 pt5        pt6 pt7        pt8 pt9        pt10
  21.                             pt11 pt12)
  22.                )
  23.   )
  24.   (setq ptlstlen (length Points))
  25.                                         ; make array of 12*2=24 doubles - that's an array of dimension 0 to 23
  26.   (setq        PointDataA
  27.          (vlax-make-safearray
  28.            vlax-vbDouble
  29.            (cons 0 (1- ptlstlen))
  30.          )
  31.   )
  32.   (vlax-safearray-fill PointDataA Points)
  33.   (setq PointData (vlax-make-variant PointDataA))
  34.   (setq myLWpoly (vla-addLightweightPolyline *ModelSpace* PointData))
  35.   (vla-Put-Color myLWpoly acBlue)
  36.   (princ)
  37. )


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

已领礼包: 1个

财富等级: 恭喜发财

发表于 2021-11-5 09:10:44 | 显示全部楼层
额,原来lisp也能操作ActiveX
论坛插件加载方法
发帖求助前要善用【论坛搜索】功能,那里可能会有你要找的答案;
如果你在论坛求助问题,并且已经从坛友或者管理的回复中解决了问题,请把帖子标题加上【已解决】;
如何回报帮助你解决问题的坛友,一个好办法就是给对方加【D豆】,加分不会扣除自己的积分,做一个热心并受欢迎的人!
回复 支持 反对

使用道具 举报

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

本版积分规则

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

GMT+8, 2024-3-28 21:07 , Processed in 0.233122 second(s), 25 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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