@@ -2011,19 +2011,19 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
2011
2011
2012
2012
objsSelected = []
2013
2013
for k in range (len (objs )):
2014
- obj = objs [k ]
2015
- if obj != None and obj . rigid_body != None :
2016
- CT = elemGrps [ objsEGrp [ k ]][ EGSidxCTyp ]
2017
- if CT == 0 :
2018
- # The foundation buffer objects need a large mass so they won't pushed away
2019
- materialDensity = elemGrp [ EGSidxDens ]
2020
- if materialDensity > 1 : obj . rigid_body . mass = materialDensity
2021
- else : obj .rigid_body .mass = 1000 # Backward compatibility for older settings
2022
- else :
2023
- try : scale = elemGrps [ objsEGrp [ k ]][ EGSidxScal ] # Try in case elemGrps is from an old BCB version
2024
- except : qScale = 0
2025
- else : qScale = 1
2026
- if j == objsEGrp [ k ]:
2014
+ if objsEGrp [k ] == j : # If object is in current element group
2015
+ obj = objs [ k ]
2016
+ if obj != None and obj . rigid_body != None :
2017
+ CT = elemGrps [ j ][ EGSidxCTyp ]
2018
+ if CT == 0 :
2019
+ # The foundation buffer objects need a large mass so they won't pushed away
2020
+ materialDensity = elemGrp [ EGSidxDens ]
2021
+ if materialDensity > 1 : obj .rigid_body .mass = materialDensity
2022
+ else : obj . rigid_body . mass = 1000 # Backward compatibility for older settings
2023
+ else :
2024
+ try : scale = elemGrps [ j ][ EGSidxScal ] # Try in case elemGrps is from an old BCB version
2025
+ except : qScale = 0
2026
+ else : qScale = 1
2027
2027
if obj != None :
2028
2028
if "bcb_child" in obj .keys ():
2029
2029
obj = scene .objects [obj ["bcb_child" ]]
@@ -2049,9 +2049,6 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
2049
2049
2050
2050
### Calculating and applying material masses based on surface area * thickness
2051
2051
if (props .surfaceForced and props .surfaceThickness ) or (props .surfaceThickness and len (objsNonMan )):
2052
- # Deselect all objects
2053
- bpy .ops .object .select_all (action = 'DESELECT' )
2054
-
2055
2052
# Find out density of the element group
2056
2053
if not materialDensity :
2057
2054
materialPreset = elemGrp [EGSidxMatP ]
@@ -2070,7 +2067,7 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
2070
2067
for n in range (len (objsNonMan )):
2071
2068
obj = objsNonMan [n ]
2072
2069
k = objsIndex [obj .name ]
2073
- if j == objsEGrp [k ]:
2070
+ if objsEGrp [k ] == j : # If object is in current element group
2074
2071
# Calculate object surface area and volume
2075
2072
me = obj .data
2076
2073
area = sum (f .area for f in me .polygons )
@@ -2118,7 +2115,7 @@ def calculateMass(scene, objs, objsEGrp, childObjs):
2118
2115
except :
2119
2116
try : groupsArea [group .name ] = obj ["Floor Area" ]
2120
2117
except : pass
2121
- for groupName in groupsMass .keys ():
2118
+ for groupName in sorted ( groupsMass .keys () ):
2122
2119
try : mass = groupsMass [groupName ]
2123
2120
except : mass = 0
2124
2121
try : area = groupsArea [groupName ]
0 commit comments