好的。给你';这是我正在做的部分;谢谢你,杰夫 ;这将从外部文件中获取块定义,而无需使用AutoCAD打开它,并将其添加到当前图形中
I';我将把要引入哪个块的计算和实际插入例程留给您个人的喜好。请确保添加对AutoCAD/ObjectDBX Common(ver#)类型库的引用- Option Explicit
- Function OpenSourceFile(FileName As String) As AXDBLib.AxDbDocument
-
- If Dir(FileName) "" Then
- Dim SourceDWG As New AXDBLib.AxDbDocument
- SourceDWG.Open (FileName)
-
- If Err.Number 0 Then
- If Err.Number -2147467259 Then 'File Moved
- SourceDWG.Open (FileName)
- End If
- End If
-
- Set OpenSourceFile = SourceDWG
- End If
-
- End Function
- Function ImportBlock(SourceName As String, BlockName As String) As AcadBlock
- Dim SourceDWG As New AXDBLib.AxDbDocument
- Dim EvryBlock As AcadBlock
-
- Set SourceDWG = OpenSourceFile(SourceName)
-
- For Each EvryBlock In SourceDWG.Blocks
- If UCase(BlockName) = UCase(EvryBlock.Name) Then
- Set ImportBlock = EvryBlock
- End If
- Next
-
- Dim BlockCollection(0) As AcadObject
-
- Set BlockCollection(0) = ImportBlock
- SourceDWG.CopyObjects BlockCollection, ThisDrawing.Blocks
-
- Set SourceDWG = Nothing
-
- End Function
- Sub Palette_Helper_Blocks()
-
- Dim SourceFile As String
- Dim BlockName As String
-
- SourceFile = "ContentMaster.dwg"
- BlockName = ""
-
- ImportBlock SourceFile, BlockName
-
- End Sub
也感谢jbuzzbee为我指明了这个方向。 |