指定 MText 对象的连接点。 支持的平台:仅窗口 签名工 务 局: object.AttachmentPoint对象此属性适用的对象。
属性值只读:不 类型:枚举acAttachmentPoint - acAttachmentPointTopLeft
- acAttachmentPointTopCenter
- acAttachmentPointTopRight
- acAttachmentPointMiddleLeft
- acAttachmentPointMiddleCenter
- acAttachmentPointMiddleRight
- acAttachmentPointBottomLeft
- acAttachmentPointBottomCenter
- acAttachmentPointBottomRight
言论连接点指定插入点与文本边界对齐的位置。您选择的选项确定相对于文本边界的文本对齐和文本溢出。 文本对齐的选项包括“左”、“右”和“居中”。文本溢出的选项包括“顶部”、“中间(中间)”和“底部”。
左上角 左对齐,溢出 |
顶部中心 居中对齐,向下溢出 |
右上 右对齐,溢出 |
左中 左对齐,上下溢出 |
中中心 居中对齐,上下溢出 |
右中 右对齐,上下溢出 |
左下角 左对齐,溢出 |
底部中心 居中对齐,溢出 |
右下角 正确对齐,溢出 |
更改属性时,现有边界框的位置不会更改;文本只是在边界框中重新对齐。 但是,属性反映正在使用的连接点的坐标,因此属性的值将更改以反映对齐方式的变化。 AttachmentPoint InsertionPoint InsertionPoint
例子工 务 局: - Sub Example_AttachmentPoint()
- Dim MTextObj As AcadMText
- Dim width As Double
- Dim text As String
- Dim count As Integer
- Dim attachPoint As String
- Dim corner(0 To 2) As Double
- corner(0) = 3#: corner(1) = 3#: corner(2) = 0#
- width = 10
- text = "Hello, World."
- ' Creates a MText object in model space
- Set MTextObj = ThisDrawing.ModelSpace.AddMText(corner, width, text)
- For count = 1 To 9
- MTextObj.AttachmentPoint = count
- ' Gets the attachment point of an MText object
- attachPoint = Choose(MTextObj.AttachmentPoint, "TopLeft", "TopCenter",
- "TopRight", "MiddleLeft", "MiddleCenter",
- "MiddleRight", "BottomLeft", "BottomCenter",
- "BottomRight")
- ThisDrawing.Regen True
- MsgBox "The attachment point of the MText is now: "
- & attachPoint, vbInformation, "AttachmentPoint Example"
- Next
- End Sub
- public void ExampleAttachmentPoint()
- {
- AcadMText mTextObject;
- double width;
- string text;
- int count;
- string attachPoint;
- double[] corner = new double[3];
- corner[0] = 3.0; corner[1] = 3.0; corner[2] = 0.0;
- width = 10;
- text = "Hello, World.";
- // Creates a MText object in model space
- mTextObject = ThisDrawing.ModelSpace.AddMText(corner, width, text);
- for (count = 1; count <= 9; count++)
- {
- mTextObject.AttachmentPoint = count;
- // Gets the attachment point of an MText object
- attachPoint = Choose(mTextObject.AttachmentPoint, "TopLeft", "TopCenter", "TopRight",
- "MiddleLeft", "MiddleCenter", "MiddleRight",
- "BottomLeft", "BottomCenter", "BottomRight");
- ThisDrawing.Regen(true);
- System.Windows.Forms.MessageBox.Show("The attachment point of the MText is now: " + attachPoint,
- "AttachmentPoint Example",
- System.Windows.Forms.MessageBoxButtons.OK,
- System.Windows.Forms.MessageBoxIcon.Information);
- }
- }
复制代码
Visual LISP: - (vl-load-com)
- (defun c:Example_AttachmentPoint()
- (setq acadObj (vlax-get-acad-object))
- (setq doc (vla-get-ActiveDocument acadObj))
- (setq corner (vlax-3d-point 3 3 0)
- width 10
- text "Hello, World.")
-
- ;; Creates a MText object in model space
- (setq modelSpace (vla-get-ModelSpace doc))
- (setq MTextObj (vla-AddMText modelSpace corner width text))
-
- (setq count 1)
- (repeat 9
- (vla-put-AttachmentPoint MTextObj count)
- ;; Gets the attachment point of an MText object
- (cond
- ((= (vla-get-AttachmentPoint MTextObj) 1)(setq attachPoint "TopLeft"))
- ((= (vla-get-AttachmentPoint MTextObj) 2)(setq attachPoint "TopCenter"))
- ((= (vla-get-AttachmentPoint MTextObj) 3)(setq attachPoint "TopRight"))
- ((= (vla-get-AttachmentPoint MTextObj) 4)(setq attachPoint "MiddleLeft"))
- ((= (vla-get-AttachmentPoint MTextObj) 5)(setq attachPoint "MiddleCenter"))
- ((= (vla-get-AttachmentPoint MTextObj) 6)(setq attachPoint "MiddleRight"))
- ((= (vla-get-AttachmentPoint MTextObj) 7)(setq attachPoint "BottomLeft"))
- ((= (vla-get-AttachmentPoint MTextObj) 8)(setq attachPoint "BottomCenter"))
- ((= (vla-get-AttachmentPoint MTextObj) 9)(setq attachPoint "BottomRight"))
- )
-
- (vla-Regen doc :vlax-true)
- (alert (strcat "The attachment point of the MText is now: " attachPoint))
-
- (setq count (1+ count))
- )
- )
|