Hello,
i want to set temporary view on/ off but how
import clr
import sys
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
from Autodesk.Revit.DB.Structure import *
clr.AddReference('RevitAPIUI')
from Autodesk.Revit.UI import *
clr.AddReference('System')
from System.Collections.Generic import List
clr.AddReference('RevitNodes')
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
clr.ImportExtensions(Revit.Elements)
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
uidoc=DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
v = doc.ActiveView;
v.EnableTemporaryViewPropertiesMode(v.Id);
OUT = "done"
Online Documentation for Autodesk's Revit API: 2015, 2016, 2017, 2017.1, 2018
… and disable…
KR
Andreas
… i solved it partly
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import *
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
vId = UnwrapElement(doc.ActiveView.ToDSType(True))
TransactionManager.Instance.EnsureInTransaction(doc)
doc.ActiveView.EnableTemporaryViewPropertiesMode(vId.Id)
TransactionManager.Instance.TransactionTaskDone()
OUT = vId
how can i swich between on and off ?
KR
Andreas
You should provide the View Template Id.
As stated in the Documentation.
Turning the Temp view state off again is a little different.
@Joelmick ,
it is driven by a boolean…
is there not a solution like a lightswitch ?
each run is true → false → true …
KR
Andreas
@Joelmick ,
yes it is a “one” click solution
background is that i want to create button (on/off)
f.e. shortcuts work in this way for temporary view i have TT i can with TT go on/off
KR
Andreas
I do not understand what you are trying to do?
You want to create a button and when you click it, the view should be in Temporary properties mode.
Then when you click it again it should be normal?
Keep in mind that, when I click the my python node, this is only to re-execute Dynamo.
1 Like
@Joelmick ,
yes exactly… like a light switch…
on/off just by one click
KR
Andreas
You are aware that this is already a button in Revit right?
You can assign a short key to it.
2 Likes
@Joelmick ,
is this code correct ? it makes nothing
import clr
import sys
import System
clr.AddReference("System")
from System import *
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.AddReference("RevitServices")
import RevitServices
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitAPIUI")
import Autodesk
from Autodesk.Revit.UI import *
from RevitServices.Persistence import *
from RevitServices.Transactions import TransactionManager
bool = IN[0]
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
uidoc = DocumentManager.Instance.CurrentUIApplication.ActiveUIDocument
TransactionManager.Instance.EnsureInTransaction(doc)
activeView = doc.ActiveView
viewTemplateId = activeView.ViewTemplateId
if viewTemplateId != ElementId.InvalidElementId:
if bool:
activeView.EnableTemporaryViewPropertiesMode(viewTemplateId)
else:
activeView.DisableTemporaryViewMode(TemporaryViewMode.TemporaryViewProperties)
TransactionManager.Instance.TransactionTaskDone()
#Assign your output to the OUT variable.
OUT = "Temporary View"
if the single button is not possible… i can create a window with a button on off like
Your code is correct, but your view does not have a view template.
The whole Idea of the Temp View props function is that you apply view properties of a certain view template to you view temporarly. If your view does not have a view tempate, the code does not know which view template you need
1 Like
@Joelmick ,
thats right! thanks…
thats mostly the case to have a template
So is this now resolved? and which of the posts is the solution?
@Joelmick ,
the next step is to connect it with view settings f.e. highlight roumbounderies, or planregions a.s. o.
Thank you
KR
Andreas