I'd try setting the quantity to the total weight divided by 40. Something like:
<?php echo (($eCart1->TotalColumn("TotalWeight")<40)?$eCart1->TotalColumn("TotalWeight"):$eCart1->TotalColumn("TotalWeight")/40); ?>
Then set the weight value to:
<?php echo (($eCart1->TotalColumn("TotalWeight")<40)?$eCart1->TotalColumn("TotalWeight"):40); ?>
That may work... The only thing I'm not sure of is it might complain about having a decimal in the quantity field and you might need to use:
<?php echo (($eCart1->TotalColumn("TotalWeight")<40)?$eCart1->TotalColumn("TotalWeight"):ceil($eCart1->TotalColumn("TotalWeight")/40)); ?>
In both there will be slight issues. The first technique... if it worked... would assume that a 1lb package was 1/40 the price of a 40lb package. The second technique would charge for a 40lb package even if it only needed a 1lb package... like if someone orderd 41lbs of goods it would treat it as two 40 lb packages.
There is no way to get around this limitation without editing the code by hand.