I´m working on a new Dynamo Script and i`m pretty happy about how far i got, but now i need your help.
Target: Create plan views for multiple levels by using one plan view as template
Create multiple plan views for multiple levels
Get parameters from template plan view (crop box, view range, scale, view template, view type)
Copy 2D-Elements from template plan
Copy Dimensionings from template plan
Set Grid like in the template plan
Set View Range. The python script by user kennyb6 is not working in plans with view direction “up”, as user pitern pointed out. All my plans have view direction up. I have no idea how to change the script and i don´t understand the error.
My script works only for creating one plan. If i add more levels it works for a specific amount of levels because in dynamo player i have to fill out all dropdowns. But i want my script to work for one plan or for 10 plans. I have no idea how to achiev this.
If the template plan view has a rotation on a sheet, the duplicated plan view doesn´t have the rotation. How can i copy and apply this rotation?
If the “get.active.view” node doen`t find anything (or finds a sheet) because i´m not in a view, the script will still create a plan, how can i stop that? I only want the sript to run with a ceiling plan or structural plan as input.
Would be happy about any advice, thank you very much in advance!
As you can see i receive the plan view as a ceiling plan when using a select.views node and the python code is working fine.
But when i take the view name from my StructuralPlanByLevel node i get the view as a StructuralPlanView and the python script does nothing.
Thank you very much Alban! You are right, i didnt see this. But there is another problem. I got it working but only by running the dynamo script a second time and switching the node where i get the view from. I cant explaine whats going on but i think i know the reason.
By creating the structural plan i get a plan with the view direction DOWN because that seems to be the default. Thats why i get the view range error on python because my parameters are for UP direction.
The Dynamo script changes the view type which changes the view direction to UP.
For some reason the python script gets the DOWN view that was created in first place, but i need to input the view after applying the new type.
I got it working, but still don`t know whats happening exactly.
As you can see, in the process of setting the parameters, the PlanView Type changes from StructuralPlan to CeilingPlan. I thought the SetParameterByName node is the reason, but now it happens at the SetCropBox node?! Would be glad if someone could explain why this is happening.
My Problem ist now, that Propagate Extents only works if the CropRegion of the views is turned off. I Can turn them off with SetParameter nodes, but i have no idea how i can turn them on after the GridExtents.
#Open a new Transaction
view.CropBoxActive = True
This successfully activates the cropbox for the view at Input 0 but not for the view in Input 1
Here is the complete code:
# Import DocumentManager and TransactionManager
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
# Import RevitAPI
from Autodesk.Revit.DB import *
from System.Collections.Generic import HashSet
pyt_path = r'C:\Program Files (x86)\IronPython 2.7\Lib'
############# DEFINITIONS START ###############
if hasattr(obj1,"__iter__"): return obj1
else: return [obj1]
############# DEFINITIONS END ###############
# declare IN-Variables
view = tolist(UnwrapElement(IN))
targetViews = tolist(UnwrapElement(IN))
# declare OUT-Variables
outList = 
#Collector - Get all grids in view...
grids = FilteredElementCollector(doc, view.Id).OfCategory(BuiltInCategory.OST_Grids)
# Get ISet of TargetViews ElementID's...
tViewIds = HashSet[ElementId]([tv.Id for tv in targetViews])
# Open a new Transaction to make changed to the Revit Document...
# Loop through all the Grids in View...
for g in grids:
outList.append("Grid " + g.Name + " - Propagation Succeeded")
except Exception, e:
outList.append("Grid " + g.Name + " - Propagation Failed" + "\n - " + e.message)
# Close Transaction and commit changes...
# Open a new Transaction
view.CropBoxActive = True
# Return the results...
OUT = outList
I edited the Python script to give the views as output and did the rest with nodes. Everything working fine now But still some problems to solve, more tomorrow. Would be great if someone could help me clean the “grid-group” up by adding the relevant lines to the python script.
Still have no idea why the script only works if i connect the python node to the setcropboxnode.
Still have no idea why only the setcropbox node gives out a ceilingplan and the others structural plans.
Has someone please any suggestions for me? DYN file attached.
What DOES work is changing the lacing of the set.parameter.by.name node an run the script a second time…
only green is working
Sorry, I do not have any great Ideas but I may have a solution for you. What if you set the crop boundary first before you changed the view type? This would then ensure that the view type is what you want it to be if View.SetCropBoxCurves is changing the type on you.
Again this is not an answer to why this is happening but it may allow your script to function properly.
Hey Steven, thanks for your reply. The “green wired” version above is working, i just wanted to solve the mystery bacause i dont understand whats going on. The version you suggested doesnt work, but don`t ask me why. It DOES work if i change the Set.Parameter lacing and run the script AGAIN…
Here is now the standalone version of the Get-Set PlanView parameter script: