clement 发表于 2003-9-13 09:33:00

请问如何获取图框左下角

dwg文件中只有唯一的图纸,但位置并不一定,请问如何获取图框左下角?

efan2000 发表于 2003-9-13 10:46:00

如果图纸唯一的话,那么图框应该主是图中最大的实体对象了,因而可以使用GetBoundingBox来获取最小点和最大点。
Sub Example_GetBoundingBox()
    ' This example creates a line in model space. It then finds the
    ' bounding box for the line and displays the corners of the box.
   
    Dim startPoint(0 To 2) As Double
    Dim endPoint(0 To 2) As Double
    Dim lineObj As AcadLine

    ' Create the Line object in model space
    startPoint(0) = 2#: startPoint(1) = 2#: startPoint(2) = 0#
    endPoint(0) = 4#: endPoint(1) = 4#: endPoint(2) = 0#
    Set lineObj = ThisDrawing.ModelSpace.AddLine(startPoint, endPoint)
    ZoomAll
   
    Dim minExt As Variant
    Dim maxExt As Variant
   
    ' Return the bounding box for the line and return the minimum
    ' and maximum extents of the box in the minExt and maxExt variables.
    lineObj.GetBoundingBox minExt, maxExt
   
    ' Print the min and max extents
    MsgBox "The extents of the bounding box for the line are:" & vbCrLf _
         & "Min Extent: " & minExt(0) & "," & minExt(1) & "," & minExt(2) _
         & vbCrLf & "Max Extent: " & maxExt(0) & "," & maxExt(1) & "," & maxExt(2), vbInformation, "GetBoundingBox Example"
         
End Sub

zhaiyuanwe 发表于 2003-9-14 15:56:00

在建立图框时,你可以为图框附加外部数据,可以对每个图框唯一的标识符,这样无论有几个图框也无所谓,比较容易找的,通过VBA编程也是比较容易实现的.

clement 发表于 2003-9-15 20:10:00

谢谢版主,但是每次返回的结果都是
The extents of the bounding box for the line are:
Min Extent: 2,2,0
Max Extent: 4,4,0            64         GetBoundingBox Example
要处理的图框并不是一个整体而是由4条直线组成的,是否有影响

mccad 发表于 2003-9-15 20:20:00

这只是个例子,你应该会灵活应用,先看看程序是怎样处理的。

neteasy 发表于 2003-9-16 21:31:00

如果是块的话,可以返回它的插入点,即左下角点。
页: [1]
查看完整版本: 请问如何获取图框左下角