Weight Calculation Macro

Discussion in 'SolidWorks' started by msweeney, Jan 24, 2008.

  1. msweeney

    msweeney Guest

    I am looking for a macro that will calculate the weight of a sheet
    metal part. The SW Mass property subtracts any hole cutouts I have
    from the overall weight. I need to calculate the weight of the piece
    before any cutouts happen. Basically a (length x width) x lbs/ft in-
    the-flat calculation. This will give me the weight of the actual
    material consumed, rather than the weight of the finished product. Is
    there anything out there that can do this?

    Thanks in advance.
    Mark
     
    msweeney, Jan 24, 2008
    #1
  2. msweeney

    msweeney Guest


    I'm looking for something more automated than this. If one of our
    engineers forgot to get the weight in the beginning, he'd have to
    suppress all of his cutouts, get the mass then unsuppress everything
    again. It would be nice to just push a button at any time in the
    creation process and get the total material usage, put it into a
    custom property which can then be exported into DBWorks and finally
    our MRP system. But if I can't get something like this, then your
    idea is probably the simplest route.

    Thanks
     
    msweeney, Jan 25, 2008
    #2
  3. When making the sheet metal part I'd say make a config pre-cutouts (do
    this after making all bends and before you start making cutouts).
    Then add all the cutouts under the 2nd config. Then just switch to
    the one config and do the mass prop, or...

    You could also then have that massprop config in your drawing (hidden)
    with a note linked to that hidden view calling for the PRP$"SW-mass"
    prop (or whatever it is). That way you can automate the info into
    your sheet with minimal additions to your part, and it will auto
    update on any part changes.

    Through a macro it'd be a lot trickier, when you can do the same thing
    just as easily by just adding a config at your split point of adding
    cutouts/holes.

    You can use a macro to auto add the new config, and do a call of all
    features (feature numbers), then call the names for each number

    Similar to the below, just for feature names/count, and instead of
    setting a property, supress under the new config:
    ***********************
    OptionCompare Text 'sets string compare to be case insensitive
    CustomCount = CurrentDoc.GetCustomInfoCount2("")
    CustomNames = CurrentDoc.GetCustomInfoNames2("")

    For j = 0 To CustomCount - 1
    CustomName = CustomNames(j)
    If StrComp(CustomNames(j), "DateCompleted") = 0 Then
    CurrentDoc.CustomInfo2("", CustomNames(j)) = Properties(0)
    ***************************

    Hope that gets you in the right direction. Check the API help file
    for the suppress/add config calls.

    -James
     
    James Spisich, Jan 25, 2008
    #3
  4. Oh, and after doing the call, I'd say compare it against Cut* & Hole*
    to find all cuts and holes to suppress.
     
    James Spisich, Jan 25, 2008
    #4
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.