Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Jack cut feature #267

Closed
wants to merge 16 commits into from
Closed
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

### Added

* Added new temporary package `_fabrication`.
* Added new `compas_timber._fabrication.JackRafterCut`.
* Added `side_as_surface` to `compas_timber.elements.Beam`.

### Changed

### Removed
Expand Down
9 changes: 9 additions & 0 deletions src/compas_timber/_fabrication/__init__.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# This module is a tepmorary solution to the problem of circular imports in the compas_timber package.
# It will be reoved or merged with the `fabrication` module once the migration to the new feature system is complete.
from .btlx_process import BTLxProcess
from .btlx_process import OrientationType
from .jack_cut import JackRafterCut
from .jack_cut import JackRafterCutParams


__all__ = ["JackRafterCut", "BTLxProcess", "OrientationType", "JackRafterCutParams"]
87 changes: 87 additions & 0 deletions src/compas_timber/_fabrication/btlx_process.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
from collections import OrderedDict

from compas.data import Data


class BTLxProcess(Data):
"""Base class for BTLx processes.

Attributes
----------
ref_side_index : int
The reference side, zero-based, index of the beam to be cut. 0-5 correspond to RS1-RS6.
priority : int
The priority of the process.
process_id : int
The process ID.
PROCESS_NAME : str
The name of the process.

"""

@property
def __data__(self):
return {"ref_side_index": self.ref_side_index, "priority": self.priority, "process_id": self.process_id}

def __init__(self, ref_side_index, priority=0, process_id=0):
super(BTLxProcess, self).__init__()
self.ref_side_index = ref_side_index
self._priority = priority
self._process_id = process_id

@property
def priority(self):
return self._priority

@property
def process_id(self):
return self._process_id

@property
def PROCESS_NAME(self):
raise NotImplementedError("PROCESS_NAME must be implemented as class attribute in subclasses!")


class BTLxProcessParams(object):
"""Base class for BTLx process parameters. This creates the dictionary of key-value pairs for the process as expected by the BTLx file format.

Parameters
----------
instance : :class:`BTLxProcess`
The instance of the process to create parameters for.

"""

def __init__(self, instance):
self._instance = instance

def as_dict(self):
"""Returns the process parameters as a dictionary.

Returns
-------
dict
The process parameters as a dictionary.
"""
result = OrderedDict()
result["Name"] = self._instance.PROCESS_NAME
result["Process"] = "yes"
result["Priority"] = str(self._instance.priority)
result["ProcessID"] = str(self._instance.process_id)
result["ReferencePlaneID"] = str(self._instance.ref_side_index + 1)
return result


class OrientationType(object):
"""Enum for the orientation of the cut.

Attributes
----------
START : literal("start")
The start of the beam is cut away.
END : literal("end")
The end of the beam is cut away.
"""

START = "start"
END = "end"
Loading
Loading