See the top rated post in this thread. Click here

Results 1 to 8 of 8

Thread: Modify the parameters of dynamic blocks within another dynamic block

  1. #1
    100 Club
    Join Date
    2002-10
    Posts
    154
    Login to Give a bone
    0

    Question Modify the parameters of dynamic blocks within another dynamic block

    How to start..... I want to modify the parameters of dynamic blocks within another dynamic block.

    First off, I am not sure of the results Let's say you have Dynamic Block blkA inserted in Dynamic Block blkB..... You have blkB inserted several places in your drawing (let's call them 1B, 2B, 3B). If I make a routine that goes into 1B, then find it's blkA and modifies blkA's parameters, will it effect 2B and 3B.

    If it will not effect them all then let's move on....

    I understand how to access and modify the parameters of a dynamic block in Model or Paper Space, but how do I get to the sub block... in this case called blkA?

    I did not see anything under the AcadBlockReference that would show you it's objects. When I listed all of the blocks, it did not show any sub blocks. I used this code to list them.

    Code:
    Dim myLayout As AcadLayout, myEntity As AcadEntity
    For Each myLayout In ThisDrawing.Layouts
        For Each myEntity In myLayout.Block
            If myEntity.ObjectName = "AcDbBlockReference" Then
                Debug.Print myEntity.Handle
            End If
        Next myEntity
    next myLayout
    Last edited by Opie; 2007-02-01 at 09:59 PM. Reason: [CODE] tags added

  2. #2
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,409
    Login to Give a bone
    0

    Default Re: Modify the parameters of dynamic blocks within another dynamic block

    There's a lot of info in this forum on blocks, but basically, the block reference is equal to the Insert object. You need to find the name of the reference and then go to the Blocks collection and get the block definition. Like the layout, which is also a block, block definitions have a Block property. You have to repeat this process for each level of nested blocks you are searching for.
    C:> ED WORKING....


    LinkedIn

  3. #3
    100 Club
    Join Date
    2002-10
    Posts
    154
    Login to Give a bone
    0

    Default Re: Modify the parameters of dynamic blocks within another dynamic block

    I listed all of the blocks before doing anything.
    using (For Each aEntity In ThisDrawing.Blocks)
    it showed the following listed as Handle - Name
    1F - *Model_Space
    58 - *Paper_Space
    5D - *Paper_Space0

    then inserted 1 block in Model space, then did the same list and it added
    BA - SubBlock
    E1 - BaseBlock

    I Copied the block over in Model Space, and then it did the list again
    it still showed me the same thing. I then modified one of the BaseBlock's
    parameters and then ran the same list. It then added the following.
    101 - *U7

    I think that the 101 is the modified BaseBlock definition.

    I ran a list of the objects in Model Space and two block Handles in there were called F3 and F9.

    I guess that I just don't understand how to get to the block's collection.
    Is there any commands like the following that would get me to the object?

    For Each subBlk In myBlockRef
    or
    For Each subBlk In ThisDrawing.HandleToObject("E1")
    or
    For Each subBlk In ThisDrawing.Blocks("E1")
    or
    For Each subBlk In ThisDrawing.Blocks(1)
    or
    For Each BaseBlock In ThisDrawing.Blocks
    For Each subBlk In BaseBlock
    or
    For Each subBlk In BaseBlock.Collection

    I found "AcSmCalloutBlockReferences.GetDirectlyOwnedObjects" in the AutoCad Help files but it does not show how to use it or any real details about it. Is this something I should be looking for?

    Thanks,
    Jason

  4. #4
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,409
    Login to Give a bone
    0

    Default Re: Modify the parameters of dynamic blocks within another dynamic block

    There's a lot of info in this forum on blocks
    Jason, what I said was a hint to search this forum. I found 6 pages of threads dealing with blocks. Also, The vba developer guide is a good place to get info on acad's api. In the IDE, if you type in the name of an object type, e.g. AcadBlockReference and hit F1, it will take you right to it. Examine the properties and methods of a block ref (definition). It has a Block property. To drill down, get a single block ref and iterate it's Block collection. If it has a block insert in it, find that insert's block def, get it's Block collection and start iterating again, and so on. For code samples, do a search.

    The exercise you did was a good test. Now you see the kinds of ents that use block structures. The unnamed block "*U101" is either a dynamic block or part of a dimension. Take note of the threads in your search that deal with dynamic blocks. They are more complex than regular blocks.
    C:> ED WORKING....


    LinkedIn

  5. #5
    100 Club
    Join Date
    2002-10
    Posts
    154
    Login to Give a bone
    0

    Default Re: Modify the parameters of dynamic blocks within another dynamic block

    OK, I think that I have it.. the Name of the BlockReference located in Model or Paper space is equal to the Name of the Block located in ThisDrawing.Blocks. You can find it's nested BlockRederences under this.

    The only problem that I can see is that if you have two blocks or more inserted in Paper or Model space with all of the parameters and nested block parameters the same, then the inserted blocks use the same Name. Therefore if you modified the nested BlockReference, it would change all of the inserted BlockReferences located in paper or model space that use that Name.

    I am assuming that I would have to first check and see if more than one block has the same Name. If so, I would have to first temporally modify the primary block which I was trying to use so that it would give me a different Name. Then I could go in and modify it's nested blocks.

    Is this what I should do and am I on the right track??

    I have not gone any deeper than one block yet. So I am assuming that I will have to do this check for every level that I go in deeper so that it only modifies that one primary block.

  6. #6
    Administrator Opie's Avatar
    Join Date
    2002-01
    Location
    jUSt Here (a lot)
    Posts
    9,100
    Login to Give a bone
    0

    Default Re: Modify the parameters of dynamic blocks within another dynamic block

    Quote Originally Posted by jluker
    OK, I think that I have it.. the Name of the BlockReference located in Model or Paper space is equal to the Name of the Block located in ThisDrawing.Blocks. You can find it's nested BlockRederences under this.

    The only problem that I can see is that if you have two blocks or more inserted in Paper or Model space with all of the parameters and nested block parameters the same, then the inserted blocks use the same Name. Therefore if you modified the nested BlockReference, it would change all of the inserted BlockReferences located in paper or model space that use that Name.

    I am assuming that I would have to first check and see if more than one block has the same Name. If so, I would have to first temporally modify the primary block which I was trying to use so that it would give me a different Name. Then I could go in and modify it's nested blocks.

    Is this what I should do and am I on the right track??

    I have not gone any deeper than one block yet. So I am assuming that I will have to do this check for every level that I go in deeper so that it only modifies that one primary block.
    If you are modifying nested blocks, you need to make a copy of the nested block definition. You would need to then modify the primary block to use the new copy of the nested block.

    At least that is my understanding of it.
    If you have a technical question, please find the appropriate forum and ask it there.
    You will get a quicker response from your fellow AUGI members than if you sent it to me via a PM or email.
    jUSt

  7. #7
    Administrator Ed Jobe's Avatar
    Join Date
    2000-11
    Location
    Turlock, CA
    Posts
    6,409
    Login to Give a bone
    1

    Default Re: Modify the parameters of dynamic blocks within another dynamic block

    Quote Originally Posted by jluker
    OK, I think that I have it.. the Name of the BlockReference located in Model or Paper space is equal to the Name of the Block located in ThisDrawing.Blocks. You can find it's nested BlockRederences under this.
    Correct. The AcadBlock object doesn't provide an object that implements a collection interface, you you have to iterate using For...Next and the Count and Item properties.


    Quote Originally Posted by jluker
    The only problem that I can see is that if you have two blocks or more inserted in Paper or Model space with all of the parameters and nested block parameters the same, then the inserted blocks use the same Name. Therefore if you modified the nested BlockReference, it would change all of the inserted BlockReferences located in paper or model space that use that Name.
    That's the way blocks work. FYI, and anybody else reading this. In plain terms, here's what goes on under the hood when you insert a block saved in the dwg. You are only inserting a pointer object that just has origin, scale and rotation properties. It tells the graphics engine, draw whatever is stored in the block at this point. The 0,0 origin or BASE point gets mapped to the insertion point of the reference and the block is redrawn there. Now, if you browse out to a file during INSERT, the contents of that files modelspace are copied to this dwg's block table. A record is created in the database for the block and a sub-table is created with a record for each entity. Then you are prompted to proceed with the insertion as before. The exact same thing happens when you xref, only instead of copying the ents, they are just read into the block table each time the dwg opens or the xref is reloaded. The only difference between an AcadBlockReference and AcadExternalReference is that the xref has a prop for the path of the external file.


    Quote Originally Posted by jluker
    I am assuming that I would have to first check and see if more than one block has the same Name. If so, I would have to first temporally modify the primary block which I was trying to use so that it would give me a different Name. Then I could go in and modify it's nested blocks.
    That depends on your goal. You could prompt the user to select a block, get its name and do a filtered ss on the name and get the count of the resulting ss. Editing a block def, updates any inserts that reference it. To edit without changing them, first make a copy of the block def, then edit it. You then will not have any insertions that reference it. You will have to determine how to proceed from there. Insert a new one, or change the refrence of existing insertion/s to point to the new block def.
    Last edited by Ed Jobe; 2007-02-02 at 11:32 PM.
    C:> ED WORKING....


    LinkedIn

  8. #8
    100 Club
    Join Date
    2002-10
    Posts
    154
    Login to Give a bone
    0

    Default Re: Modify the parameters of dynamic blocks within another dynamic block

    I've started creating some routines over the weekend.. Thanks for the help.
    Jason

Similar Threads

  1. Modify Insertion Name? of Dynamic block
    By dmleves in forum AutoLISP
    Replies: 3
    Last Post: 2012-12-12, 01:11 AM
  2. Replies: 1
    Last Post: 2012-02-16, 06:58 PM
  3. New to Dynamic Blocks? LEARN!: Dynamic Block ATP's
    By Chris.N in forum Dynamic Blocks - Technical
    Replies: 0
    Last Post: 2007-07-15, 02:53 AM
  4. Replies: 6
    Last Post: 2006-04-03, 07:19 AM
  5. VBA to insert & modify Dynamic Blocks
    By mcoffman in forum VBA/COM Interop
    Replies: 5
    Last Post: 2006-02-07, 02:31 PM

Posting Permissions

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