block instances and properties

Discussion in 'SolidWorks' started by blisspikle, Jul 28, 2005.

  1. blisspikle

    blisspikle Guest

    Hello All,

    I am doing schematics just as drawings in SW and I created a bunch of
    blocks that I use all the time, most of them I imported from AutoCAD.
    I drop the pinout from a machine in and all the attributes are labeled
    as follows.

    I:1/09 where I = Input Card 1 = slot and 9 = bit.

    When I drop one of these cards in I have been going through and
    manually changing all of the attributes. This is usually just changing
    the slot numbers on all the attributes. What I would like to do is
    pull in a block set one attribute and all of the slot numbers will
    change. Is this possible?

    I was thinking linked properties would offer a way to do this. I can
    not seem to set a property that is only useful to one instance of the
    block.

    Thank you,
     
    blisspikle, Jul 28, 2005
    #1
  2. blisspikle

    CS Guest

    You can use custom properties but only if you only need a single block
    in the drawing. Another thing you can do is to use a macro that would
    fill the attributes on insertion or from a custom property or a string
    from the user
     
    CS, Jul 29, 2005
    #2
  3. blisspikle

    blisspikle Guest

    Is there a good place to learn about macro programming in solidworks?
    I do quite a bit of excel and this seems a little different. I tried
    recording a macro that I could select the block that I want to change
    and play a macro. I can not seem to get it working.

    Thank you,
     
    blisspikle, Aug 1, 2005
    #3
  4. blisspikle

    TOP Guest

    Not all the functionality of the GUI is available in the API. A shame
    it is; but that is how it is. It may be with blocks that you have to
    figure it out as I think they are treated as annotations. Now as to
    learning the SW API there is a lot of information available. Go into
    the downloads section of the SW website and look through the two API
    download sections. There are specific examples and what amount to
    tutorials on how SW wants you to do things. I wouldn't call either
    rigourously complete, but there is a lot there.
     
    TOP, Aug 1, 2005
    #4
  5. blisspikle

    CS Guest

    Here is what I would do. Since you are going to have alot of coppies
    of a block in one drawing I would create the block with one attribute
    that is invisible named something like BlockName-ID since it is
    invisible you can use this ID to Identify which block is which for
    later editing if needed.

    I would have your program insert the block and fill it in from a form
    or something.

    Set MyBlock = dwgdoc.insertBlock(PathOnly + "\BlockName.SLDBLK", x, y,
    0#, Bscale)
    'note the x and y dims are in meters so you will have to convert your
    units to meters
    'Then You can edit the text of the block
    MyBlock.SetAttributeValue "BlockName-ID", "BlockName-1"

    'then you can retriev these values like this

    msgbox = MyBlock.GetAttributeValue("BlockName-ID")

    'You can also find your block later

    Set thisView = dwgdoc.GetFirstView
    Set blockInst = thisView.GetFirstBlockInstance
    while blockInst.GetAttributeValue("BlockName-ID") <> "BlockName-1" and
    not BlockInst is nothing
    blockInst = BlockInst.GetNext
    wend

    If blockInst is nothing then
    Msgbox "Didn't find an instance named BlockName-1"
    exit sub
    end if

    'if your code gets here then you have your block instance found


    Good luck

    Corey
     
    CS, Aug 4, 2005
    #5
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.