API: Bitwise Options

Discussion in 'SolidWorks' started by Dave L, Sep 15, 2003.

  1. Dave L

    Dave L Guest

    Alright, I give. I have a macro that pulls up a drawing and performs
    various operations and everything works great, except I want to rebuild the
    views that are not up to date. I'm trying to use "ModelDoc.Rebuild (
    Options )", but I can't seem to get the bitwise options right. I've
    declared them, I think properly according to an example I've found:

    ....
    Const swRebuildAll = &H1
    Const swForceRebuildAll = &H2
    Const swUpdateMates = &H4
    Const swCurrentSheetDisp = &H8
    Const swUpdateDirtyOnly = &H10
    ....

    And used this:

    ....
    Rebuild = DrawingDoc.Rebuild(options)
    ....

    But, I've tried any number of different formats for the "options" variable;
    decimal, binary, hex, even the option name, but the most I get is some sort
    of partial rebuild where it seems to rebuild, but the object lines
    disappear. I'd prefer to update only those marked as needing it -
    swUpdateDirtyOnly. ???

    TIA,

    Dave
     
    Dave L, Sep 15, 2003
    #1
  2. Dave L

    Heikki Leivo Guest

    If you are trying to use more than one of
    Sorry, but this has to be a mistake; you need to use bitwise OR to put the
    flags together. Most usually SW constants are of type long. Bitwise AND is
    for testing, OR is for setting flags - this may, for sure, be confusing. A
    good rule of thumb for bitwise operations: if it seems logical, it is
    propably wrong. ;-) . So it should work by callig for example

    Const swForceRebuildAll as Long = &H2
    Const swUpdateDirtyOnly as Long = &H10
    .....
    Rebuild = DrawingDoc.Rebuild(swForceRebuildAll Or swUpdateDirtyOnly)

    Hope this helps!
    -h-
     
    Heikki Leivo, Sep 15, 2003
    #2
  3. Dave L

    Dave L Guest

    Thanks guys. I don't get any error, but it still doesn't update the views.
    I've actrually tried the exact syntax shown below before with no luck and
    I've tried AND. Oddly, the only option that seems to do anything is
    "swCurrentSheetDisp". All the object lines diappear. None of the other
    options seem to do anything.

    Thanks again,
    Dave
     
    Dave L, Sep 15, 2003
    #3
  4. im thinking this could be the problem. because microsoft controls the
    repainting of the screen. you may need to use this command.
    View::UpdateViewDisplayGeometry
     
    Sean Phillips, Sep 15, 2003
    #4
  5. I don't know if this makes it more intuitive, but you could use the "+" as
    your "OR" operator. i.e.,
    DrawingDoc.Rebuild(swForceRebuildAll + swUpdateDirtyOnly)

    One way of thinking about this is by way of a search engine analogy. If you
    search for "A or B" you get documents that contain "A"; you also get
    documents that contain "B". So the "OR" gives you BOTH document sets. In
    this case, the "OR" gives you both options.

    For what it's worth,
    Brenda
     
    Brenda D. Bosley, Sep 20, 2003
    #5
  6. Dave,

    A couple other things to check...

    1. Not all options are valid, depending on your Document type. The help
    file has a chart on this.
    2. The other thing I just noticed is that you're trying to get a return
    value off of the API call, and there is none for this one (assuming you're
    using VB, which it looks like from your sample lines)
    In other words, the call should just be

    DrawingDoc.Rebuild(swForceRebuildAll Or swUpdateDirtyOnly)

    --Brenda
     
    Brenda D. Bosley, Sep 20, 2003
    #6
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.