Results 1 to 3 of 3

Thread: Inserting dynamic block reference loses the properties

  1. #1
    Member
    Join Date
    2015-01
    Posts
    27
    Login to Give a bone
    0

    Default Inserting dynamic block reference loses the properties

    Hi all,
    I'm trying to insert a reference of an already existing dynamic block, but when I use the following code the inserted block reference loses all the properties (in fact, if I debug it the block has isDynamicBlock set to False).

    Code:
    Using blockRef As New BlockReference(insertPoint, curBlock)
        ms.AppendEntity(blockRef)
        ' ts is the already opened transaction
        ts.AddNewlyCreatedDBObject(blockRef, True)
        
        Dim dynBlockDef As BlockTableRecord = TryCast(blockRef.DynamicBlockTableRecord.GetObject(OpenMode.ForRead), BlockTableRecord)
        ' The following part never gets executed because the block reference is not dynamic.
        For Each prop As DynamicBlockReferenceProperty In blockRef.DynamicBlockReferencePropertyCollection
            Select Case prop.PropertyName
                Case "lenght"
                    prop.Value = length
                Case "width"
                    prop.Value = width
            End Select
        Next
    End Using
    What am I missing? I can't find anything that can help me on the net, only ways to access the properties of and already placed dynamic block reference.

  2. #2
    I could stop if I wanted to
    Join Date
    2007-08
    Posts
    202
    Login to Give a bone
    0

    Default Re: Inserting dynamic block reference loses the properties

    Hi,

    I see nothing wrong in this snippet (just an useless line with "Dim dynBlockDef ...").

    I suspect "curBlock" is the ObjectId of an anonymous block definition (i.e. someDynamicBlockReference.BlockTableRecord) instead of the root definition (i.e. someDynamicBlockReference.DynamicBlockTableRecord).

  3. #3
    Member
    Join Date
    2015-01
    Posts
    27
    Login to Give a bone
    0

    Default Re: Inserting dynamic block reference loses the properties

    Quote Originally Posted by _gile View Post
    Hi,

    I see nothing wrong in this snippet (just an useless line with "Dim dynBlockDef ...").

    I suspect "curBlock" is the ObjectId of an anonymous block definition (i.e. someDynamicBlockReference.BlockTableRecord) instead of the root definition (i.e. someDynamicBlockReference.DynamicBlockTableRecord).
    Hi _gile, thank you so much!
    You guessed it right, I was passing the BlockTableRecord objectID instead of the DynamicBlockTableRecord objectID!
    Now everything works fine.
    Thanks again!

    PS: the useless line is useful for some other code I omitted

Similar Threads

  1. 2012: Dynamic Block loses its Visability function when inserting
    By Darren Allen in forum Dynamic Blocks - Technical
    Replies: 5
    Last Post: 2012-11-20, 03:00 PM
  2. Visibility state when inserting a Dynamic Block
    By autocad.wishlist1734 in forum AutoCAD Wish List
    Replies: 2
    Last Post: 2012-06-13, 01:10 PM
  3. Retain Layer Properties When Inserting Block with Design Center
    By miket.203279 in forum AutoCAD General
    Replies: 8
    Last Post: 2009-08-28, 09:48 AM
  4. Dynamic block loses ability
    By wjwydock in forum Dynamic Blocks - Technical
    Replies: 12
    Last Post: 2008-11-20, 10:18 PM
  5. Dynamic Block loses parts when exploded
    By pbrumberg in forum Dynamic Blocks - Technical
    Replies: 8
    Last Post: 2006-06-26, 07:10 PM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •