- Sub ScaleEntFromCentro()
- On Error Resume Next
- Dim Ent As AcadEntity
- Dim Pnt As Variant
- ThisDrawing.Utility.GetEntity Ent, Pnt, "选择对象:"
- Dim Ents(0) As AcadEntity
- Set Ents(0) = Ent
- Dim Regs As Variant
- Dim Reg As AcadRegion
- Regs = ThisDrawing.ModelSpace.AddRegion(Ents)
- If Err Then
- Err.Clear
- ThisDrawing.Utility.Prompt "选中的对象不能找到合适的中心,程序不能继续进行。"
- Exit Sub
- End If
- If IsArray(Regs) Then
- Set Reg = Regs(0)
- Dim Org As Variant
- Org = Reg.Centroid
- Reg.Delete
- ThisDrawing.SendCommand "scale" & vbCr & axEnt2lspEnt(Ent) & vbCr & vbCr & axPoint2lspPoint(Org) & vbCr
- Else
- ThisDrawing.Utility.Prompt "没有选中闭合的对象,程序不能继续进行。"
- End If
- End Sub
- Public Function axEnt2lspEnt(entObj As AcadEntity) As String
- Dim entHandle As String
- entHandle = entObj.Handle
- axEnt2lspEnt = "(handent " & Chr(34) & entHandle & Chr(34) & ")"
- End Function
- Public Function axPoint2lspPoint(Pnt As Variant) As String
- axPoint2lspPoint = Pnt(0) & "," & Pnt(1)
- End Function
|