Xref bind and explode problem

Discussion in 'AutoCAD' started by sjohnson100, Nov 23, 2004.

  1. sjohnson100

    sjohnson100 Guest

    Hi All,

    I'm creating an app that will attach, bind and then explode several xrefs. The code to attach and bind works but when I explode, I get run time error "Not applicable". If I run the explode portion of the code separately, it works fine.

    What seems to happen is that the database doesn't get updated after the xref is bound and, while the sub is still running it thinks the object is still an xref.

    I've tried the block.update and Application.update method with no sucess. Is there another way to refresh the database after my xref is bound?

    fyi. I tried just inserting and exploding but it leads to dealing with other overlayed xrefs and stuff that I don't want in the drawing.

    Thanks in Advance

    Scott
     
    sjohnson100, Nov 23, 2004
    #1
  2. sjohnson100

    Paul Turvill Guest

    Why go through all those extra steps? Just INSERT (-insert) the file as a
    block. If you prefix the filename with an asterisk (*), it will be inserted
    already exploded.
    ___
     
    Paul Turvill, Nov 23, 2004
    #2
  3. sjohnson100

    sjohnson100 Guest

    I need to delete objects from selected layers and It seemed simple enough to explode the object and walk through the returned array, deleting what I need without fear of deleting something unexpectedly.
     
    sjohnson100, Nov 23, 2004
    #3
  4. sjohnson100

    Paul Turvill Guest

    I don't understand what you hope to accomplish. Physically and logically
    there's no difference between Attaching and Binding an XRef and simply
    INSERTing it as a block.
    ___
     
    Paul Turvill, Nov 23, 2004
    #4
  5. sjohnson100

    sjohnson100 Guest

    I agree that both methods are the same, except, if the drawing you're inserting has xrefs overlayed in it or even xref that are unloaded. Those overlayed/unloaded xrefs become standard blocks and it just adds another layer of checking and cleanup.

    The main purpose of the app is to build survey related drawings from pieces of many different drawings, which, others in the company use as xrefs for working drawings. Personally, I would prefer to attach the needed files as xrefs, freeze some layers and be done. But, they need to edit the data for their field crews. They currently open each drawing, freeze layers and copy/paste the entities they need to another dwg. I want to accomplish the same task.
     
    sjohnson100, Nov 24, 2004
    #5
  6. sjohnson100

    Art Cooney Guest

    I don't know what version of Acad you're working with, so this may be of no
    use to you, but in Acad 2005, xrefs in inserted drawings stay as xrefs and
    are resolved if possible.
     
    Art Cooney, Nov 24, 2004
    #6
  7. sjohnson100

    sjohnson100 Guest

    I'm using AutoCAD 2004 (Civil series)

    To test things I separated into two subs, one to attach and bind while the other explodes and it works. I'm puzzled why the database isn't updated immediately but for now it's a work around. So to recap, these two subs work as they are but if the code is combined to one sub, it fails.

    Here are the two subs if anyone is curious:

    Sub test1()
    Dim acXref As AcadExternalReference
    Dim InsertPoint(0 To 2) As Double

    InsertPoint(0) = 0: InsertPoint(1) = 0: InsertPoint(2) = 0

    Set acXref = ThisDrawing.ModelSpace.AttachExternalReference("C:\foo.dwg", "foo", InsertPoint, 1, 1, 1, 0, True)
    ThisDrawing.Blocks("foo").Bind True
    End Sub

    Sub test2()
    Dim gpCode(1) As Integer
    Dim dataValue(1) As Variant
    Dim groupCode As Variant, dataCode As Variant
    Dim vEnts As Variant
    Dim ssXref As AcadSelectionSet

    On Error Resume Next
    ThisDrawing.SelectionSets("SSET").Delete
    On Error GoTo 0
    Set ssXref = ThisDrawing.SelectionSets.Add("SSET")
    sXrefName = "foo"
    gpCode(0) = 0
    gpCode(1) = 2
    dataValue(0) = "INSERT"
    dataValue(1) = sXrefName
    groupCode = gpCode
    dataCode = dataValue
    ssXref.Select acSelectionSetAll, , , groupCode, dataCode
    If ssXref.Count > 0 Then
    vEnts = ssXref.Item(0).Explode
    Set acBlockRef = ssXref.Item(0)
    vEnts = acBlockRef.Explode
    End If
     
    sjohnson100, Nov 24, 2004
    #7
  8. sjohnson100

    Ted Schaefer Guest

    I created a bind/purge/compact app a couple year ago, and found that explode
    didn't work worth a hoot.
    Not sure why this AutoCAD well known bug has persisted through so many
    version of AutoCAD.

    Just use the in-elegant sendcommand:


    Public Sub ExplodeEX(oBlkRef As AcadBlockReference, odwg As AcadDocument)
    Dim strCmd As String
    Const DbQt As String = """"

    On Error Resume Next
    SetObjectSpace oBlkRef, odwg
    If Not ThisDrawing.Blocks(oBlkRef.Name).IsXRef Then
    strCmd = "(command " & DbQt & "explode" & DbQt & " (handent " & DbQt &
    oBlkRef.Handle & DbQt & "))" & vbCr
    odwg.SendCommand strCmd
    End If

    End Sub

    Public Sub SetObjectSpace(varEnt As Variant, odwg As AcadDocument)
    Dim varPnt As Variant
    Dim oBlk As AcadBlock

    Set oBlk = ThisDrawing.ObjectIdToObject(varEnt.OwnerID)
    If StrComp(oBlk.Name, "*Paper_Space", vbTextCompare) = 0 Then
    odwg.ActiveSpace = acPaperSpace
    ElseIf StrComp(oBlk.Name, "*Model_space", vbTextCompare) = 0 Then
    odwg.ActiveSpace = acModelSpace
    End If
    End Sub



    other explodes and it works. I'm puzzled why the database isn't updated
    immediately but for now it's a work around. So to recap, these two subs work
    as they are but if the code is combined to one sub, it fails.
    ThisDrawing.ModelSpace.AttachExternalReference("C:\foo.dwg", "foo",
    InsertPoint, 1, 1, 1, 0, True)
     
    Ted Schaefer, Dec 6, 2004
    #8
Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.