Quick Dimension Question

Hi Einar, Thanks for your reply, yes i have seen the wall trick and i have used it on some occasions but i was just wondering if anybody could show me how to create the dimension script so that i can start to get an idea how they are made.

Thanks

Marcello showed one at his AU2015 Dynamo presentation. He hasn’t released it yet though…

You can start with this simple script: It’s just the example from NewDimension class in Revit API help. http://revitapisearch.com/html/47b3977d-da93-e1a4-8bfa-f23a29e5c4c1.htm

Select a detail line and a dimension will be created along it:


4 Likes

To find the refrences from grids is a little bit trickier, but Harry from Boostyourbim showed it in this tread: http://forums.autodesk.com/t5/revit-api/how-to-revit-2016-api-create-dimension-between-grid/td-p/5971147

Maybe you can try something like this:

1 Like

Einar, Do you have to draw a line through the grids to acheive this ? and is there anyway i can copy the text in the code block instead of typing it all out ?

Cheers

Kieran

In the last example the line is made in dynamo from the grids start points.

Here is the code, but you can learn a lot from transcribing!

import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

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

#Converting input from Dynamo to Revit
line = IN[0].ToRevitType()
grids = UnwrapElement(IN[1])

#Getting refrences from grid
gridRef = ReferenceArray()
opt = Options()
opt.ComputeReferences = True
opt.IncludeNonVisibleObjects = True
opt.View = doc.ActiveView
for grid in grids:
	for obj in grid.get_Geometry(opt):
		if isinstance(obj, Line):
			gline = obj
			gridRef.Append(gline.Reference)

#Create the dimension in a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

dim = doc.Create.NewDimension(doc.ActiveView, line, gridRef)

TransactionManager.Instance.TransactionTaskDone()

OUT = dim
2 Likes

Einar

I seem to get an error message,

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 20, in
IndexError: index out of range: 1

Did this happen when you ran it ?

Sounds like you need to add another port to your python node:

I have added the extra port but im still getting an error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 28, in
TypeError: iteration over non-sequence of type NoneType

Is there something i am doing wrong ? Dimension Line.dyn (6.3 KB)

Have you connected the grid elements to it?

[quote=“Kieran_Atherton, post:11, topic:4168”]
Is there something i am doing wrong?
[/quote]Extra semicolon near end?

For copy/paste people:

"
import clr
clr.AddReference('RevitAPI')
from Autodesk.Revit.DB import *

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

#Converting input from Dynamo to Revit
line = UnwrapElement(IN[0]).GeometryCurve

ref = ReferenceArray()
ref.Append(line.GetEndPointReference(0))
ref.Append(line.GetEndPointReference(1))

#Create the dimension in a transaction
TransactionManager.Instance.EnsureInTransaction(doc)

dim = doc.Create.NewDimension(doc.ActiveView, line, ref)

TransactionManager.Instance.TransactionTaskDone()

OUT = dim
";
1 Like

I get this error:

Warning: IronPythonEvaluator.EvaluateIronPythonScript operation failed.
Traceback (most recent call last):
File “”, line 19, in
AttributeError: ‘Line’ object has no attribute ‘GeometryCurve’

I published “Dimension Detail Line” based on @Einar_Raknes’s code, here

You can see how that one works.

1 Like

I tried to use this and it returns error in Revit2017:
Traceback (most recent call last):
File “”, line 36, in
Exception: Invalid number of references.

The original post shows the way in Revit2016, and I do not have 2016 to test at the moment. Is there any changes on 2017?

It was tested in 2017. Number of references is equal to number of grid lines. You have to select at least two parallel lines

This is pretty strange, the same error message keeps poping up.
I tried to individually select the line and three single line grid, but after the python, it generates 8 null references.
Attached are the screenshots for nodes and python code.
Any suggestions are welcome.


I’m not sure what could be wrong. Here is a revit and dyn file that works for me: (Revit 2017, dynamo 1.0.0.1180)

dimensionGrids.dyn (6.3 KB)
dinensionGrids.rvt (1.6 MB)

2 Likes

Thans Einar, it works.
I wonder what is the difference in PythonScript from String and PythonScript itself?
Seemed that is where the error comes from.

Hello Einar,
I have tried to follow your solution here, but I’m a little hamstrung by the fact I only have Revit 2016, however I wondering if another solution could be made from a different point of view. That being instead of retrospectively trying to fit dimensions to a grid, they could be fitted to the grid when the grid is created ?

Even better, have the construction of the Grid controlled in an Excel file where you have the set-out points defined.
Have a look at the solution posted here How to create Grid lines from an Excel file https://forum.dynamobim.com/t/how-to-create-grid-lines-from-an-excel-file-or-tabulated-survey-points

I can see the VB.NET code from http://revitapisearch.com/html/47b3977d-da93-e1a4-8bfa-f23a29e5c4c1.htm uses VB code to create a DIM dimension, but I’m unsure how to incorporate that, or generate the correct code in Dynamo to create a dimension line. Perhaps the VB code can further streamlined given that the points are already defined. Any help is always appreciated.