encontrei esse codigo para contar os blocos no acad, porem ele conta todos os blocos existentes dando o resultado geral, alguem teria uma ideia de como posso modificar para ele contar os blocos de acordo com o nome dos mesmos?
ex.: blocoA 50
blocoB 207
e não :
ex.: path 257 .
abraços.
Private Sub GetBlockCnt()
Dim Sheet As Worksheet
Dim ACad As Object
Dim ACadDwg As Object
Dim sPath As String
Dim ssetObj As Object
Dim mode As Integer
Dim gpCode(0) As Integer
Dim dataValue(0) As Variant
Dim I As Integer
Dim groupCode As Variant, dataCode As Variant
Const SELSET = "SSblockCnt"
Const acSelectionSetAll = 5
sPath = "C:UsersUsuarioDesktopcount.dwg"
Set ACad = GetObject(, "AutoCAD.Application")
If Err <> 0 Then
MsgBox "Please open a drawing file and then restart this macro."
Exit Sub
End If
Set ACadDwg = ACad.Application.Documents.Open(sPath)
For I = 0 To ACadDwg.SelectionSets.Count - 1
If ACadDwg.SelectionSets.Item(I).Name = SELSET Then
ACadDwg.SelectionSets.Item(I).Delete
End If
Next
Set ssetObj = ACadDwg.SelectionSets.Add(SELSET)
mode = acSelectionSetAll
gpCode(0) = 0
dataValue(0) = "INSERT"
groupCode = gpCode
dataCode = dataValue
ssetObj.Select mode, , , groupCode, dataCode
Set Sheet = ThisWorkbook.Sheets(1)
Sheet.Cells(1, 1) = sPath
Sheet.Cells(1, 2) = ssetObj.Count
ssetObj.Delete
ACadDwg.Close False
Set ssetObj = Nothing
Set ACadDwg = Nothing
Set ACad = Nothing
End Sub
Existem mil maneiras de preparar Neston. Invente a sua!
http://www.youtube.com/ExpressoExcel
Postado : 08/05/2012 3:03 pm