VBA
Discuss AutoCAD ActiveX and VBA (Visual Basic for Applications) questions here.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Getting all XRef's In VBA

3 REPLIES 3
Reply
Message 1 of 4
Anonymous
1844 Views, 3 Replies

Getting all XRef's In VBA

I am trying to find out all the XRefs for a document in the following way,

--
Sub getxrefs()
Dim myXRefs As AcadExternalReference
For Each myXRefs In ActiveDocument.ModelSpace
MsgBox myXRefs.Path
Next
UserForm1.Show
End Sub
--

This is fine for ModelSpace XRefs but I would to get all the XRefs for
PaperSpace as well. I thought that it would be a case of changing the third
line to 'For Each myXRefs In ActiveDocument.PaperSpace' but this does not
work.

Any help with PaperSpace XRef's would be most gratefully received.

Barry Bell
3 REPLIES 3
Message 2 of 4
Anonymous
in reply to: Anonymous

Cycle through the Blocks colelction checking the IsXref
property. When it returns True, create a filtered selection
set using the name of that block. Doing so will yield every
xref insert regardless of which space block it is contained
in:

Dim blkDef As AcadBlock, xref As AcadExternalReference
Dim fType(1) As Integer, fData(1)
Dim ss As AcadSelectionSet

Set ss = ThisDrawing.Selectionsets.Add("ss")

fType(0) = 0 : fData(0) = "INSERT"
fType(1) = 2

For Each blkDef In ThisDrawing.Blocks
If blkDef.IsXref Then
fData(1) = blkDef.Name
ss.Select , , fType, fData
For Each xref In ss

Next
End If
Next

--
http://www.acadx.com


"Barry Bell" wrote in message
news:2DD44CAEE63F7A534C96A915FBD0E4BF@in.WebX.maYIadrTaRb...
> I am trying to find out all the XRefs for a document in
the following way,
>
> --
> Sub getxrefs()
> Dim myXRefs As AcadExternalReference
> For Each myXRefs In ActiveDocument.ModelSpace
> MsgBox myXRefs.Path
> Next
> UserForm1.Show
> End Sub
> --
>
> This is fine for ModelSpace XRefs but I would to get all
the XRefs for
> PaperSpace as well. I thought that it would be a case of
changing the third
> line to 'For Each myXRefs In ActiveDocument.PaperSpace'
but this does not
> work.
>
> Any help with PaperSpace XRef's would be most gratefully
received.
>
> Barry Bell
>
>
Message 3 of 4
Anonymous
in reply to: Anonymous

So if there is no dxf code to for getting a selection set of Xref's. Using
the code supplied by frank. How can I change the layer of the xref? I have
tried several things and nothing has worked for me.

Heath

"Frank Oquendo" wrote in message
news:589EA01EC18CE849DC5F8EB4ACFB9CC3@in.WebX.maYIadrTaRb...
> Cycle through the Blocks colelction checking the IsXref
> property. When it returns True, create a filtered selection
> set using the name of that block. Doing so will yield every
> xref insert regardless of which space block it is contained
> in:
>
> Dim blkDef As AcadBlock, xref As AcadExternalReference
> Dim fType(1) As Integer, fData(1)
> Dim ss As AcadSelectionSet
>
> Set ss = ThisDrawing.Selectionsets.Add("ss")
>
> fType(0) = 0 : fData(0) = "INSERT"
> fType(1) = 2
>
> For Each blkDef In ThisDrawing.Blocks
> If blkDef.IsXref Then
> fData(1) = blkDef.Name
> ss.Select , , fType, fData
> For Each xref In ss
>
> Next
> End If
> Next
>
> --
> http://www.acadx.com
>
>
> "Barry Bell" wrote in message
> news:2DD44CAEE63F7A534C96A915FBD0E4BF@in.WebX.maYIadrTaRb...
> > I am trying to find out all the XRefs for a document in
> the following way,
> >
> > --
> > Sub getxrefs()
> > Dim myXRefs As AcadExternalReference
> > For Each myXRefs In ActiveDocument.ModelSpace
> > MsgBox myXRefs.Path
> > Next
> > UserForm1.Show
> > End Sub
> > --
> >
> > This is fine for ModelSpace XRefs but I would to get all
> the XRefs for
> > PaperSpace as well. I thought that it would be a case of
> changing the third
> > line to 'For Each myXRefs In ActiveDocument.PaperSpace'
> but this does not
> > work.
> >
> > Any help with PaperSpace XRef's would be most gratefully
> received.
> >
> > Barry Bell
> >
> >
>
>
Message 4 of 4
Anonymous
in reply to: Anonymous

An xref is another type of insert. Once you've collected the inserts
using a filtered selection set, you can cast the AcadBlockReference to
an AcadExternalReference:

Dim xref As AcadExternalReference

For Each xref In ss
xref.Layer =
Next

--
http://www.acadx.com


"Heath" wrote in message
news:5389EAF53953098CDEADF430B8808801@in.WebX.maYIadrTaRb...
> So if there is no dxf code to for getting a selection set of Xref's.
Using
> the code supplied by frank. How can I change the layer of the xref?
I have
> tried several things and nothing has worked for me.
>
> Heath

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report

”Boost