Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How to copy entities from a XRef to modelspace?

185 views
Skip to first unread message

AM4D

unread,
Apr 24, 2002, 7:38:32 AM4/24/02
to
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


Brian D.

unread,
Apr 24, 2002, 9:10:09 AM4/24/02
to
When you insert it, all you have in modelspace to copy is the insert itself.
Try to bind, then explode it. Not even a need for VB.

Brian D.


"AM4D" <alexis....@skynet.be> wrote in message
news:0F35880CC092449B...@in.WebX.maYIadrTaRb...

Bobby C. Jones

unread,
Apr 24, 2002, 9:28:07 AM4/24/02
to
Look at the CopyObjects method instead of Copy.
--
Bobby C. Jones
http://www.acadx.com

AM4D

unread,
Apr 24, 2002, 9:12:01 AM4/24/02
to
The problem is that the file is corrupted. When I bind it, I get a fatal
error...
I think the only way to recover my drawing is to find a method to export
each entity of my XRef, one by one, to the modelspace...

You maybe have another idea...

Thanks
"Brian D." <bcd...@hiwaay.com.{Remove-This-To-Reply}> a écrit dans le
message de news: E08B61FAEFFCB9D9...@in.WebX.maYIadrTaRb...

AM4D

unread,
Apr 24, 2002, 9:29:09 AM4/24/02
to
Hello, Bobby,

I have already tried it... with the same problem. The copied object stays
inside of the XRef...


"Bobby C. Jones" <bob...@acadx.com> a écrit dans le message de news:
f0d6...@WebX.maYIadrTaRb...

Brian D.

unread,
Apr 24, 2002, 9:44:05 AM4/24/02
to
I haven't tried it, but I believe you can get to the objects in the Xref
through the "XRefDatabase" property.

An Xref is a block insert. Find the block record in the blocks collection,
then take the XRefDatabase property from it. Dig through it for your
entities.

Brian D.


"AM4D" <alexis....@skynet.be> wrote in message

news:229CCB5701DC1260...@in.WebX.maYIadrTaRb...

Bobby C. Jones

unread,
Apr 24, 2002, 10:29:08 AM4/24/02
to
You must provide the modelspace object as the owner argument.

--
Bobby C. Jones
http://www.acadx.com

"AM4D" <alexis....@skynet.be> wrote in message
news:D83780435F48FB73...@in.WebX.maYIadrTaRb...

Andy Freeland

unread,
Apr 24, 2002, 10:22:09 AM4/24/02
to
Try inserting (as block) the XREF file into a new drawing (if successful
then save)
Try exploding the block (if successful then save)
Try zoom extents (if successful then save)

If the above trials are unsuccessful then you can try using the partial open
command to read in a layer at a time. You will probably read in one or two
layers that cause the problem again. Just avoid those layers when doing the
partial open (the next time) and SaveAs the drawing to another name after
you have as much as you can salvage.

HTH, Andy


Alan McCormack

unread,
Apr 25, 2002, 4:04:00 PM4/25/02
to
If you can get a copy of IntelliCAD, try opening the file with it.
(I've found that it will open many corrupted files that AutoCAD
won't.) If you're successful, simply save it under a new name and then
open the new file in AutoCAD.
0 new messages