Documentation example fixes where I forgot to give things with representations a placement

This commit is contained in:
Dion Moult
2023-01-04 16:09:04 +11:00
parent af1949678a
commit e22904b41b
6 changed files with 16 additions and 15 deletions
@@ -111,7 +111,7 @@ class Usecase:
# If we plan to store 3D geometry in our IFC model, we have to setup # If we plan to store 3D geometry in our IFC model, we have to setup
# a "Model" context. # a "Model" context.
model = ifcopenshell.api.run("context.add_context", model, context_type="Model") model3d = ifcopenshell.api.run("context.add_context", model, context_type="Model")
# And/Or, if we plan to store 2D geometry, we need a "Plan" context # And/Or, if we plan to store 2D geometry, we need a "Plan" context
plan = ifcopenshell.api.run("context.add_context", model, context_type="Plan") plan = ifcopenshell.api.run("context.add_context", model, context_type="Plan")
@@ -121,44 +121,37 @@ class Usecase:
# and common context, as most IFC models are assumed to be viewable # and common context, as most IFC models are assumed to be viewable
# in 3D. # in 3D.
body = ifcopenshell.api.run("context.add_context", model, body = ifcopenshell.api.run("context.add_context", model,
context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model context_type="Model", context_identifier="Body", target_view="MODEL_VIEW", parent=model3d)
)
# The 3D Axis subcontext is important if any "axis-based" parametric # The 3D Axis subcontext is important if any "axis-based" parametric
# geometry is going to be created. For example, a beam, or column # geometry is going to be created. For example, a beam, or column
# may be drawn using a single 3D axis line, and for this we need an # may be drawn using a single 3D axis line, and for this we need an
# Axis subcontext. # Axis subcontext.
ifcopenshell.api.run("context.add_context", model, ifcopenshell.api.run("context.add_context", model,
context_type="Model", context_identifier="Axis", target_view="GRAPH_VIEW", parent=model context_type="Model", context_identifier="Axis", target_view="GRAPH_VIEW", parent=model3d)
)
# The 3D Box subcontext is useful for clash detection or shape # The 3D Box subcontext is useful for clash detection or shape
# analysis, or even lazy-loading of large models. # analysis, or even lazy-loading of large models.
ifcopenshell.api.run("context.add_context", model, ifcopenshell.api.run("context.add_context", model,
context_type="Model", context_identifier="Box", target_view="MODEL_VIEW", parent=model context_type="Model", context_identifier="Box", target_view="MODEL_VIEW", parent=model3d)
)
# It's also important to have a 2D Axis subcontext for things like # It's also important to have a 2D Axis subcontext for things like
# walls and claddings which can be drawn using a 2D axis line. # walls and claddings which can be drawn using a 2D axis line.
ifcopenshell.api.run("context.add_context", model, ifcopenshell.api.run("context.add_context", model,
context_type="Plan", context_identifier="Axis", target_view="GRAPH_VIEW", parent=plan context_type="Plan", context_identifier="Axis", target_view="GRAPH_VIEW", parent=plan)
)
# A 2D annotation subcontext for plan views are important for door # A 2D annotation subcontext for plan views are important for door
# swings, window cuts, and symbols for equipment like GPOs, fire # swings, window cuts, and symbols for equipment like GPOs, fire
# extinguishers, and so on. # extinguishers, and so on.
ifcopenshell.api.run("context.add_context", model, ifcopenshell.api.run("context.add_context", model,
context_type="Plan", context_identifier="Annotation", target_view="PLAN_VIEW", parent=plan context_type="Plan", context_identifier="Annotation", target_view="PLAN_VIEW", parent=plan)
)
# You may also create 2D annotation subcontexts for sections and # You may also create 2D annotation subcontexts for sections and
# elevation views. # elevation views.
ifcopenshell.api.run("context.add_context", model, ifcopenshell.api.run("context.add_context", model,
context_type="Plan", context_identifier="Annotation", target_view="SECTION_VIEW", parent=plan context_type="Plan", context_identifier="Annotation", target_view="SECTION_VIEW", parent=plan)
)
ifcopenshell.api.run("context.add_context", model, ifcopenshell.api.run("context.add_context", model,
context_type="Plan", context_identifier="Annotation", target_view="ELEVATION_VIEW", parent=plan context_type="Plan", context_identifier="Annotation", target_view="ELEVATION_VIEW", parent=plan)
)
# Let's create a new wall. The wall does not have any geometry yet. # Let's create a new wall. The wall does not have any geometry yet.
wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall") wall = ifcopenshell.api.run("root.create_entity", model, ifc_class="IfcWall")
@@ -172,6 +165,9 @@ class Usecase:
# Assign our new body geometry back to our wall # Assign our new body geometry back to our wall
ifcopenshell.api.run("geometry.assign_representation", model, ifcopenshell.api.run("geometry.assign_representation", model,
product=wall, representation=representation) product=wall, representation=representation)
# Place our wall at the origin
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
""" """
self.file = file self.file = file
self.settings = { self.settings = {
@@ -53,6 +53,7 @@ class Usecase:
context=body, length=5, height=3, thickness=0.2) context=body, length=5, height=3, thickness=0.2)
ifcopenshell.api.run("geometry.assign_representation", model, ifcopenshell.api.run("geometry.assign_representation", model,
product=wall, representation=representation) product=wall, representation=representation)
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
# Now let's create a layer that contains walls # Now let's create a layer that contains walls
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL") layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
@@ -45,6 +45,7 @@ class Usecase:
context=body, length=5, height=3, thickness=0.2) context=body, length=5, height=3, thickness=0.2)
ifcopenshell.api.run("geometry.assign_representation", model, ifcopenshell.api.run("geometry.assign_representation", model,
product=wall, representation=representation) product=wall, representation=representation)
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
# Now let's create a layer that contains walls # Now let's create a layer that contains walls
layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL") layer = ifcopenshell.api.run("layer.add_layer", model, Name="AI-WALL")
@@ -125,6 +125,7 @@ class Usecase:
context=body_context, length=5000, height=3000, thickness=200) context=body_context, length=5000, height=3000, thickness=200)
ifcopenshell.api.run("geometry.assign_representation", model, product=wall, representation=axis) ifcopenshell.api.run("geometry.assign_representation", model, product=wall, representation=axis)
ifcopenshell.api.run("geometry.assign_representation", model, product=wall, representation=body) ifcopenshell.api.run("geometry.assign_representation", model, product=wall, representation=body)
ifcopenshell.api.run("geometry.edit_object_placement", model, product=wall)
""" """
self.file = file self.file = file
self.settings = {"product": product, "type": type, "material": material} self.settings = {"product": product, "type": type, "material": material}
@@ -75,6 +75,7 @@ class Usecase:
body = ifcopenshell.api.run("geoemtry.add_profile_representation", body = ifcopenshell.api.run("geoemtry.add_profile_representation",
context=body_context, profile=hea100, depth=1000) context=body_context, profile=hea100, depth=1000)
ifcopenshell.api.run("geometry.assign_representation", model, product=beam, representation=body) ifcopenshell.api.run("geometry.assign_representation", model, product=beam, representation=body)
ifcopenshell.api.run("geometry.edit_object_placement", model, product=beam)
# Now let's change the profile to a HEA200 standard profile instead. # Now let's change the profile to a HEA200 standard profile instead.
# This will automatically change the body representation that we # This will automatically change the body representation that we
@@ -79,6 +79,7 @@ class Usecase:
body = ifcopenshell.api.run("geoemtry.add_profile_representation", body = ifcopenshell.api.run("geoemtry.add_profile_representation",
context=body_context, profile=hea100, depth=1000) context=body_context, profile=hea100, depth=1000)
ifcopenshell.api.run("geometry.assign_representation", model, product=beam, representation=body) ifcopenshell.api.run("geometry.assign_representation", model, product=beam, representation=body)
ifcopenshell.api.run("geometry.edit_object_placement", model, product=beam)
# Let's change the cardinal point to be the top center of the axis # 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 # line. This is represented by the number "8". Consult the IFC