Open ColinDayOrg opened 6 years ago
Comment by andydandy74 Wednesday Oct 21, 2015 at 02:26 GMT
I just tried a few other things and it seems like any command that is tied to to the UIDoc object is being blocked.
Comment by epeter- Monday Nov 02, 2015 at 09:57 GMT
andreas, that is odd. i think that i succeeded in the change of active views in older versions of dynamo......
Comment by andydandy74 Monday Nov 02, 2015 at 11:45 GMT
peter, if you happen to find your old code could you post it here? thanks.
Comment by epeter- Monday Nov 02, 2015 at 15:36 GMT
andreas i definitely will. 2morrow i am in office and check. best peter Am 02.11.2015 um 12:45 schrieb Andreas Dieckmann:
peter, if you happen to find your old code could you post it here? thanks.
— Reply to this email directly or view it on GitHub https://github.com/DynamoDS/Dynamo/issues/5573#issuecomment-152996364.
Diese E-Mail wurde von Avast Antivirus-Software auf Viren geprüft. https://www.avast.com/antivirus
Comment by ksobon Tuesday Feb 23, 2016 at 17:55 GMT
@andydandy74 I think this might be an issue of Transactions. If I remember correctly the Revit API documentation states that in order to set a Current View, you need to have all Transactions closed. What you are doing is opposite. Please try ForceCloseTransaction and then set the Active View.
Comment by choiie Tuesday Sep 13, 2016 at 12:43 GMT
@ksobon ForceCloseTransaction() did not work to achieve this functionality. Can somebody chime into this discussion? This seems like pretty basic functionality.
Comment by ThomasMahon Monday Mar 20, 2017 at 11:47 GMT
Just found this thread and thought I'd update it since I've been developing a tool in Dynamo which includes a set view action. I discovered, as @ksobon points out, that activating the view in a transaction is not possible. Its also not possible to set the uidoc.ActiveView
property in Revit's Idling even, and that's obviously a problem when trying to do this through Dynamo!
That leaves only one option, the uidoc.RequestViewChange()
method. Its a bit limited as it's asycronous, but it works, and ForceCloseTransaction
has to be called otherwise it throws the exception @andydandy74 reported.
Here's a code snippet:
#Copyright 2016. All rights reserved. Bimorph Consultancy LTD, 5 St Johns Lane, London EC1M 4BH www.bimorph.co.uk
#Written by Thomas Mahon @Thomas__Mahon info@bimorph.co.uk Package: bimorphNodes
#GitHub: https://github.com/ThomasMahon/bimorphNodes/
#Follow: facebook.com/bimorphBIM | linkedin.com/company/bimorph-bim | @bimorphBIM
import clr
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
doc = DocumentManager.Instance.CurrentDBDocument
uidoc = DocumentManager.Instance.CurrentUIDocument
TransactionManager.Instance.EnsureInTransaction(doc)
TransactionManager.Instance.ForceCloseTransaction()
view = UnwrapElement(IN[0])
uidoc.RequestViewChange( view )
Comment by jtotheb86 Monday Aug 28, 2017 at 09:09 GMT
@ThomasMahon thanks for your code above. Can you help modifying to accept a Document input, instead of using the current document.
Trying to use this in Dynamo for opening families in the background, setting the active view to a 3D view and saving.
I'm very new to Python script and am struggling
Issue by andydandy74 Wednesday Oct 21, 2015 at 01:54 GMT Originally opened as https://github.com/DynamoDS/Dynamo/issues/5573
I thought I could do this by myself using a Python node, but no such luck. Dynamo tells me that setting the active view is currently disabled. Looks like this can only be done via a proper built-in Dynamo node. FWIW, here's my Python code: