Author Topic: BlockTableRecord Collection  (Read 1650 times)

0 Members and 1 Guest are viewing this topic.

WOWENS

  • Newt
  • Posts: 60
BlockTableRecord Collection
« on: June 14, 2012, 11:26:37 AM »
1. first I have a drawing called "test1" its empty
2. and a drawing call "Dwg1" Inside this drawing is a block called "Block1"
3. now after I insert Drawing "Dwg1" into drawing "test1" I explode "dwg1" then I save and close the drawing test1.
4. now I run this code on drawing Test1 and it gives me a block count of 2 for block called "Block1"
   but there is only one block Reference in the drawing called "Block1"
   yes I know when I inserted the Drawing "dwg1" is comes in as a block called "dwg1" and inside that Block is a block called "block1"
   I understand when I explode Dwg1 it leaves Block1 in model space but the code shows that there are 2
   Block References for block Block1 thats the part i do not understand. when i check the
   Block Reference (bref.BlockName one will = dwg1 and the other will = *Model_Space) so why does is show a
   bref.BlockName to Block1 after block1 was exploded. if i purge the drawing and then run my code the count is 1

Public Sub DwgTest(ByVal pathtodwg As String, ByVal blockname As String)
        Dim db As Database = New Database(False, False)

        If IO.File.Exists(pathtodwg) = True Then
            db.ReadDwgFile(pathtodwg, System.IO.FileShare.Read, False, Nothing)

            Using Trans As Transaction = db.TransactionManager.StartTransaction
                Dim bktbl As BlockTable = db.BlockTableId.GetObject(OpenMode.ForRead)

                Dim revblk As BlockTableRecord = bktbl(blockname).GetObject(OpenMode.ForRead)
                Dim refs As ObjectIdCollection = revblk.GetBlockReferenceIds(False, False)
                MsgBox(refs.Count.ToString)
            End Using
        End If
        db.Dispose()
    End Sub

owenwengerd

  • Bull Frog
  • Posts: 451
Re: BlockTableRecord Collection
« Reply #1 on: June 14, 2012, 11:31:03 AM »
Immediately after you insert Dwg1, there is one Block1 reference in the Dwg1 block table record. Then when you explode the Dwg1 reference, you're making a copy of the original Block1 reference, so you end up with two block references: one in the Dwg1 block table record, and one in the *Model_Space block table record.
« Last Edit: June 14, 2012, 11:34:29 AM by owenwengerd »

WOWENS

  • Newt
  • Posts: 60
Re: BlockTableRecord Collection
« Reply #2 on: June 14, 2012, 11:33:33 AM »
thank you

Jeff H

  • Needs a day job
  • Posts: 6150
Re: BlockTableRecord Collection
« Reply #3 on: June 14, 2012, 11:56:43 AM »
What does GetBlockReferenceIds(True, False) give you?
 
*************Edit***************
Same thing did not think that through
« Last Edit: June 14, 2012, 12:13:11 PM by Jeff H »

WOWENS

  • Newt
  • Posts: 60
Re: BlockTableRecord Collection
« Reply #4 on: June 14, 2012, 02:43:27 PM »
the same