TheSwamp

Code Red => VB(A) => Topic started by: Guest on September 10, 2007, 01:40:17 PM

Title: Xdata from pline in xref, selection boundary from pline for counting blocks
Post by: Guest on September 10, 2007, 01:40:17 PM
I've got a program that I'm working on which reads xdata attached to a pline.  That pline is then used as a selection boundary for counting blocks within that pline.  Now I'm starting to think about being able to read the xdata on the pline from within an xref - I don't think that'll be too hard to do.  The issue that I'm having a hard time wrapping my head around is the part about using the pline from the xref as a selection boundary.  Is the process similar to a selection set within a host drawing?  And how do I determine if the nested pline has blocks within it?  Is this going to be a big headache to accomplish?  And what if the host drawing has blocks within the pline of the xref?  Will the host's blocks be counted?  (I hope not).

I haven't done too much with accessing info from xrefs other than a simple count of all blocks (including those within the host drawing).


Any thoughts or words of wisdom regarding this?
Title: Re: Xdata from pline in xref, selection boundary from pline for counting blocks
Post by: deegeecees on September 10, 2007, 01:54:26 PM
Pseudo thinking:

Use the coordinates for the pline, and pass it to a selectionset for a WP method, using filtering of course.

Am I on the right track?
Title: Re: Xdata from pline in xref, selection boundary from pline for counting blocks
Post by: LE on September 10, 2007, 01:58:07 PM
It is going to be a very difficult task..... I would do it by binding the xref's as insert and exploded - and from there to do the selections as what I did in my latest code samples for superburst and mytrim in the show your stuff.... but wait for the real masters.....
Title: Re: Xdata from pline in xref, selection boundary from pline for counting blocks
Post by: Bryco on September 11, 2007, 10:41:08 AM
How hard it is depends on your set up.
Typically you use a matrix to figure out where an indivual entity is in a blockreferene or xref as the block gives you the info at zero rotation and origin zero.
If your xref is at a scale of 1,  has an origin 0,0,0 , isnt rotated and has a normal 0,0,1 then there is no need for a matrix.
The code below assumes all that (use a selset function) and uses an xref with only 1 rectangle in it.
Code: [Select]
Sub SELFROMX()

    Dim x As AcadExternalReference
    Dim B As AcadBlock
    Dim SS As AcadSelectionSet
    Dim xname As String
    xname = "3"
    Set SS = SSet(2, xname)
    If SS.count <> 1 Then Exit Sub
    Set x = SS(0)
    SS.Delete
    Dim E As AcadEntity, P As AcadLWPolyline
    For Each E In ThisDrawing.Blocks(xname)
        If TypeOf E Is AcadLWPolyline Then
            Set P = E
            Exit For
        End If
    Next
    Dim P1(2) As Double, P2(2) As Double
    P1(0) = P.Coordinate(0)(0)
    P1(1) = P.Coordinate(0)(1)
    P1(2) = P.Elevation
    P2(0) = P.Coordinate(2)(0)
    P2(1) = P.Coordinate(2)(1)
    P2(2) = P.Elevation

    Set SS = ThisDrawing.SelectionSets.Add("SS")
    SS.Select acSelectionSetWindow, P1, P2
    Debug.Print SS.count
End Sub

Title: Re: Xdata from pline in xref, selection boundary from pline for counting blocks
Post by: FengK on September 11, 2007, 12:40:05 PM
i think Matt wants to selection objects from within Xref, not in the current drawing. right?
Title: Re: Xdata from pline in xref, selection boundary from pline for counting blocks
Post by: Guest on September 11, 2007, 12:58:54 PM
i think Matt wants to selection objects from within Xref, not in the current drawing. right?

Uh huh!  I'm already getting the info from the current drawing.  I was hoping to xref all of the files into one temporary drawing then do a mass take off using my already existing xdata plines as boundaries.