找回密码
 立即注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

查看: 711|回复: 0

[研讨] 不与 WCS 平行的UCS下 MLeader 制造问题

[复制链接]

已领礼包: 1268个

财富等级: 财源广进

发表于 2017-7-10 09:09:36 | 显示全部楼层 |阅读模式

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

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

×
本帖最后由 st788796 于 2017-7-10 09:12 编辑

AddMleader 定义如下:
Signature

RetVal = object.AddMLeader(pointsArray, leaderLineIndex)

Object   ModelSpace Collection, PaperSpace Collection, Block
The object or objects this method applies to.

pointsArray
Variant (three-element array of Doubles); input-only
The array of 3D WCS coordinates specifying the leader. You must provide at least two point to define the leader. The third point is optional.
leaderLineIndex

Long; input-only
Input index of the mleader cluster.
RetVal
MLeader object
The newly created MLeader object.

MLeader 是 Leader 增加了"反应器“的集合,Leader 定义如下

Signature
RetVal = object.AddLeader(PointsArray, Annotation, Type)
Object
ModelSpace collection, PaperSpace collection, Block
The object or objects this method applies to.
PointsArray
Variant (array of doubles); input-only
The array of 3D WCS coordinates specifying the leader. You must provide at least two points to define the leader. The third point is optional.
Annotation
Object; input-only
A Tolerance, MText, BlockRef object or NULL.
Type
AcLeaderType enum; input-only
acAttributeModeLockPosition
acAttributeModeMultipleLine
acLineNoArrow
acLineWithArrow
acSplineNoArrow
acSplineWithArrow
RetVal
Leader object
The newly created Leader object.

其中有个 coordinate 属性,

Signature
object.Coordinate(index)
object
3DPoly, Leader, LightweightPolyline, Point, PolyfaceMesh, PolygonMesh, Polyline, Section, Solid, Trace
The object or objects this property applies to.
Coordinate
Variant (three-element or two-element array of doubles); read-write
The array of X, Y, and Z coordinates for the specified vertex.

LightweightPolyline object: The variant has two elements representing the X and Y coordinates in OCS.
Polyline object: The variant has three elements, representing the X and Y coordinates in OCS. The Z coordinate is present in the variant but ignored.

All other objects: The variant has three elements, representing the X and Y coordinates in WCS; the Z coordinate will default to 0 on the active UCS.
Index
Integer
The index in the array of vertices for the vertex you want to set or query. The vertex arrays are 0 based.
Remarks
This property will replace any existing vertices for the specified object. Use standard array-handling techniques to process the values contained in this property.
3DPolyline, Polyline, PolygonMesh: For simple polylines (not splined or curve fit), this property specifies simple vertices. For splined or curve-fit polylines, this property specifies control point vertices.
The OCS coordinates for the Polyline and LightweightPolyline objects can be converted to and from other coordinate systems using the TranslateCoordinates method.

注意其中红色部分,AddMLeader 中 pointsArray 是三元素的点表,事实上在不与 WCS 平行的 UCS 下生成的MLeader会忽略掉 Z ,可以使用下面的代码在 http://bbs.xdcad.net/thread-710631-1-1.html 这个帖子中的附件验证

  1. [/align][align=left](defun c:tt (/ ms p p1 ml scl)
  2.   ;;(setq scl (getreal "\nscalefactor: "))
  3.   ;;(if (not scl)
  4.   ;;  (setq scl 100.0)
  5.   ;;)
  6.   (setq    ms (vla-get-modelspace
  7.          (vla-get-activedocument (vlax-get-acad-object))
  8.        )
  9.   )
  10.   (while (and (setq p (getpoint "\nlocation: "))
  11.           (setq p1 (getpoint p "\nposition: "))
  12.      )
  13.     (princ "\n")
  14.     (princ (trans p 1 0))
  15.     (princ "\n")
  16.     (princ (trans p1 1 0))
  17.     (setq ml (vla-addmleader
  18.            ms
  19.            (vlax-make-variant
  20.          (vlax-safearray-fill
  21.            (vlax-make-safearray
  22.              vlax-vbdouble
  23.              '(0 . 5)
  24.            )
  25.            (append (trans p 1 0)
  26.                (trans p1 1 0)
  27.            )
  28.          )
  29.            )
  30.            0
  31.          )
  32.     )
  33.     (vla-put-textstring
  34.       ml
  35.       (strcat "X="
  36.           (rtos (car p) 2 0)
  37.           "\\PY="
  38.           (rtos (cadr p) 2 0)
  39.           "\\PZ="
  40.           (rtos (last p) 2 0)
  41.       )
  42.     )
  43.     (vla-put-textjustify ml acAttachmentPointMiddleLeft)
  44.     (vla-put-textleftattachmenttype ml 3)
  45.     (vla-put-textrightattachmenttype ml 3)
  46.     (vla-put-DoglegLength ml 10.0)
  47.     (vla-put-scalefactor ml 50)
  48.   )
  49.   (princ)
  50. )




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

本版积分规则

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

GMT+8, 2024-11-12 09:48 , Processed in 0.308983 second(s), 28 queries , Gzip On.

Powered by Discuz! X3.5

© 2001-2024 Discuz! Team.

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