Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 35 additions & 2 deletions commands/TNA_envelope.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
import compas_rhino.objects
from compas.datastructures import Mesh
from compas_masonry.session import MasonrySession as Session
from compas_rui import feedback
from compas_tna.diagrams import FormDiagram

# from compas_rui import feedback
from compas_tna.envelope import CrossVaultEnvelope
from compas_tna.envelope import DomeEnvelope
from compas_tna.envelope import Envelope
Expand Down Expand Up @@ -299,17 +298,48 @@ def RunCommand():
obj = compas_rhino.objects.find_object(guid)
mesh_middle = compas_rhino.conversions.mesh_to_compas(obj.Geometry, cls=Mesh)

guid = compas_rhino.objects.select_mesh("Select fill mesh (Optional)")
rs.UnselectAllObjects()
if not guid:
mesh_fill = None
else:
guids_bounds.append(guid)
obj = compas_rhino.objects.find_object(guid)
mesh_fill = compas_rhino.conversions.mesh_to_compas(obj.Geometry, cls=Mesh)

rs.HideObjects(guids_bounds)

envelope = MeshEnvelope.from_meshes(mesh_intrados, mesh_extrados, mesh_middle)

if mesh_fill:
envelope.fill = mesh_fill

# =============================================================================
# Not supported
# =============================================================================

else:
raise NotImplementedError

# =============================================================================
# Commom parameters
# =============================================================================

if not envelope:
feedback.warn("Error creating Envelope. Try again.")
return

rho = rs.GetInteger("Density masonry (rho)", envelope.rho, 0, 200)
if not rho:
return
envelope.rho = rho

if envelope.fill:
rho_fill = rs.GetInteger("Density masonry fill (rho_fill)", envelope.rho_fill, 0, 200)
if not rho_fill:
return
envelope.rho_fill = rho_fill

# =============================================================================
# Update scene
# =============================================================================
Expand All @@ -324,10 +354,13 @@ def RunCommand():
show_intrados = session.settings.envelope.show_intrados
show_middle = session.settings.envelope.show_middle
show_extrados = session.settings.envelope.show_extrados
show_fill = session.settings.envelope.show_extrados

session.scene.add(envelope.intrados, disjoint=True, show=show_intrados, name="Intrados", layer="Masonry::TNA::Envelope") # type: ignore
session.scene.add(envelope.middle, disjoint=True, show=show_middle, name="Middle", layer="Masonry::TNA::Envelope") # type: ignore
session.scene.add(envelope.extrados, disjoint=True, show=show_extrados, name="Extrados", layer="Masonry::TNA::Envelope") # type: ignore
if envelope.fill:
session.scene.add(envelope.fill, disjoint=True, show=show_fill, name="Fill", layer="Masonry::TNA::Envelope") # type: ignore

session.scene.redraw()
rs.Redraw()
Expand Down
8 changes: 7 additions & 1 deletion commands/TNA_loads.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def RunCommand():
return

if option == "Add":
option = rs.GetString("Type of load", strings=["Selfweight", "External"])
option = rs.GetString("Type of load", strings=["Selfweight", "External", "FillLoads"])
if not option:
return

Expand Down Expand Up @@ -73,6 +73,12 @@ def RunCommand():
print("Load at vertex {0} updated from {1:.2f} to {2:.2f}".format(key, pz, pz + load))
formdiagram.vertex_attribute(key, "pz", pz + load)

elif option == "FillLoads":
if not envelope.fill:
feedback.warn("There is no Fill Mesh. Please re-create envelope with a fill")
return
envelope.apply_fill_weight_to_formdiagram(formdiagram)

elif option == "ClearAll":
print("Cleared Loads in the Model.")
formobject.mesh.vertices_attribute(name="pz", value=0)
Expand Down
12 changes: 12 additions & 0 deletions src/compas_masonry/scene/envelopeobject.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,15 @@ def __init__(
show_intrados=True,
show_middle=False,
show_extrados=True,
show_fill=True,
**kwargs,
):
super().__init__(**kwargs)
self.color = color or self.color
self.show_intrados = show_intrados
self.show_middle = show_middle
self.show_extrados = show_extrados
self.show_fill = show_fill

@property
def settings(self) -> dict:
Expand All @@ -38,6 +40,7 @@ def settings(self) -> dict:
settings["show_intrados"] = self.show_intrados
settings["show_middle"] = self.show_middle
settings["show_extrados"] = self.show_extrados
settings["show_fill"] = self.show_fill
return settings

@property
Expand All @@ -61,6 +64,9 @@ def draw(self):
if self.show_extrados:
self.draw_extrados()

if self.show_fill:
self.draw_fill()

return self._guids

def _draw_mesh(self, mesh: Mesh, name: str) -> None:
Expand Down Expand Up @@ -92,3 +98,9 @@ def draw_extrados(self):
return
guid = self._draw_mesh(self.envelope.extrados, name="Extrados") # type: ignore
self._guids.append(guid)

def draw_fill(self):
if not self.envelope.fill:
return
guid = self._draw_mesh(self.envelope.fill, name="Fill") # type: ignore
self._guids.append(guid)
1 change: 1 addition & 0 deletions src/compas_masonry/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ class EnvelopeSettings(BaseModel):
show_intrados: bool = Field(default=True, title="Show Intrados")
show_middle: bool = Field(default=False, title="Show Middle")
show_extrados: bool = Field(default=True, title="Show Extrados")
show_fill: bool = Field(default=True, title="Show Fill")


class BlockModelSettings(BaseModel):
Expand Down
Loading