alin 发表于 2007-10-18 14:05:00

你要通过拾取圆来得到坐标呢还是其它什么方法,也可以上张图。

liuyang4740 发表于 2007-10-18 17:48:00

<p>不是!我想通过for each 命令自动搜索所有的块参照,然后自动获取圆心</p>

alin 发表于 2007-10-18 21:59:00

对于二维的情况,可以试用下面的代码,只要把块名haha更换

'Option Explicit
Sub test()
Dim blkDef As AcadBlock
Dim objEnt As AcadEntity
Dim center As Variant
Dim InsPnt As Variant
Set blkDef = ThisDrawing.Blocks("haha")
For Each objEnt In blkDef
    If objEnt.ObjectName = "AcDbCircle" Then
      center = objEnt.center
      xc = center(0): yc = center(1)
    End If
Next
For Each objEnt In ThisDrawing.ModelSpace
   If objEnt.ObjectName = "AcDbBlockReference" Then
   If objEnt.Name = "haha" Then
       InsPnt = objEnt.InsertionPoint
       rot = objEnt.Rotation
       x_scale = objEnt.XScaleFactor
       y_scale = objEnt.YScaleFactor
       new_x = Cos(rot) * x_scale * xc - Sin(rot) * y_scale * yc + InsPnt(0)
       new_y = Sin(rot) * x_scale * xc + Cos(rot) * y_scale * yc + InsPnt(1)
       MsgBox new_x & ", " & new_y
    End If
    End If
Next

liuyang4740 发表于 2007-10-19 09:32:00

非常感谢版主!问题解决了!
页: 1 [2]
查看完整版本: 求助:块插入点问题