mirror of
https://github.com/IfcOpenShell/IfcOpenShell.git
synced 2026-08-10 09:48:32 +00:00
Add API documentation for the material module
This commit is contained in:
@@ -21,11 +21,74 @@ import ifcopenshell.util.representation
|
||||
|
||||
|
||||
class Usecase:
|
||||
def __init__(self, file, **settings):
|
||||
def __init__(self, file, usage=None, attributes=None):
|
||||
"""Edits the attributes of an IfcMaterialProfileSetUsage
|
||||
|
||||
This is typically used to change the cardinal point of the profile.
|
||||
The cardinal point represents whether the profile is extruded along the
|
||||
center of the axis line, at a corner, at a shear center, at the bottom,
|
||||
top, etc.
|
||||
|
||||
For more information about the attributes and data types of an
|
||||
IfcMaterialProfileSetUsage, consult the IFC documentation.
|
||||
|
||||
:param usage: The IfcMaterialProfileSetUsage entity you want to edit
|
||||
:type usage: ifcopenshell.entity_instance.entity_instance
|
||||
:param attributes: a dictionary of attribute names and values.
|
||||
:type attributes: dict, optional
|
||||
:return: None
|
||||
:rtype: None
|
||||
|
||||
Example::
|
||||
|
||||
# Let's imagine we have a steel I-beam. Notice we are assigning to
|
||||
# the type only, as all occurrences of that type will automatically
|
||||
# inherit the material.
|
||||
beam_type = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeamType", name="B1")
|
||||
|
||||
# First, let's create a material set. This will later be assigned
|
||||
# to our beam type element.
|
||||
material_set = ifcopenshell.api.run("material.add_profile_set", model,
|
||||
name="B1", set_type="IfcMaterialProfileSet")
|
||||
|
||||
# Create a steel material.
|
||||
steel = ifcopenshell.api.run("material.add_material", model, name="ST01", category="steel")
|
||||
|
||||
# Create an I-beam profile curve. Notice how we name our profiles
|
||||
# based on standardised steel profile names.
|
||||
hea100 = self.file.create_entity(
|
||||
"IfcIShapeProfileDef", ProfileName="HEA100", ProfileType="AREA",
|
||||
OverallWidth=100, OverallDepth=96, WebThickness=5, FlangeThickness=8, FilletRadius=12,
|
||||
)
|
||||
|
||||
# Define that steel material and cross section as a single profile
|
||||
# item. If this were a composite beam, we might add multiple profile
|
||||
# items instead, but this is rarely the case in most construction.
|
||||
profile_item = ifcopenshell.api.run("material.add_profile", model,
|
||||
profile_set=material_set, material=steel, profile=hea100)
|
||||
|
||||
# Great! Let's assign our material set to our beam type.
|
||||
ifcopenshell.api.run("material.assign_material", model, product=beam_type, material=material_set)
|
||||
|
||||
# Let's create an occurrence of this beam.
|
||||
beam = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcBeam", name="B1.01")
|
||||
rel = ifcopenshell.api.run("material.assign_material", model,
|
||||
product=beam, type="IfcMaterialProfileSetUsage")
|
||||
|
||||
# Let's give a 1000mm long beam body representation.
|
||||
body = ifcopenshell.api.run("geoemtry.add_profile_representation",
|
||||
context=body_context, profile=hea100, depth=1000)
|
||||
ifcopenshell.api.run("geometry.assign_representation", model, product=beam, representation=body)
|
||||
|
||||
# Let's change the cardinal point to be the top center of the axis
|
||||
# line. This is represented by the number "8". Consult the IFC
|
||||
# documentation for all the numbers you can use.
|
||||
ifcopenshell.api.run("material.edit_profile_usage", model,
|
||||
usage=rel.RelatingMaterial, attributes={"CardinalPoint": 8})
|
||||
"""
|
||||
|
||||
self.file = file
|
||||
self.settings = {"usage": None, "attributes": {}}
|
||||
for key, value in settings.items():
|
||||
self.settings[key] = value
|
||||
self.settings = {"usage": usage, "attributes": attributes or {}}
|
||||
|
||||
def execute(self):
|
||||
self.cardinal_point = self.settings["attributes"].get("CardinalPoint")
|
||||
|
||||
Reference in New Issue
Block a user