-
-
Notifications
You must be signed in to change notification settings - Fork 335
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
PyRevit Synchronise #1832
Comments
something proposed by @alexdaversa is treating some features of your request #1692 |
@jmcouffin this seems like exactly what we just started to implement, but haven't finished. we should blow the dust off. |
Care for a working session this week in the morning @thumDer to check it out? |
All, this feature seems complimentary to the feature I had developed, but probably separate. The autosave PR only periodically saves the local, but does not sync to central. I could see this being implemented with two different approaches: one which uses the doc-syncing hook, and one which utilizes a toolbar button. Either approach seems viable, but if using the hooks approach, please provide a toggle to turn off this "enhanced sync" feature. I expect some users might be confused or upset that the tool closes open views. Look at my PR for an example of this. |
@alexdaversa yeah,
|
Sorry for getting back late, I'm too busy these days.
What do you guys think? Should we keep going according the above, or do you have any objections? |
|
I have bad news. I wasn't able to initiate a new sync from the hook, after cancelling the original. It will throw an Internal Error, which has no explanation in the API docs:
Our custom sync function sometimes also throws the same... Here is the related API forum thread, if anyone is interested. Here is my first experimental hook, if anybody has some time to play with it: from pyrevit import script, EXEC_PARAMS
from Autodesk.Revit.DB import TransactWithCentralOptions
from Autodesk.Revit.DB import SynchronizeWithCentralOptions
from Autodesk.Revit.DB import ICentralLockedCallback
logger = script.get_logger()
event_args = EXEC_PARAMS.event_args
doc = event_args.Document
comment_suffix = " pyRevit sync yo!"
class SyncLockCallback(ICentralLockedCallback):
def ShouldWaitForLockAvailability(self):
return False
options = event_args.Options
logger.info('Options:')
for attr in dir(options):
if attr.startswith('__') or callable(getattr(options, attr)):
continue
logger.info('{}: {}'.format(attr, getattr(options, attr)))
if comment_suffix in options.Comment:
script.exit()
logger.info('Cancelling...')
event_args.Cancel()
logger.info('Cancelled!')
twc_opts = TransactWithCentralOptions()
# twc_opts.SetLockCallback(SyncLockCallback())
# swc_opts = SynchronizeWithCentralOptions()
swc_opts = options
swc_opts.Comment += " pyRevit sync yo!"
doc.SynchronizeWithCentral(twc_opts, swc_opts) |
Could we release a simplified version of this tool minus the auto-save that does the following as per my original post?
|
I can take a gander at this - if nobody else is already doing it @jmcouffin @thumDer - Let me know :) |
@aniketdikshit please do. |
I was planning on making it a regular button as a one-off to start with :) - we eventually add more complexity - currently following what @Robbo1234 pointed out as a 4 step process should be a good starting point - though closing all inactive views is slightly dangerous - so that's probably going to a checkbox |
Hey everyone, this might be a separate feature, but I wanted to support this effort however possible, and just kinda let you all know what I am hoping to do soon. My team has recently requested a "sync queue" feature, especially for large projects. We've talked to other firms who have done this internally, but this just felt like a feature that should be available to everyone to be most effective. I haven't started on my own implementation yet, but if you want me to plug into this effort anywhere just let me know. Otherwise, I can get to a point where I can submit a PR and let you all take a look. For reference, details of the ask are:
There are of course other implications of these requests that we'll run into as the tool grows. |
@jmcouffin @Robbo1234 I didn't know how to submit a PR for this repo and also couldn't create a fun icon - but this is how the code stands
feel free to put this code in a script.py and use it as is also - if you place this code in the hooks folder in these Python files then this Sync can replace the command binding and would be the default sync for the users:
|
Thanks, Aniket
@jmcouffin <https://github.com/jmcouffin> can we incorporate this into a
PyRevit update? Thanks
…On Tue, 7 Nov 2023 at 13:17, Aniket Dikshit ***@***.***> wrote:
@jmcouffin <https://github.com/jmcouffin> @Robbo1234
<https://github.com/Robbo1234> I didn't know how to submit a PR for this
repo and also couldn't create a fun icon - but this is how the code stands
1. this first gives a pop-up as to whether you want to close all
inactive views
2. then switch the active view to the first drafting view that it finds
3. then saves - reloads latest - saves and syncs
4. 30%ish quicker sync
feel free to put this code in a script.py and use it as is
also - if you place this code in the hooks folder in these Python files
then this Sync can replace the command binding and would be the default
sync for the users:
command-exec[ID_FILE_SAVE_TO_CENTRAL].py
command-exec[ID_FILE_SAVE_TO_CENTRAL_SHORTCUT].py
from Autodesk.Revit import DB, UI
from pyrevit import script
doc = __revit__.ActiveUIDocument.Document
uidoc = __revit__.ActiveUIDocument
def close_inactiveviews() :
td = UI.TaskDialog('Better Sync')
td.TitleAutoPrefix = False
td.ExtraCheckBoxText = 'Close Inactive Open Views'
td.MainInstruction = 'Synchronize the Active Document'
td.MainContent = 'Central File Path \n{} '.format(doc.PathName)
td.CommonButtons = UI.TaskDialogCommonButtons.Cancel | UI.TaskDialogCommonButtons.Ok
td.AllowCancellation = True
result = td.Show()
if result == UI.TaskDialogResult.Cancel or result == UI.TaskDialogResult.Close :
script.exit()
return td.WasExtraCheckBoxChecked()
'This gets the first drafting view to allow for quick syncing'
def get_first_draftingView() :
all_views = (DB.FilteredElementCollector(doc).
OfClass(DB.View).
WhereElementIsNotElementType().
ToElements())
for view in all_views :
if view.ViewType == DB.ViewType.DraftingView :
return view
break
'This closes all views for the current document except the one that is passed through as input'
def close_views(view_list) :
all_open_views = uidoc.GetOpenUIViews()
for ui_view in all_open_views :
doc_view = doc.GetElement(ui_view.ViewId)
if doc_view.Name not in view_list :
ui_view.Close()
def sync_document() :
if doc.IsWorkshared and not doc.IsFamilyDocument and not doc.IsLinked :
try:
first_draftingview = get_first_draftingView()
if uidoc.ActiveView.ViewType != DB.ViewType.DraftingView :
uidoc.ActiveView = first_draftingview
except :
pass
if close_inactiveviews() :
close_views(doc.ActiveView.Name)
transOptions = DB.TransactWithCentralOptions()
syncOptions = DB.SynchronizeWithCentralOptions()
relinquish_all = True
relinquishOptions = DB.RelinquishOptions(relinquish_all)
reloadLatestOptions = DB.ReloadLatestOptions()
saveOptions = DB.SaveOptions()
syncOptions.SetRelinquishOptions(relinquishOptions)
syncOptions.Compact = True
doc.Save(saveOptions)
doc.ReloadLatest(reloadLatestOptions)
doc.Save(saveOptions)
doc.SynchronizeWithCentral(transOptions , syncOptions)
else :
UI.TaskDialog.Show("Error" , "Current Document is not Workshared")
if __name__ == "__main__" :
sync_document()
—
Reply to this email directly, view it on GitHub
<#1832 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACC6Z454ORH4N62MLMJLKH3YDIYFTAVCNFSM6AAAAAAYVKWGXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTOOJYGQ4DONJQGQ>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
This is interesting, but probably an entirely different feature (and a big one) You coul dcreate a new issue/feature request @nterranova |
I will try it and make the PR, Thanks a lot @aniketdikshit @thumDer would you like to do the PR and review? @Robbo1234 Sir, Yes Sir! Whenever I get the chance |
first implementation #2008 if you want to review @thumDer ? |
📦 New work-in-progress (wip) builds are available for 4.8.14.23326+1241-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23326+2020-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23327+1037-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23328+0920-wip |
Try it and let us know how it goes |
Installed it yesterday and it works fine.
Rob
…On Tue, 28 Nov 2023 at 12:19, Jean-Marc Couffin ***@***.***> wrote:
Thanks, Aniket and Jean-Marc for this new PyRevit feature. Rob
Try it and let us know how it goes
—
Reply to this email directly, view it on GitHub
<#1832 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ACC6Z42U72TCH534VXYESR3YGXJFRAVCNFSM6AAAAAAYVKWGXKVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTQMRZG4ZTANZUHA>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
📦 New work-in-progress (wip) builds are available for 4.8.14.23335+1813-wip |
Dang I've missed this one, sorry. I would be really interested if anyone else experiences random InternalExceptions on calling SynchronizeWithCentral() without any explanation. I'm about to make a pr on this to have an option to reopen the closed views. |
📦 New work-in-progress (wip) builds are available for 4.8.14.23338+0813-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23340+1759-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23346+0717-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23352+1117-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23352+1544-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23353+1120-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23353+1222-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23354+0922-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23354+1019-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.23354+1055-wip |
📦 New work-in-progress (wip) builds are available for 4.8.14.24012+1924-wip |
📦 New public release are available for 4.8.14.24016+1909 |
Is your feature request related to a problem? Please describe.
Best practice for synchronising in Revit would be as follows:
Describe the solution you'd like
To speed up this process would it be possible to have a PyRevit Sync button that automates the following:
Additional context
Maybe one could Shift-Click to control what Revit commands you want to run when Synchronising with Central.
The text was updated successfully, but these errors were encountered: