0

我正在尝试获取 AutoCAD 块参考的坐标。

使用下面的代码,我可以在 AutoCAD 中选择块引用,但它始终显示 (0,0,0) 作为插入点...

插入点是块的实际坐标,还是不是?

Sub GetInsertpoint()
    Dim oEnt As AcadEntity
    Dim varPick As Variant
    Dim brBref As AcadBlockReference
    Dim arAttR As AcadAttributeReference
    Dim varAt As Variant
    Dim i As Double

    ThisDrawing.Utility.GetEntity oEnt, varPick, vbCr & "Get the block"
    If TypeOf oEnt Is AcadBlockReference Then
        MsgBox "Thank you, very nice!"
        Set brBref = oEnt
        MsgBox brBref.InsertionPoint(0) & brBref.InsertionPoint(1) & brBref.InsertionPoint(2)
    Else
        MsgBox "Not a block reference!"
        Exit Sub
    End If

End Sub
4

3 回答 3

1

分解 AcDbBlockReference

AcDbBlockReference.explode();

它将为您提供 BlockReference 中存在的实体。

于 2013-02-24T15:55:10.160 回答
1

首先:您使用的是哪个版本的 AutoCAD?

在德国 AutoCAD 2008 上尝试了您的代码。我从多边形创建了一些简单的块并将它们插入到新图形中。

当我执行上面的代码并选择其中一个块时,我总是得到有效的坐标。所以这可能是一个问题,你是如何创建块的?

也许您创建了一个块并将“从屏幕中选择插入点”留空。所以 ACAD 采用了默认值:(0,0,0)。这将是一个解释,为什么你总是得到那些坐标。

于 2010-09-01T10:22:39.113 回答
1

尝试这个

Dim point1, point2 As Variant
brBref.GetBoundingBox point1, point2
MsgBox point1(0) & " / " & point1(1) & vbcrlf & point2(0) & " / " & point2(1)
于 2017-01-27T05:57:48.400 回答