Hello everyone,
I found a very helpful script from youtupe.
But it only work in active view.
Can we improve the script which can modify the grid in multi-selected views.
Hello everyone,
I found a very helpful script from youtupe.
But it only work in active view.
Can we improve the script which can modify the grid in multi-selected views.
If you upload both the graph and possible python scripts it would go a long way so everyone doesn’t have to reinvent the wheel.
EDIT:
Went to the youtube video and found the graph:
SetGridExtents01.dyn (29.2 KB)
I believe the unloaded node is from an old version of spring nodes.
Or use Scope Box = )
My guess is that you should simply input another view that is not the activeview (red node in my previous post).
Thank you!
I have to change some old node to get it to work on the active view
First python script is to get grid length
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
# Import DocumentManager and TransactionManager
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
# Import RevitAPI
clr.AddReference("RevitAPI")
import Autodesk
from Autodesk.Revit.DB import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.GeometryConversion)
doc = DocumentManager.Instance.CurrentDBDocument
uiapp = DocumentManager.Instance.CurrentUIApplication
app = uiapp.Application
grids = UnwrapElement(IN[0])
view = UnwrapElement(IN[1])
gridCurves = []
curves = []
for g in grids:
gridCurves.append(g.GetCurvesInView(DatumExtentType.Model, view))
for i in range(0,len(gridCurves)):
for c in gridCurves[i]:
start = c.GetEndPoint(0)
end = c.GetEndPoint(1)
curves.append(Line.CreateBound(start,end).ToProtoType())
#Assign your outputs to the OUT variable
OUT = curves
And the last script is for setting grid lines
import clr
clr.AddReference(‘ProtoGeometry’)
from Autodesk.DesignScript.Geometry import *# Import DocumentManager and TransactionManager clr.AddReference("RevitServices") import RevitServices from RevitServices.Persistence import DocumentManager from RevitServices.Transactions import TransactionManager # Import RevitAPI clr.AddReference("RevitAPI") import Autodesk from Autodesk.Revit.DB import * clr.AddReference("RevitNodes") import Revit clr.ImportExtensions(Revit.GeometryConversion) doc = DocumentManager.Instance.CurrentDBDocument uiapp = DocumentManager.Instance.CurrentUIApplication app = uiapp.Application grids = UnwrapElement(IN[0]) view = UnwrapElement(IN[1]) crvs = UnwrapElement(IN[2]) curves = [] curvesViews = [] TransactionManager.Instance.EnsureInTransaction(doc) for i in range(0,len(grids)): grids[i].SetCurveInView(DatumExtentType.ViewSpecific,view,crvs[i]) TransactionManager.Instance.TransactionTaskDone() #Assign your outputs to the OUT variable OUT = grids
If you wish to run on several views either you can pack the graph into a custom node and use that functionality. Otherwise you have to rewrite the python to take multiple views (using for loops).
You should post the graph as well in your solution as it is not possible to see what is going on in your graph and there is for sure some python in there
For anyone interested the graph by @dongthl is for Dynamo 2.0, so it will not be applicable for people who have not yet updated
When I try to open this definition, I get errors. Even in Dynamo 2.0 i get errors. Can you post a clear picture of this definition?
@dongthl…Hi…Can you please post a small video running the script as it may help the community a lot…Thank you
Many thanks to all for the great conversation, I’ve refined and recreated a script that puts everything in the discussion here together (and a few more features like Grids Bubbles manipulation) with a Dynamo player UI (Revit 2020.2 + Dynamo 2.3):
You can find the script in the repo below ( ATnodes_Fit Grids to Viewport Crop Region.dyn)
https://github.com/alitehami/ATnodes-DynamoRevit/tree/main/scripts
Enjoy ~
Ali T.
Hi @ali.tehami,
Thank you a lot for your work, it’s awesome!
I tried to adapt it to work with a list of multiple views (the final goal is to make it work on all views in the project), but it does not seem to work as well as expected…
To make it work, I “broke” your custom nodes to take it directly in the main graph. Then I made some modifications in the python script in the “@All Elements of Category in View” to accept a list of views, and to treat it one by one. The modified script filters the list of views to keep only the ones that have grids on them (to avoid an error if there is no grids to work on).
The graph works this way, but acts only on the last view of the list, and I don’t understand why…
Translation of the watch nodes, after the python script :
Would it be ok for you to help me make it work?
You will find an image and my graph in attachement.
Thank you,
Etienne