-
Notifications
You must be signed in to change notification settings - Fork 26
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
Joints by topology #157
Closed
Closed
Joints by topology #157
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
53 changes: 53 additions & 0 deletions
53
src/compas_timber/ghpython/components/CT_ApplyJointsByTopology/code.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
from ghpythonlib.componentbase import executingcomponent as component | ||
from Grasshopper.Kernel.GH_RuntimeMessageLevel import Warning | ||
|
||
from compas_timber.connections import ConnectionSolver | ||
from compas_timber.connections import JointTopology | ||
from compas_timber.ghpython import JointDefinition | ||
|
||
from compas_timber.connections import LButtJoint | ||
from compas_timber.connections import LMiterJoint | ||
from compas_timber.connections import TButtJoint | ||
from compas_timber.connections import XHalfLapJoint | ||
from compas_timber.connections import FrenchRidgeLapJoint | ||
|
||
|
||
class MyComponent(component): | ||
def RunScript(self, Beams, L, T, X, MaxDistance): | ||
MAP = { | ||
"T-Butt": TButtJoint, | ||
"L-Miter": LMiterJoint, | ||
"L-Butt": LButtJoint, | ||
"French Ridge Lap": FrenchRidgeLapJoint, | ||
"X-HalfLap": XHalfLapJoint, | ||
} | ||
|
||
max_dist = MaxDistance or 1 | ||
solver = ConnectionSolver() | ||
found_pairs = solver.find_intersecting_pairs(Beams, rtree=True, max_distance=max_dist) | ||
Joints = [] | ||
Info = [] | ||
|
||
for pair in found_pairs: | ||
beam_a, beam_b = pair | ||
detected_topo, beam_a, beam_b = solver.find_topology(beam_a, beam_b, max_distance=max_dist) | ||
flip_beams = False | ||
if detected_topo == JointTopology.TOPO_UNKNOWN: | ||
continue | ||
elif detected_topo == JointTopology.TOPO_L: | ||
joint_type = MAP.get(str(L)) or LMiterJoint | ||
if joint_type == LButtJoint: | ||
if beam_a.width * beam_a.height > beam_b.width * beam_b.height: | ||
flip_beams = True | ||
elif detected_topo == JointTopology.TOPO_T: | ||
joint_type = MAP.get(str(T)) or TButtJoint | ||
elif detected_topo == JointTopology.TOPO_X: | ||
joint_type = MAP.get(str(X)) or XHalfLapJoint | ||
|
||
if flip_beams: | ||
Joints.append(JointDefinition(joint_type, [beam_b, beam_a])) | ||
else: | ||
Joints.append(JointDefinition(joint_type, [beam_a, beam_b])) | ||
msg = "Beams: {}, {} meet with topology: {} and use joint: {}" | ||
Info.append(msg.format(beam_a, beam_b, JointTopology.get_name(detected_topo), joint_type.__name__)) | ||
return Joints, Info |
Binary file added
BIN
+1.17 KB
src/compas_timber/ghpython/components/CT_ApplyJointsByTopology/icon.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
54 changes: 54 additions & 0 deletions
54
src/compas_timber/ghpython/components/CT_ApplyJointsByTopology/metadata.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
{ | ||
"name": "Apply Joints by Topology", | ||
"nickname": "JointsByTopo", | ||
"category": "COMPAS Timber", | ||
"subcategory": "Joints", | ||
"description": "Analyzes beams and applies given joint types for each topology type.", | ||
"exposure": 2, | ||
"ghpython": { | ||
"isAdvancedMode": true, | ||
"iconDisplay": 0, | ||
"inputParameters": [ | ||
{ | ||
"name": "Beams", | ||
"description": "Collection of Beams.", | ||
"typeHintID": "none", | ||
"scriptParamAccess": 1 | ||
}, | ||
{ | ||
"name": "L", | ||
"description": "Joint type to be applied to L topology. Default type is L-Miter. If L-Butt, the beam with a larger cross section area will be used as crossing beam.", | ||
"typeHintID": "none", | ||
"scriptParamAccess": 0 | ||
}, | ||
{ | ||
"name": "T", | ||
"description": "Joint type to be applied to T topology. Default type is T-Butt.", | ||
"typeHintID": "float", | ||
"scriptParamAccess": 0 | ||
}, | ||
{ | ||
"name": "X", | ||
"description": "Joint type to be applied to X topology. Default type is X-HalfLap.", | ||
"typeHintID": "float", | ||
"scriptParamAccess": 0 | ||
}, | ||
{ | ||
"name": "MaxDistance", | ||
"description": "(optional) Maximum distance between centerlines of two Beams (limited to segments) to consider the Beams as connecting. Optional (if omitted, a default value equal to the average beam height will be taken).", | ||
"typeHintID": "float", | ||
"scriptParamAccess": 0 | ||
} | ||
], | ||
"outputParameters": [ | ||
{ | ||
"name": "Joints", | ||
"description": "List of JointDefinitions." | ||
}, | ||
{ | ||
"name": "Info", | ||
"description": "Report and analysis of the found connections and any issues." | ||
} | ||
] | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,7 +29,7 @@ | |
"ghuser": { | ||
"source_dir": "src/compas_timber/ghpython/components", | ||
"target_dir": "src/compas_timber/ghpython/components/ghuser", | ||
"prefix": "(COMPAS_TIMBER)", | ||
"prefix": "CT_", | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I started using |
||
}, | ||
} | ||
) |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does that work? that's a scary import :P