lrzm 发表于 2007-7-12 15:39:00

如何获得矩形的4个点的坐标

<p>用什么样的命令可以获得AUTOCAD中一个矩形的四个点的坐标,并且在其中的一个点上建立新的坐标系。</p>

fjfhgdwfn 发表于 2007-7-12 16:37:00

本帖最后由 作者 于 2007-7-12 17:14:58 编辑 <br /><br /> <p class="syntax">object.GetBoundingBox MinPoint, MaxPoint </p>

fircst 发表于 2007-7-12 17:49:00

如果是不平行于坐标系的呢?

fjfhgdwfn 发表于 2007-7-13 10:31:00

矩形就是多义线,用多义线的命令。<pre class="Code">Sub Example_Coordinates()
    ' This example creates a polyline. It then uses the Coordinates
    ' property to return all the coordinatesin the polyline. It then
    ' resets one of the vertices using the Coordinates property.
   
    Dim plineObj As AcadPolyline

    ' Create Polyline
    Dim points(5) As Double
    points(0) = 3: points(1) = 7: points(2) = 0
    points(3) = 9: points(4) = 2: points(5) = 0
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
    ThisDrawing.Regen True

    ' Return all the coordinates of the polyline
    Dim retCoord As Variant
    retCoord = plineObj.Coordinates

    ' Display current coordinates for the first vertex
    MsgBox "The current coordinates of the second vertex are: " &amp; points(3) &amp; ", " &amp; points(4) &amp; ", " &amp; points(5), vbInformation, "Coordinates 示例"

    ' Modify the coordinate of the second vertex to (5,5,0). Note that in
    ' case of a lightweight Polyline, indices will be different because the points are 2D only.
    points(3) = 5
    points(4) = 5
    points(5) = 0
    plineObj.Coordinates = points

    ' Update display
    ThisDrawing.Regen True

    MsgBox "The new coordinates have been set to " &amp; points(3) &amp; ", " &amp; points(4) &amp; ", " &amp; points(5), vbInformation, "Coordinates 示例"
End Sub</pre>

fjfhgdwfn 发表于 2007-7-13 10:31:00

<pre class="Code">Sub Example_Coordinates()
    ' This example creates a polyline. It then uses the Coordinates
    ' property to return all the coordinatesin the polyline. It then
    ' resets one of the vertices using the Coordinates property.
   
    Dim plineObj As AcadPolyline

    ' Create Polyline
    Dim points(5) As Double
    points(0) = 3: points(1) = 7: points(2) = 0
    points(3) = 9: points(4) = 2: points(5) = 0
    Set plineObj = ThisDrawing.ModelSpace.AddPolyline(points)
    ThisDrawing.Regen True

    ' Return all the coordinates of the polyline
    Dim retCoord As Variant
    retCoord = plineObj.Coordinates

    ' Display current coordinates for the first vertex
    MsgBox "The current coordinates of the second vertex are: " &amp; points(3) &amp; ", " &amp; points(4) &amp; ", " &amp; points(5), vbInformation, "Coordinates 示例"

    ' Modify the coordinate of the second vertex to (5,5,0). Note that in
    ' case of a lightweight Polyline, indices will be different because the points are 2D only.
    points(3) = 5
    points(4) = 5
    points(5) = 0
    plineObj.Coordinates = points

    ' Update display
    ThisDrawing.Regen True

    MsgBox "The new coordinates have been set to " &amp; points(3) &amp; ", " &amp; points(4) &amp; ", " &amp; points(5), vbInformation, "Coordinates 示例"
End Sub</pre>

muzi2005888 发表于 2007-8-13 22:02:00

<p>谢谢楼上精彩的解答</p><p>我顺便问一下如何获取图形里所有圆的圆心坐标呢</p><p>是遍历所有图元吗?</p><p>具体如何实现呢?</p><p>谢谢</p>

青青20 发表于 2007-8-16 15:57:00

建立圆选择集,遍历所有图元,取圆心
页: [1]
查看完整版本: 如何获得矩形的4个点的坐标