I’m trying to combine the two methods of automatically dimension in Dynamo. I can dimension element to element using “Dimension.By.Elements” node. And I can dimension face to face using this python script
Here is the code that works for Face to Face dimensioning
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
from Revit.Elements import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
dataEnteringNode = IN
doc = DocumentManager.Instance.CurrentDBDocument
line = UnwrapElement(IN[0]).GeometryCurve
elements=(IN[1])
dim = 0
elementsRef = ReferenceArray()
opt=Options()
opt.ComputeReferences=True
opt.IncludeNonVisibleObjects=True
opt.View=doc.ActiveView
for element in elements:
elementsRef.Append(element)
TransactionManager.Instance.EnsureInTransaction(doc)
dim=doc.Create.NewDimension(doc.ActiveView, line, elementsRef)
(True)
TransactionManager.Instance.TransactionTaskDone()
OUT = dim
And here is the one I am working on now to try and dimension from a floor edge to a grid line
import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *
clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)
from Revit.Elements import *
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *
clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
line = UnwrapElement(IN[0]).GeometryCurve
grid = UnwrapElement(IN[1])
elements=(IN[2])
dim = 0
geomopt=Options()
geomopt.ComputeReferences=True
geomopt.IncludeNonVisibleObjects=True
geomopt.View=doc.ActiveView
refg = []
for i in grid:
r = i.get_geometry(geomopt)
[refg.append(j.Reference) for j in r if str(j).contains('line')
for j in elements:
elementsRef.Append(element)
dim = []
TransactionManager.Instance.EnsureInTransaction(doc)
for i,j,k in zip(refg,elementsRef,IN[0]):
refarr = ReferenceArray()
refarr.Clear()
refarr.Append(i)
refarr.Append(J)
dim.append(doc.Create.NewDimension(doc.ActiveView,k.ToRevitType(),refarr))
TransactionManager.Instance.TransactionTaskDone();
OUT = dim
It is actually a variant of something you posted on another discussion
Any help from you at all would be greatly appreciated
Could you please paste your code as preformatted text like @Mostafa_El_Ayoubi mentioned above? It will be easier for users to help troubleshoot for you without having to indent all the code. also what is the error that is appearing when you run it?
Essentially I know how to dimension from element to element, for example, gridline to the centre of a wall, column etc. I also have some python code that will dimension from the face of a wall to a face of wall. But now I’m trying to figure out how to tweak this python code to dimension from a gridline to a face of a wall. Does that make sense?