- UID
- 5244
- 积分
- 1648
- 精华
- 贡献
-
- 威望
-
- 活跃度
-
- D豆
-
- 在线时间
- 小时
- 注册时间
- 2002-5-18
- 最后登录
- 1970-1-1
|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?立即注册
×
Add Area
Option Explicit
Public Sub vbd_Add_Areas()
'The Variables
Dim objSel As Object
Dim dblArea As Double
Dim intCnt As Integer
Dim strPrompt As String
Dim ssArea As AcadSelectionSet
On Error GoTo ErrorControl
'Assignments
strPrompt = "The Total area of selected entities is "
intCnt = 1
Set ssArea = ThisDrawing.SelectionSets.Add("Areas")
'The Selections
ssArea.SelectOnScreen
'The Math
For Each objSel In ssArea
dblArea = dblArea + objSel.Area
intCnt = intCnt + 1
Next
'dblArea = RoundOff(dblArea)
'PutOnClipboard dblArea
MsgBox strPrompt & vbCrLf & dblArea, vbInformation, "Lisp to VBA"
ThisDrawing.SelectionSets.Item("Areas").Delete
Exit Sub
'Error Label
ErrorControl:
If Err.Description = "Object doesn't support this property or method" Then
If MsgBox("Entity #" & intCnt & " does not have an area property." & vbCrLf & _
"The area total will not include it, Would you like to continue?", vbYesNo, "Lisp to VBA") = vbYes Then
Err.Clear
Resume Next
End If
Else
Debug.Print Err.Description
End If
ThisDrawing.SelectionSets.Item("Areas").Delete
End Sub
Public Sub PutOnClipboard(varValue As Variant)
Dim objClip As New DataObject
objClip.SetText Format(varValue)
objClip.PutInClipboard
End Sub
Private Function RoundOff(varValue As Variant) As Variant
'If you would like to format to another decimal place, add more # symbols!
RoundOff = Format(varValue, "##.##")
End Function
Private Sub SendToNewXLBook(strName As String, varVal As Variant)
Dim xlApp As New Excel.Application
Dim xlBook As Excel.Workbook
Dim xlSheet As Excel.Worksheet
Dim intRow As Integer
intRow = 1
Set xlBook = xlApp.Workbooks.Add
Set xlSheet = xlBook.Sheets(1).Select
xlSheet.Cells(intRow, 1).Value = varVal
xlBook.SaveAs strName
xlApp.Quit
Set xlApp = Nothing
End Sub |
|