Skip to content

Commit

Permalink
Merge pull request #1765 from nodatasheet/1704
Browse files Browse the repository at this point in the history
  • Loading branch information
jmcouffin authored May 2, 2023
2 parents bb2d83d + bc892be commit b42c438
Show file tree
Hide file tree
Showing 8 changed files with 15 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ def recall():
"""Load last matched properties from memory."""
data = []
try:
with open(MEMFILE, 'r') as mf:
with open(MEMFILE, 'rb') as mf:
data = pickle.load(mf)
except Exception as ex:
logger.debug(
Expand All @@ -125,7 +125,7 @@ def recall():

def remember(src_props):
"""Save selected matched properties to memory."""
with open(MEMFILE, 'w') as mf:
with open(MEMFILE, 'wb') as mf:
pickle.dump(src_props, mf)


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,13 @@
selected_ids = {str(elid.IntegerValue) for elid in selection.element_ids}

try:
f = open(datafile, 'r')
f = open(datafile, 'rb')
prevsel = pickle.load(f)
new_selection = prevsel.union(selected_ids)
f.close()
except Exception:
new_selection = selected_ids

f = open(datafile, 'w')
f = open(datafile, 'wb')
pickle.dump(new_selection, f)
f.close()
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@


try:
f = open(datafile, 'r')
f = open(datafile, 'rb')
current_selection = pickle.load(f)
f.close()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@
selection = revit.get_selection()
selected_ids = {str(elid.IntegerValue) for elid in selection.element_ids}

f = open(datafile, 'w')
f = open(datafile, 'wb')
pickle.dump(selected_ids, f)
f.close()
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
selected_ids = {str(elid.IntegerValue) for elid in selection.element_ids}

try:
f = open(datafile, 'r')
f = open(datafile, 'rb')
prevsel = pl.load(f)
newsel = prevsel.difference(selected_ids)
f.close()
f = open(datafile, 'w')
f = open(datafile, 'wb')
pl.dump(newsel, f)
f.close()
except Exception:
f = open(datafile, 'w')
f = open(datafile, 'wb')
pl.dump([], f)
f.close()
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
filter_name = \
'SavedSelection_' + coreutils.timestamp()

with open(data_file, 'r') as f:
with open(data_file, 'rb') as f:
cursel = pl.load(f)

with revit.Transaction('pySaveSelection'):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ def iterate(mode, step_size=1):
selection = revit.get_selection()

if op.exists(index_datafile):
with open(index_datafile, 'r') as f:
with open(index_datafile, 'rb') as f:
idx = pickle.load(f)

if mode == '-':
Expand All @@ -32,7 +32,7 @@ def iterate(mode, step_size=1):

if op.exists(datafile):
try:
with open(datafile, 'r') as df:
with open(datafile, 'rb') as df:
cursel = pickle.load(df)

if cursel:
Expand All @@ -43,7 +43,7 @@ def iterate(mode, step_size=1):

selection.set_to([DB.ElementId(int(list(cursel)[idx]))])

with open(index_datafile, 'w') as f:
with open(index_datafile, 'wb') as f:
pickle.dump(idx, f)
except Exception as io_err:
logger.error(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def copy_zoomstate(sender, args):
# get zoom corners
cornerlist = current_ui_view.GetZoomCorners()
# and save the info
f = open(get_datafile(event_doc), 'w')
f = open(get_datafile(event_doc), 'wb')
try:
# dump current view type
pl.dump(type(args.CurrentActiveView).__name__, f)
Expand Down Expand Up @@ -108,7 +108,7 @@ def apply_zoomstate(sender, args):
return

# load zoom data
f = open(get_datafile(event_doc), 'r')
f = open(get_datafile(event_doc), 'rb')
try:
view_type_saved = pl.load(f)
if view_type_saved != type(args.CurrentActiveView).__name__:
Expand Down

0 comments on commit b42c438

Please sign in to comment.