找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 790|回复: 0

[他山之石] LISP使用ACTIVEX添加多段线的凸度

[复制链接]

已领礼包: 145个

财富等级: 日进斗金

发表于 2013-8-22 09:35:46 | 显示全部楼层 |阅读模式

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

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

×
Setting the bulge of a polyline using ActiveX in LISP
Issue
This is the Visual LISP code I have used to set a bulge for a polyline:
Command: !pline
#
Command: !mspace
#
Command: (vla-SetBulge mSpace pline 0 0.5)
; error: ActiveX Server returned the error: unknown name: SetBulge
Command: (vla-put-SetBulge pline 0 0.5)
; error: no function definition: VLA-PUT-SETBULGE
Command: (vlax-invoke-method mspace 'setbulge pline 0 0.5)
; error: ActiveX Server returned the error: unknown name: SETBULGE
Command: (vlax-put-property pline 'setbulge 0 0.5)
; error: ActiveX Server returned an error: Type mismatch


What is the correct syntax to use?
Solution
The documentation contains the information to answer this question. In the AutoCAD ActiveX and VBA Reference, go to Object Model -> Polyline Object -> SetBulge Method.
Then refer to the Visual LISP Developer's Guide: Using Visual LISP Functions with ActiveX Methods -> Determining How to Call a Function.
After reading these two references, you should notice that SetBulge is a method of the polyline object, not a Property nor a Method of the Model Space Collection (which is what the preceding code shows).
You'll find that the following code will set the bulge of a Polyline Object:
(vla-SetBulge myPolyObj 1 -0.42080)
Because it is easier to see this in context, code was copied from , and modified it to use the SetBulge method for a polyline:

  1. (vl-load-com)
  2. (defun a_Polyline_wArc ()
  3.   (setq acadapp (vlax-get-Acad-Object)
  4.         acaddoc (vla-get-ActiveDocument acadapp)
  5.         *ModelSpace* (vla-get-ModelSpace acaddoc)
  6.   )
  7.   (setq pt1 (list 2.93905 1.87048 0.0))
  8.   (setq pt2 (list 5.54349 4.81627 0.0))
  9.   (setq pt3 (list 8.78096 4.97892 0.0))
  10.   (setq pt4 (list 12.6153 1.20181 0.0))
  11.   (setq Points (apply
  12.                  'append
  13.                  (list pt1 pt2 pt3 pt4)
  14.                )
  15.   )
  16.   (setq ptlstlen (length Points))
  17.   (setq PointDataA (vlax-make-safearray vlax-vbDouble (cons 0 (1- ptlstlen))))
  18.   (vlax-safearray-fill PointDataA Points)
  19.   (setq PointData (vlax-make-variant PointDataA (logior vlax-vbarray
  20.                                                         vlax-vbDouble
  21.                                                 )
  22.                   )
  23.   )
  24.   (setq myPolyObj (vla-addPolyline *ModelSpace* PointData))
  25.   (vla-Put-Color myPolyObj acBlue)
  26.   (setq strtWidth 1.0
  27.         endWidth 1.0
  28.         verticies (1- (/ ptlstlen 3))
  29.         indx0
  30.   )
  31.   (while (< indx verticies)
  32.     (vla-SetWidth myPolyObj indx strtWidth endWidth)
  33.     (setq indx (1+ indx))
  34.   )
  35.   (vla-SetBulge myPolyObj 1 -0.42080)
  36.   (vla-Update myPolyObj)
  37.   (princ)
  38. )

  39. ; (a_Polyline_wArc)



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

本版积分规则

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

GMT+8, 2024-9-25 08:30 , Processed in 0.345885 second(s), 29 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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