mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-14 03:14:23 +00:00
Bonsai - setup default values for new patametric profiles
So there will be less invalid IFC and user will get a preview right away after creating a new profile. Example - https://imgur.com/a/GjkCql4
This commit is contained in:
@@ -149,6 +149,7 @@ class AddProfileDef(bpy.types.Operator, tool.Ifc.Operator):
|
||||
profile = ifcopenshell.api.run("profile.add_arbitrary_profile", tool.Ifc.get(), profile=points)
|
||||
else:
|
||||
profile = ifcopenshell.api.run("profile.add_parameterized_profile", tool.Ifc.get(), ifc_class=profile_class)
|
||||
tool.Profile.set_default_profile_attrs(profile)
|
||||
profile.ProfileName = "New Profile"
|
||||
bpy.ops.bim.load_profiles()
|
||||
|
||||
|
||||
@@ -116,3 +116,104 @@ class Profile(bonsai.core.tool.Profile):
|
||||
index = props.active_profile_index
|
||||
if len(props.profiles) > index >= 0:
|
||||
return props.profiles[index]
|
||||
|
||||
# Lengths are in meters.
|
||||
DEFAULT_PROFILE_ATTRS = {
|
||||
"IfcCircleProfileDef": {
|
||||
"Radius": 0.05,
|
||||
},
|
||||
# TODO: test after debug
|
||||
"IfcAsymmetricIShapeProfileDef": {
|
||||
"BottomFlangeWidth": 0.1,
|
||||
"BottomFlangeThickness": 0.01,
|
||||
"BottomFlangeFilletRadius": 0.01,
|
||||
"OverallDepth": 0.1,
|
||||
"WebThickness": 0.005,
|
||||
"TopFlangeWidth": 0.075,
|
||||
"TopFlangeThickness": 0.01,
|
||||
"TopFlangeFilletRadius": 0.01,
|
||||
},
|
||||
"IfcCShapeProfileDef": {
|
||||
"Depth": 0.1,
|
||||
"Width": 0.05,
|
||||
"WallThickness": 0.01,
|
||||
"Girth": 0.01,
|
||||
},
|
||||
# 101.6-10.0
|
||||
"IfcCircleHollowProfileDef": {
|
||||
"WallThickness": 0.01,
|
||||
},
|
||||
# TODO: check shape after fixing crash
|
||||
# "IfcEllipseProfileDef": {
|
||||
# "SemiAxis1": 0.1,
|
||||
# "SemiAxis2": 0.1,
|
||||
# },
|
||||
# HEA100
|
||||
"IfcIShapeProfileDef": {
|
||||
"OverallWidth": 0.1,
|
||||
"OverallDepth": 0.1,
|
||||
"WebThickness": 0.005,
|
||||
"FlangeThickness": 0.01,
|
||||
"FilletRadius": 0.01,
|
||||
},
|
||||
# LNP100x10
|
||||
"IfcLShapeProfileDef": {
|
||||
"Depth": 0.1,
|
||||
"Thickness": 0.01,
|
||||
"FilletRadius": 0.012,
|
||||
"EdgeRadius": 0.01,
|
||||
},
|
||||
"IfcRectangleProfileDef": {
|
||||
"XDim": 0.1,
|
||||
"YDim": 0.1,
|
||||
},
|
||||
"IfcRoundedRectangleProfileDef": {
|
||||
"RoundingRadius": 0.01,
|
||||
},
|
||||
# 100-10.0
|
||||
"IfcRectangleHollowProfileDef": {
|
||||
"WallThickness": 0.01,
|
||||
"InnerFilletRadius": 0.01,
|
||||
"OuterFilletRadius": 0.01,
|
||||
},
|
||||
"IfcTShapeProfileDef": {
|
||||
"Depth": 0.1,
|
||||
"FlangeWidth": 0.05,
|
||||
"WebThickness": 0.005,
|
||||
"FlangeThickness": 0.009,
|
||||
},
|
||||
"IfcTrapeziumProfileDef": {
|
||||
"BottomXDim": 0.1,
|
||||
"TopXDim": 0.08,
|
||||
"YDim": 0.05,
|
||||
"TopXOffset": 0.01,
|
||||
},
|
||||
# UAP100
|
||||
"IfcUShapeProfileDef": {
|
||||
"Depth": 0.1,
|
||||
"FlangeWidth": 0.05,
|
||||
"WebThickness": 0.005,
|
||||
"FlangeThickness": 0.009,
|
||||
},
|
||||
# ZNP100
|
||||
"IfcZShapeProfileDef": {
|
||||
"Depth": 0.1,
|
||||
"FlangeWidth": 0.05,
|
||||
"WebThickness": 0.007,
|
||||
"FlangeThickness": 0.01,
|
||||
},
|
||||
}
|
||||
|
||||
@classmethod
|
||||
def set_default_profile_attrs(cls, profile: ifcopenshell.entity_instance) -> None:
|
||||
"""Set default profile attributes to keep profile valid."""
|
||||
class_match = False
|
||||
si_conversion = ifcopenshell.util.unit.calculate_unit_scale(tool.Ifc.get())
|
||||
for ifc_class, params in cls.DEFAULT_PROFILE_ATTRS.items():
|
||||
if profile.is_a(ifc_class):
|
||||
class_match = True
|
||||
for key, value in params.items():
|
||||
setattr(profile, key, value / si_conversion)
|
||||
|
||||
if not class_match:
|
||||
raise ValueError(f"Unable to set default profile parameters for {profile.is_a()}.")
|
||||
|
||||
Reference in New Issue
Block a user