Skip to content

Commit

Permalink
0.0.3, Debugging, autopanel
Browse files Browse the repository at this point in the history
  • Loading branch information
symonkipkemei committed Aug 27, 2023
1 parent 57e1010 commit 2a1fa90
Show file tree
Hide file tree
Showing 7 changed files with 126 additions and 231 deletions.
15 changes: 13 additions & 2 deletions lib/_create/_auto.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,11 @@ def auto_panel(__title__, host_wall_id, lap_type_id, reveal_indexes, side_of_wal
try:
with Transaction(doc, __title__) as t:
t.Start()
options = t.GetFailureHandlingOptions()
failureProcessor = eh.JointConditionSwallower()
options.SetFailuresPreprocessor(failureProcessor)
t.SetFailureHandlingOptions(options)

for reveal_index in reveal_indexes:
wall_sweep = auto_reveal(host_wall_id, lap_type_id, reveal_index, side_of_wall)
t.Commit()
Expand All @@ -124,7 +129,7 @@ def auto_panel(__title__, host_wall_id, lap_type_id, reveal_indexes, side_of_wal
print ('The following error has occurred: {}'.format(e))


def auto_parts(__title__, part):
def auto_parts(__title__, part, multiple = True):
"""
Identifies :
1. the Parts ( exterior, interior or partition ) intuitively
Expand Down Expand Up @@ -159,5 +164,11 @@ def auto_parts(__title__, part):

out_ranges = o.get_out_ranges(part, hosted_doors, hosted_windows, reveal_plane_coordinate_0, displacement)

reveal_indexes = g.get_reveal_indexes_v2(left_edge, right_edge, out_ranges, exterior)
if multiple:
reveal_indexes = g.get_reveal_indexes_v2(left_edge, right_edge, out_ranges, exterior)
else:
reveal_indexes = g.get_single_panel_reveal_indexes(left_edge, right_edge, exterior)

auto_panel(__title__, host_wall_id, lap_type_id, reveal_indexes, side_of_wall)


17 changes: 17 additions & 0 deletions lib/_create/_errorhandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,23 @@ def PreprocessFailures(self, failuresAccessor):
return FailureProcessingResult.Continue


# delete dialog box for : Wall part could not be properly adjusted for join condition.
class JointConditionSwallower(IFailuresPreprocessor):
def PreprocessFailures(self, failuresAccessor):
# Inside event handler, get all warnings
failList = failuresAccessor.GetFailureMessages()

for failure in failList:
# check FailureDefinitionIds against ones that you want to dismiss
failID = failure.GetFailureDefinitionId()
# prevent Revit from showing Unenclosed room warnings
if failID == BuiltInFailures.PartMakerMethodForWallFailures.CouldNotCreateWallPartDueToWallJoin:
failuresAccessor.DeleteWarning(failure)


return FailureProcessingResult.Continue


#catch variable distance cannot be found
class VariableDistanceNotFoundError(Exception):
pass
11 changes: 8 additions & 3 deletions lib/_create/_parts.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ def select_part():
part = uidoc.Document.GetElement(reference)

if str(type(part)) == "<type 'Part'>":
print (str(type(part)))
return part
else:
raise eh.CannotPanelizeError
Expand Down Expand Up @@ -102,10 +101,15 @@ def get_host_wall_type_id(host_wall_id):
def get_wallsweep_parameters(layer_index, host_wall_type_id):
"""Abstract parameters based on the layer index of the part"""

global lap_type_id, side_of_wall, exterior
left_lap_id = ElementId(352818)
right_lap_id = ElementId(352808)

# default setting for exterior
side_of_wall = WallSide.Exterior
lap_type_id = right_lap_id
exterior = True


I_E_wall_types = [ElementId(384173), ElementId(391917), ElementId(391949), ElementId(391949), ElementId(391971)]
I_wall_types = [ElementId(400084)]

Expand Down Expand Up @@ -272,7 +276,8 @@ def get_part_length(part):
Abstract the length of selected part
:return: length
"""
return part.get_Parameter(BuiltInParameter.DPART_LENGTH_COMPUTED).AsDouble()
part_length =part.get_Parameter(BuiltInParameter.DPART_LENGTH_COMPUTED).AsDouble()
return part_length


def get_reveal_coordinate_at_0(__title__, part):
Expand Down
96 changes: 33 additions & 63 deletions panelization.tab/panel.panel/AutoPanel.pushbutton/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,15 @@

__title__ = "AutoPanel"

__doc__ = """Version 1.3
Date = 09.06.2023
___________________________________________________________
Description:
This tool will create multiple panel of 4' or less
by breaking down a Part into panels
Direction based on type of the Parts
Exterior Parts -> left to right
Interior Parts -> right to left
Partition Parts -> right to left
Laps based on type of Parts
Exterior Parts -> right lap
Interior Parts -> left lap
Partition Parts -> left lap
___________________________________________________________
How-to:
-> Click on the button
-> Select a Part
___________________________________________________________
last update:
- [01.07.2023] - 1.3 RELEASE
___________________________________________________________
To do:
-> Allow the user to set a constrain of the smallest panel size
___________________________________________________________
Author: Symon Kipkemei
__doc__ = """
Auto select all parts and panelize
"""

__author__ = "Symon Kipkemei"
__helpurl__ = "https://www.linkedin.com/in/symon-kipkemei/"

__highlight__ = 'new'

__min_revit_ver__ = 2020
__max_revit_ver__ = 2023
__max_revit_ver__ = 2025

# IMPORTS
################################################################################################################################
Expand All @@ -56,9 +23,8 @@
clr.AddReference("System")
from _create import _auto as a
from _create import _parts as g

import time
import random
from _create import _checks as cc
from _create import _errorhandler as eh
# VARIABLES
################################################################################################################################

Expand All @@ -74,35 +40,39 @@

def main():
selected_parts = g.select_all_parts()
non_panelized_parts = g.check_if_parts_panelized(selected_parts)
parts = g.check_if_host_wall_edited(non_panelized_parts)
non_panelized_parts = cc.check_if_parts_panelized(selected_parts)
parts = cc.check_if_host_wall_edited(non_panelized_parts)

# start by BamCore 8" Separate I-E - exterior parts
for part in parts:
layer_index = g.get_layer_index(part)
if layer_index == 1: # exterior parts
try:
a.auto_parts(__title__, part)
except ValueError:
pass
exterior_parts = []
interior_parts = []

# followed by BamCore 8" Separate I-E - interior parts
# sorted parts, starting with exterior followed by interior
for part in parts:
host_wall_id = g.get_host_wall_id(part)
host_wall_type_id = g.get_host_wall_type_id(host_wall_id)
layer_index = g.get_layer_index(part)
if layer_index == 3: # interior parts
try:
a.auto_parts(__title__, part)
except ValueError:
pass
lap_type_id, side_of_wall, exterior = g.get_wallsweep_parameters(layer_index, host_wall_type_id)

if exterior:
exterior_parts.append(part)
else:
interior_parts.append(part)

all_parts = exterior_parts + interior_parts
print (parts)

for part in all_parts:
try:
a.auto_parts(__title__, part)
except eh.CannotPanelizeError:
pass
except eh.CannotSplitPanelError:
pass
except eh.VariableDistanceNotFoundError:
pass
except Exception:
pass

# followed by BamCore 8" Int Only - interior parts
for part in parts:
layer_index = g.get_layer_index(part)
if layer_index == 2: # interior parts
try:
a.auto_parts(__title__, part)
except ValueError:
pass

if __name__ == "__main__":
# print(get_part_length(496067))
Expand Down
67 changes: 15 additions & 52 deletions panelization.tab/panel.panel/MultiPanel.pushbutton/script.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,48 +4,14 @@

__title__ = "MultiPanel"

__doc__ = """Version 1.3
Date = 09.06.2023
___________________________________________________________
Description:
This tool will create multiple panel of 4' or less
by breaking down a Part into panels
Direction based on type of the Parts
Exterior Parts -> left to right
Interior Parts -> right to left
Partition Parts -> right to left
Laps based on type of Parts
Exterior Parts -> right lap
Interior Parts -> left lap
Partition Parts -> left lap
___________________________________________________________
How-to:
-> Click on the button
-> Select a Part
___________________________________________________________
last update:
- [01.07.2023] - 1.3 RELEASE
___________________________________________________________
To do:
-> Allow the user to set a constrain of the smallest panel size
___________________________________________________________
Author: Symon Kipkemei
__doc__ = """
Select Multiple/Single Parts and panelize
"""

__author__ = "Symon Kipkemei"
__helpurl__ = "https://www.linkedin.com/in/symon-kipkemei/"

__highlight__ = 'new'

__min_revit_ver__ = 2020
__max_revit_ver__ = 2023
__max_revit_ver__ = 2025

# IMPORTS
################################################################################################################################
Expand All @@ -57,10 +23,10 @@

from _create import _auto as a
from _create import _parts as g
from _create import _errorhandler as eh

from _create import _errorhandler as eh

from pyrevit import forms

# VARIABLES
################################################################################################################################

Expand All @@ -75,19 +41,16 @@


def main():

try:
parts = g.select_parts()
# part = g.check_if_part_panelized(part)
for part in parts:
a.auto_parts(__title__, part)
except eh.CannotPanelizeError:
forms.alert('Select a Part to Panelize')
except eh.CannotSplitPanelError:
forms.alert("Centre Index could not be established")
except eh.VariableDistanceNotFoundError:
forms.alert("The variable distance could not be established")
parts = g.select_parts()
for part in parts:
try:
a.auto_parts(__title__, part, multiple=True)
except eh.CannotPanelizeError:
forms.alert('Select a Part to Panelize')
except eh.CannotSplitPanelError:
forms.alert("Centre Index could not be established")
except eh.VariableDistanceNotFoundError:
forms.alert("The variable distance could not be established")

if __name__ == "__main__":
# print(get_part_length(496067))
main()
Loading

0 comments on commit 2a1fa90

Please sign in to comment.