Question For Wayne Tiffany

Discussion in 'SolidWorks' started by McBrian, Jan 6, 2006.

  1. McBrian

    McBrian Guest

    Hi Wayne

    I'm trying to use your BoundingBox.swp but it keeps failing, and I'm no
    guru when it comes to VB.

    I get a Microsoft Visual Basic Compile Error popup message "Object
    Library Feature Not Supported". It appears to stop at

    "Set swApp = CreateObject("SldWorks.Application")" line in the Sub
    Main() part of the code.

    I'm using SWX2005 SP3 on a Win 2000 SP4 PC.

    Any help would be much appreciated.

    Regards Brian
     
    McBrian, Jan 6, 2006
    #1
  2. McBrian

    TOP Guest

    Did you set the type library and constant library first? Found in
    Tools/References in the macro editor.
     
    TOP, Jan 9, 2006
    #2
  3. Did this suggestion help? You should set the reference to the proper
    version of the files that matches your installed SW version. If not, let us
    know.

    WT
     
    Wayne Tiffany, Jan 9, 2006
    #3
  4. McBrian

    McBrian Guest

    Hi Guys

    Thanks for the replies. The references appear to be correct,
    "c:\program files\solidworks\sldworks.tlb" for the Solidworks 2005 Type
    Library and "c:\program files\solidworks\swconst.tlb" for the
    Solidworks 2005 Constant Type Library. Can't see the version of these
    files but they were both created on 14/04/2005. I have tried to run the
    macro on five different installations (all SWX 2005 SP3) and get the
    same error on them all.
    All my other macros appear to work fine.

    Regards Brian
     
    McBrian, Jan 10, 2006
    #4
  5. McBrian

    McBrian Guest

    Hi Again

    Ok! I found a 2005 SP0.0 installation in another office, and HEY! no
    problem, works OK, just what were looking for (you code masters are a
    god send). I copied the 2 tlb files, renamed the ones in my
    installation and pasted the SP0.0 files into my SWX installation
    folder, and yup it works, SWX sucks sometimes.

    Now! how do I change it to list centimeters instead of millimeters in
    the custom properties ( the model is and always will be created in
    millimeters/grams).
    At the moment we manually add these bounding box dims as reference dims
    and change the properties to centimeters with one decimal place, this
    is then listed on the drawing by a linked note in the border template.

    Your help is much appreciated.

    Regards Brian
     
    McBrian, Jan 10, 2006
    #5
  6. Interesting thought - I don't think you can. The program respects the user
    selected units of the model and since the evaluated value of the custom
    properties is tied directly to properties, it will evaluate to the document
    units. You could add a routine that creates a new property by factoring the
    existing property and assigning a value to it, but then it would be a stupid
    number - not tied to anything active. If the geometry changed, that fudged
    value would not update on its own.

    Now, an even more interesting happening - the macro won't run on my SW2005
    SP5.0 installation either! Same error you are seeing. It appears that
    something has changed in that the method I used in this macro to attach to
    SW isn't valid any more. Other macros still work, and this one works in SW
    2006 SP3.0 by merely changing the referenced files. Hmmm - time to turn it
    in.

    WT
     
    Wayne Tiffany, Jan 10, 2006
    #6
  7. McBrian

    Blair Sutton Guest

    Brian,
    I would do the following to make BoundingBox.swp add properties in CM
    when doc units are MM.

    Do this in new macro BoundingBoxMM.swp by creating blank macro and
    cutting and pasting entire boundingbox.swp.

    1) Comment/delete 'Select Statement' that gets document's units (mm in
    this case)
    2) Add ConvFactor line immeadiately after select statement.

    'Select Case Part.GetUnits(0)
    ' Case swMM
    ' ConvFactor = 1 * 1000
    ' Case swCM
    ' ConvFactor = 1 * 100
    ....

    ConvFactor = 1 * 100 'assign ConvFactor to be equivalent to when doc
    units = cm.

    This overrides the user units for this macro.
    You can also do similar comments and override values for the
    messageboxes and answers.

    -----------------------------------------------
    Wayne,
    I'm very impressed with boundingbox.swp and excited to use it.
    Our company wants to know material usage better and bounding box could
    greatly simplify this.

    In your response to Brian, you wrote:

    You could add a routine that creates a new property by factoring the
    Does this mean the properties created by BoundingBox.Swp stay current
    when dimensions are changed after the macro is ran?

    I'm using boundingbox.swp with this in the header.
    ' * Modified by Wayne Tiffany, Oct 12, 2004
    ' * Updated 10/15/04
    Is this the latest?

    Thanks for creating this Macro and contributing so regularly on the
    forum.

    Sincerely, Blair
     
    Blair Sutton, Jan 11, 2006
    #7
  8. McBrian

    Blair Sutton Guest

    Brian,
    I would do the following to make BoundingBox.swp add properties in CM
    when doc units are MM.

    Do this in new macro BoundingBoxMM.swp by creating blank macro and
    cutting and pasting entire boundingbox.swp.

    1) Comment/delete 'Select Statement' that gets document's units (mm in
    this case)
    2) Add ConvFactor line immeadiately after select statement.

    'Select Case Part.GetUnits(0)
    ' Case swMM
    ' ConvFactor = 1 * 1000
    ' Case swCM
    ' ConvFactor = 1 * 100
    ....

    ConvFactor = 1 * 100 'assign ConvFactor to be equivalent to when doc
    units = cm.

    This overrides the user units for this macro.
    You can also do similar comments and override values for the
    messageboxes and answers.

    -----------------------------------------------
    Wayne,
    I'm very impressed with boundingbox.swp and excited to use it.
    Our company wants to know material usage better and bounding box could
    greatly simplify this.

    In your response to Brian, you wrote:

    You could add a routine that creates a new property by factoring the
    Does this mean the properties created by BoundingBox.Swp stay current
    when dimensions are changed after the macro is ran?

    I'm using boundingbox.swp with this in the header.
    ' * Modified by Wayne Tiffany, Oct 12, 2004
    ' * Updated 10/15/04
    Is this the latest?

    Thanks for creating this Macro and contributing so regularly on the
    forum.

    Sincerely, Blair
     
    Blair Sutton, Jan 11, 2006
    #8
  9. Updated 10/15/04 is the latest version that I have.

    Ok, I actually took a look at the way I wrote it back then and I see that my
    previous answer wasn't proper - sorry, bad memory.

    Every time you run the program, it queries the geometry to find the rough
    outline using a SW API call. Then it converts the return values (which are
    always in meters) to whatever the user units are in the document. The
    individual properties are then created as numbers, not properties, so they
    are totally stupid as far as no updating. If you use the default property,
    it creates it as text, but stuffs in numbers, not properties. If the 3D
    sketch is used, it's also stupid and it will create a new one each time the
    program is run.

    So, Blair's answer about the cm question is correct - just hard code it to
    always convert the numbers to cm. You don't have to create a new macro
    unless you want to retain a copy of the old one also.

    Also keep in mind that the program adds a small amount to all 3 dimensions
    and this value is changeable to suit your needs. In the section titled
    Main(), the next line has a variable called AddFactor - just change the
    default .015 to whatever you wish. It can also be 0 if desired.

    WT
     
    Wayne Tiffany, Jan 11, 2006
    #9
  10. I pursued this through our VAR to APISupport at SW and they replied with the
    following:

    "This issue is now fixed. Please remove the SldWorks type library
    reference, close the references dialog, add it back again, and save. This
    should fix the issue. I apologize for the inconvenience."

    Ok, I tried it and it did fix the problem on my machine. So I wrote back
    and asked why since the fix made no sense to me. If I receive more info,
    I'll update you. Otherwise just do the fix and enjoy it.

    WT
     
    Wayne Tiffany, Jan 12, 2006
    #10
  11. I asked the question of the proper person at SWW and got an answer as to why
    this procedure worked. When you save a macro, it compiles a certain amount
    of information into the macro and saves it with the macro file. Now,
    somewhere about SP3 or 4, they made a change to the type library such that
    the newer versions would not read properly without recompiling. So,
    following the procedure forced the macro to reread and recompile the info,
    thereby allowing it to properly read the type library file.

    And now you know the "rest of the story." :)

    WT
     
    Wayne Tiffany, Jan 27, 2006
    #11
  12. McBrian

    McBrian Guest

    Hi Guys

    Sorry I've not replied earlier, been tied up with other things but many
    thanks for the responses.
    I've eventually got round to making the changes suggested and it works
    a treat, the only problem I can't solve is that it now returns a number
    to 6 decimal places, any suggetions on how to get this down to two, the
    office VB guru has had a look and come up empty.

    Thanks in advance.

    Brian
     
    McBrian, Feb 3, 2006
    #12
  13. Quite interesting indeed. The code is written to set the rounding to the
    user setting, but when the property is written, it appears to always write
    it as 6 digits. I'll have to look into this one. Sorry.

    WT
     
    Wayne Tiffany, Feb 3, 2006
    #13
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.