这应该可以让您开始
- Public Function CopyDwgLayout(sPath As String, SourceName, TargetName As String) As AcadLayout
- Dim axDoc As AxDbDocument
- Dim Doc As AcadDocument
- Dim sLayout As AcadLayout
- Dim tLayout As AcadLayout
- Dim i As Integer
- Dim objArray() As Object
-
- Set Doc = ThisDrawing
- Set axDoc = New AxDbDocument
- axDoc.Open sPath
- Set sLayout = axDoc.Layouts(SourceName)
- Set tLayout = Doc.Layouts.Add(TargetName)
- If sLayout.Block.count > 0 Then
- ReDim objArray(0 To sLayout.Block.count - 1)
- For i = 0 To sLayout.Block.count - 1
- Set objArray(i) = sLayout.Block.Item(i)
- Next
- axDoc.CopyObjects objArray, tLayout.Block
- End If
- tLayout.CopyFrom sLayout 'here you copy the pagesetups etc
- Set axDoc = Nothing
- End Function
- Sub TestCopyLayout()
- Dim sPath As String
- sPath = "C:\MyAppPath\StdSheets.DWG"
- CopyDwgLayout sPath, "A4Psheet", "A4Psheet"
- End Sub
|