向excel autocad请求特定数据
大家好,我叫Louis and post,来自意大利,我在网上搜索过,尤其是在;TheSwamp“;但是我没有找到我的解决方案。在Swamp中,我看到了许多代码示例,但我无法得到我想要的东西。我想要什么我希望用excel宏查询包含块的活动图形并返回我;块名称“
&引用;“处理”
";标签1“
";Term01“
";TERM02“
";第03条
";XRF“
";“家庭”
我将避免要求我选择哪个文件简而言之,必须与autocad的活动图形交互以检索数据,并在用户编辑后,依次返回到autocad对当前块的更改。是否可能?
向上的 这应该让你开始:http://help.autodesk.com/view/ACD/2015/ENU/?guid=GUID-403AF773-01AD-4AAF-BC3D-49A9884F7CF6,尽管您也可以走非编码路线并使用数据提取命令。 感谢您的回复,您的参考是相对于vba autocad的,但我指的是excel。例如,在本论坛的讨论中,有一段代码很漂亮,除了只检索活动图形上一个或所有块的一些参考之外,还有许多不理解的声音Sub Extract()
Dim sheet As Object
Dim shapes As Object
Dim elem As Object
Dim Excel As Object
Dim Max As Integer
Dim Min As Integer
Dim NoOfIndices As Integer
Dim excelSheet As Object
Dim RowNum As Integer
Dim Array1 As Variant
Dim Count As Integer
Dim SHand As String
Dim TStr As String
Set Excel = GetObject(, "Excel.Application")
Worksheets("Attributes").Activate
Set excelSheet = Excel.ActiveWorkbook.Sheets("Attributes")
excelSheet.Range(Cells(1, 1), Cells(5000, 100)).Clear
excelSheet.Range(Cells(1, 1), Cells(1, 100)).Font.Bold = True
Set acad = Nothing
On Error Resume Next
Set acad = GetObject(, "AutoCAD.Application")
If Err0 Then
Set acad = CreateObject("AutoCAD.Application")
MsgBox "Open the drawing file first and then rexecute!"
Exit Sub
End If
acad.Visible = True
Set doc = acad.ActiveDocument
Set mspace = doc.ModelSpace
RowNum = 1
Dim Header As Boolean
Header = False
For Each elem In mspace
With elem
If StrComp(.EntityName, "AcDbBlockReference", 1) = 0 Then
If .HasAttributes Then
Array1 = .GetAttributes
For Count = LBound(Array1) To UBound(Array1)
If Header = False Then
If StrComp(Array1(Count).EntityName, "AcDbAttribute", 1) = 0 Then
TStr = Array1(Count).TagString
excelSheet.Cells(RowNum, Count + 1).Value = TStr
End If
End If
Next Count
RowNum = RowNum + 1
For Count = LBound(Array1) To UBound(Array1)
TStr = Array1(Count).TextString
excelSheet.Cells(RowNum, Count + 1).Value = TStr
Next Count
SHand = elem.Handle
excelSheet.Cells(RowNum, Count + 1).NumberFormat = "@"
excelSheet.Cells(RowNum, Count + 1).Value = SHand
Header = True
End If
End If
End With
Next elem
NumberOfAttributes = RowNum - 1
Set acad = Nothing
End Sub我只希望在这些项目(3,1)中表现出色。值=“”;“Nome Blocco”
;单元格(3,2)。值=“”;“处理”
;细胞(3,3)。值=“”;标签1“
;细胞(3,4)。值=“”;TERM01“
;细胞(3,5)。值=“”;TERM02“
;细胞(3,6)。值=“”;第03条
;细胞(3,7)。值=“”;外部参照
;单元格(3.Value=FAMILY)
页:
[1]