+ Reply to Thread
Results 1 to 5 of 5
  1. #1
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Aug 2008
    Posts
    3

    Default VBA: choosing dynamic block attributes

    Registered forum members do not see this ad.

    Hello,

    I have 4 blocks which I have made. 3 of the blocks have a single visibility attribute which have 16 possible choices. The final block is similar with only 4 choices (each corresponding to 4 of the 16 visibility state choices of the other blocks).

    What I want to do is to automate the following task:
    1. Open an existing file containing these block references layed out on the model space as required.
    2. Select one combination of the visibility states
    3. Save the file with a particular file name (indicating which visibility states have been selected)
    4. Repeat steps 2 and 3 for the rest of the 16 visibility state combinations

    This way, rather than maintaining 16 DWG files, if there is a change, I can update the blocks in the original file and then run this automation to update (recreate) all 16 files.

    Because I am working with multiple files, I decided to go with VBA, not AutoLISP. If this is a bad decision, please tell me.

    THE PROBLEM
    No matter how I try to, I can't figure out how to get a handle to/variable for existing objects in the drawing. I know how to create a new line, or even a new block, but the blocks I am dealing with are too complicated (and not maintainable for that matter) to be created in hard code.

    Sometimes it is possible to find the "block" I am after to manipulate, but this seems to me to be more the object "in the block editor" rather than the copy in the drawing itself (i.e. block reference).

    How can I find an existing BlockReference object from within a drawing, so that I can manipulate the dynamic block properties I have created?

    Thanks,

  2. #2
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,786

    Default

    There are a lot of examples here for editing attributes using VBA its very simple to make new code to do change attributes to 1 or multiple blocks
    here is a quick example to select all blocks the secondary criteria rem out looks for block name SCHEDTEXT

    Code:
     
    FilterDXFCode(0) = 0
    FilterDXFVal(0) = "INSERT"
    'FilterDXFCode(1) = 2
    'FilterDXFVal(1) = "SCHEDTEXT"
    Set SS = ThisDrawing.SelectionSets.Add("pit1sel")
    SS.Select acSelectionSetAll, , , FilterDXFCode, FilterDXFVal

  3. #3
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Aug 2008
    Posts
    3

    Default

    There are a lot of examples here for editing attributes using VBA its very simple to make new code to do change attributes to 1 or multiple blocks
    here is a quick example to select all blocks the secondary criteria rem out looks for block name SCHEDTEXT
    Thank you for your help. I didn't get what you said right away. Now I have looked up help on filters and selection sets I understand a bit better. Just for future reference, punctuation is our friend

    Code:
    FilterDXFCode(0) = 0
    FilterDXFVal(0) = "INSERT"
    I have a question, what does this find? What type of entity is INSERT?


    Code:
    Set SS = ThisDrawing.SelectionSets.Add("pit1sel")
    Also, what is "pit1sel"?
    Thanks,
    Last edited by CADenator; 12th Aug 2008 at 12:49 am. Reason: added extra question

  4. #4
    Forum Newbie
    Using
    AutoCAD 2008
    Join Date
    Aug 2008
    Posts
    3

    Default confused :S

    Hello,

    It seems I have confused myself. When I said attributes before, I didn't mean a text tag that you enter. I meant the selections you can make with a dynamic block reference.

    How do you change what dynamic selections are made on a dynamic block reference?

    Thanks,

  5. #5
    Forum Deity
    Using
    Civil 3D 2013
    Join Date
    Dec 2005
    Location
    GEELONG AUSTRALIA
    Posts
    3,786

    Default

    Registered forum members do not see this ad.

    Just a quick answer to cadenator

    the insert value is the same as saying look for blocks

    the pitsel1 is a name I have given to be used for the data list it could be anything the other modules have pitsel2 3 4 etc

Similar Threads

  1. Dynamic block with dynamic attributes
    By Helenka in forum AutoCAD Drawing Management & Output
    Replies: 14
    Last Post: 28th Jul 2012, 09:56 am
  2. Attributes in Dynamic Blocks..
    By hardwired in forum AutoCAD Drawing Management & Output
    Replies: 8
    Last Post: 27th Mar 2008, 02:53 pm
  3. Limit on visibility attributes of a dynamic block?
    By Archetype05 in forum AutoCAD Drawing Management & Output
    Replies: 2
    Last Post: 31st Jan 2008, 11:28 pm
  4. Dynamic Blocks and Attributes
    By dbroada in forum AutoCAD Drawing Management & Output
    Replies: 5
    Last Post: 18th Jan 2007, 05:08 pm
  5. dynamic block attributes?
    By maxholer in forum AutoCAD General
    Replies: 6
    Last Post: 25th May 2005, 12:59 pm

Bookmarks

Posting Permissions

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