
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello forum,
I've got a problem concerning copying elements between two drawings which I cannot solve myself at the moment.
I want to copy elements from the drawing "QuellDxf" based on Layer "ORIGINALKONTUR" to the "ZielDxf" and then add some elements to drawing "ZielDxf". Well all works fine until I add something by the call "Set Linie1 =..." in the sub routine to the drawing after copying.
If I comment out this lines I see the expected result: the elements from second opened drawing have been added to the other drawing. But if I add anything to the drawing after copying the elements are not visible anymore. They seem to be on a layer which is not displayed in the layer properties. You can get them back, if you select all elements and change the layer so they are only some kind of invinsible.
Maybe someone has an idea. Thanks in advance.
Lars
Here comes the Code.
'Declaration of variables
Public InsrtPnt(0 To 2) As Double
Public QuellDxf As AcadDocument
Public Quelllayer As String
Public ZielDxf As AcadDocument
Public SSetA As AcadSelectionSet
'Test Sub
Sub TESTMain()
Dim Linie1 As AcadLine, Linie2 As AcadLine
Dim MinXPkt(0 To 2) As Double, MaxXPkt(0 To 2) As Double
'Definiere den Einfügepunkt (0,0,0)
InsrtPnt(0) = 0: InsrtPnt(1) = 0: InsrtPnt(2) = 0
MinXPkt(0) = 10.5: MinXPkt(1) = 10: MinXPkt(2) = 0
MaxXPkt(0) = -10: MaxXPkt(1) = 10: MaxXPkt(2) = 0
Quelllayer = "ORIGINALKONTUR"
Set ZielDxf = Application.Documents.Open("E:\Dropbox\Zeichnung0.dxf") '("C:\Users\Lars.Elbracht\Desktop\Testprofile\Zeichnung0.dxf") '
Set QuellDxf = Application.Documents.Open("E:\Dropbox\Zeichnung1.dxf") '("C:\Users\Lars.Elbracht\Desktop\Testprofile\Zeichnung1.dxf")
CopyObjects False
Set Linie1 = ZielDxf.ModelSpace.AddLine(InsrtPnt, MinXPkt)
'Set Linie2 = QuellDxf.ModelSpace.AddLine(InsrtPnt, MinXPkt)
End Sub
Function CopyObjects(All As Boolean)
Dim SSetA As AcadSelectionSet
Dim tDxfCodes(0) As Integer ', mI%
Dim tDxfValues(0) As Variant
Dim mTmp As AcadBlockReference
Set SSetA = CreateSelectionSet("KopiereObjekte")
'wenn All=True sollen alle Objekte in der aktiven Zeichnung kopiert werden, sonst nur gemäß Filter-Einstellungen
If All = False Then
'Filter-Einstellungen
tDxfCodes(0) = 8
tDxfValues(0) = Quelllayer
Call SSetA.Select(acSelectionSetAll, , , tDxfCodes, tDxfValues) 'Filtertyp 8-->Layer Name, Layer-Name
Else
Call SSetA.Select(acSelectionSetAll)
End If
If SSetA.Count > 0 Then
QuellDxf.Wblock "C:\Users\Public\Documents\" & "Block.dwg", SSetA
Set mTmp = ZielDxf.ModelSpace.InsertBlock(InsrtPnt, "C:\Users\Public\Documents\" & "Block.dwg", 1, 1, 1, 0)
mTmp.Explode
mTmp.Delete
ZielDxf.PurgeAll
Kill "C:\Users\Public\Documents\" & "Block.dwg"
SSetA.Clear
End If
End Function
Solved! Go to Solution.