Message 1 of 8
How to copy entities from a XRef to modelspace?
Not applicable
04-23-2002
08:38 PM
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello, everybody...
I'm trying actually to recover a file wich couldn't be opened in a normal
way (fatal error, internal error ...)
I can insert it as XRef in a new drawing. To recover the drawing, I would
like to copy all the entities from the XRef to the empty modelspace.
I use this code :
Sub xrefcopy()
Dim objSS As AcadSelectionSet
Dim entity As AcadEntity
Dim xref As AcadBlock
Dim NewEntity As AcadEntity
Set objSS = ThisDrawing.SelectionSets.Add("all")
objSS.Select acSelectionSetAll
For Each entity In objSS
If entity.ObjectName = "AcDbBlockReference" Then
Set xref = ThisDrawing.Blocks(entity.Name)
End If
Next entity
For Each entity In xref
Set NewEntity = entity.Copy
NewEntity.Layer = "0"
Next entity
If Not objSS Is Nothing Then
objSS.Delete
End If
ThisDrawing.Regen acAllViewports
End Sub
It works... But not as I would like... Every entity is copied, but INSIDE
the XRef !
When I remove it, nothing stays on the screen. So it doesn't help me...
I've thought it was maybe because I send the entities on the "0" layer. But
it doesn't work. If I try to send an entity on a new layer from the
modelspace, it makes an error;
What can I do? Thanks for your help...
Alexis Perdaen
AM4D
Brussels, Belgium
I'm trying actually to recover a file wich couldn't be opened in a normal
way (fatal error, internal error ...)
I can insert it as XRef in a new drawing. To recover the drawing, I would
like to copy all the entities from the XRef to the empty modelspace.
I use this code :
Sub xrefcopy()
Dim objSS As AcadSelectionSet
Dim entity As AcadEntity
Dim xref As AcadBlock
Dim NewEntity As AcadEntity
Set objSS = ThisDrawing.SelectionSets.Add("all")
objSS.Select acSelectionSetAll
For Each entity In objSS
If entity.ObjectName = "AcDbBlockReference" Then
Set xref = ThisDrawing.Blocks(entity.Name)
End If
Next entity
For Each entity In xref
Set NewEntity = entity.Copy
NewEntity.Layer = "0"
Next entity
If Not objSS Is Nothing Then
objSS.Delete
End If
ThisDrawing.Regen acAllViewports
End Sub
It works... But not as I would like... Every entity is copied, but INSIDE
the XRef !
When I remove it, nothing stays on the screen. So it doesn't help me...
I've thought it was maybe because I send the entities on the "0" layer. But
it doesn't work. If I try to send an entity on a new layer from the
modelspace, it makes an error;
What can I do? Thanks for your help...
Alexis Perdaen
AM4D
Brussels, Belgium