Automatic dimensioning of (multiple) detail lines

Hi,

I have found this great topic on automatic dimensioning in Dynamo, see: Quick Dimension Question.

I am trying to use the script provided by @Einar_Raknes in post 5, and @truevis in post 14/16, which, given a detail line, places a dimension on the given detail line.

So far it works really well when I provide 1 detail line at a time. BUT I cant get it to work on multiple detail lines…

I have tried chopping up the list of detail lines into sublists but to no effect.

Can anyone think of a way to get this workflow working on multiple detail lines at once?
I suspect that it has to do with the python script build, but to me this is still a bit too much to grasp.

Thanks in advance!

JN

1 Like

Hi JN,

Have you tried setting the lacing of the custom node that you created to Longest?

Otherwise you could use a for loop in Python:

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

clr.AddReference("RevitNodes")
import Revit
clr.ImportExtensions(Revit.Elements)
clr.ImportExtensions(Revit.GeometryConversion)

clr.AddReference("RevitServices")
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument

if isinstance(IN[0], list):
	lines = []
	for i in IN[0]:
		lines.append(UnwrapElement(i))
else:
	lines = [UnwrapElement(IN[0])]


crvs = []

for line in lines:
	crvs.append(line.GeometryCurve)
	

TransactionManager.Instance.EnsureInTransaction(doc)


for crv in crvs:
	ref = ReferenceArray()
	ref.Append(crv.GetEndPointReference(0))
	ref.Append(crv.GetEndPointReference(1))
	dim = doc.Create.NewDimension(doc.ActiveView, crv, ref)

TransactionManager.Instance.TransactionTaskDone()

OUT = dim

I use an offset to position the dimension:

and the python code becomes:

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

    clr.AddReference("RevitNodes")
    import Revit
    clr.ImportExtensions(Revit.Elements)
    clr.ImportExtensions(Revit.GeometryConversion)

    clr.AddReference("RevitServices")
    import RevitServices
    from RevitServices.Persistence import DocumentManager
    from RevitServices.Transactions import TransactionManager

    doc = DocumentManager.Instance.CurrentDBDocument

    if isinstance(IN[0], list):
    	lines = []
    	for i in IN[0]:
    		lines.append(UnwrapElement(i))
    else:
    	lines = [UnwrapElement(IN[0])]


    crvs = []

    for line in lines:
    	crvs.append(line.GeometryCurve)


    if isinstance(IN[1], list):
    	linea = []
    	for i in IN[1]:
    		linea.append(UnwrapElement(i).ToRevitType())
    else:
    	linea = [UnwrapElement(IN[1]).ToRevitType()]


    TransactionManager.Instance.EnsureInTransaction(doc)


    for i in range (0,len(linea)):
    	ref = ReferenceArray()
    	ref.Append(crvs[i].GetEndPointReference(0))
    	ref.Append(crvs[i].GetEndPointReference(1))
    	dim = doc.Create.NewDimension(doc.ActiveView, linea[i], ref)



    TransactionManager.Instance.TransactionTaskDone()

    OUT = linea

image

5 Likes

Can you send file dyn to me?
i creat my dny file, but it is fail
thanks you

Hi @khuvv.hp This is .dyn good work
D.Dim detail line.dyn (5.3 KB)

Thank you all very much for your replies! Sadly I didn’t find the time yet to continue on this great quest :slight_smile: deadlines at the office, you know the drill. But again, very grateful for the help and I’ll surely come back on it.

Please send a screenshot of your work to illustrate your question and to make it clearly and quickly understandable. Thanks :slightly_smiling_face:

@Giovanni_Brogiolo
Very thank you you have well well! my life would like to ask you about the solution to make dim from lines in a family detail line.Please see Picture!

Hi Bach,

Please try this one. It works for grids too.

Automatic Dimension03.dyn (26.0 KB)

Could you give additional information about this code and how to build it? Thanks :slight_smile:

The python code is taken from this discussion: Quick Dimension Question which refers back to this post on the Revit API forum https://forums.autodesk.com/t5/revit-api-forum/how-to-revit-2016-api-create-dimension-between-grid/td-p/5971147

A clear description of the NewDimension method can be found in the revit api docs website along with an example. http://www.revitapidocs.com/2018/47b3977d-da93-e1a4-8bfa-f23a29e5c4c1.htm

image

image

The line in IN[0] is where the dimension will be drawn (I used the lines end points + 500mm offset) while the lines in IN[1] are the dimension references.

In order to convert a line (or a grid line) to a reference we need to extract its geometry first (line 27) and then store its reference in a ReferenceArray() (line 18).

The NewDimension method is going to change the Revit project so it must be included in a Transaction.

Please note the code will work also with structural framings as you can extract a Reference from them too.

1 Like

@Giovanni_Brogiolo Very thanks for your reply soon
The thing I want is not the Grid but the lines in it (Line in family detail line)
I created this family for cutting steel beams!
And I hope to be able to dim it
Please see .rvt
Test Dim family detail line.rvt (2.0 MB)

@Bach
Please show your graph or code and ask specific questions about it.
Thanks :slight_smile:

Dear @Yna_Db
This topic has had the same script as above and I just want to do something self-only!
I sincerely apologize if I was wrong rules!

No problem! It is always possible to contribute to solve the issue with some efforts. Here is how to paste code in a post:


here are Python basics links if needed:

Now I’ve understand how get help the Dynamo fourm
Thanks @Yna_Db

1 Like

Dear all
So can it is automatic dim rebar?

1 Like

I would suggest to start a new topic with the appropriate title. You can link it to this one like so:
Share-a-link-to-this-post
Thanks :slight_smile:

Hi @Yna_Db
Since there are many topics, but still not resolved, so I think here people are ideas so I want to ask, it also does not diferen this topic
Thanks

I think this is just due to users not properly following up with the solution to their posts, as I certainly have seen solutions to this before… As seen here, one of the users on this thread above you created a new post and found a solution: Get DetailCurve From detail line family

Dimensioning rebar is an entirely different topic than dimensioning detail lines, so this is a different topic. Follow @Yna_Db 's suggestion and create a new post! Many people are very willing to help :slight_smile:

2 Likes

Is there a way to create a list of all dimensions created? Or to choose the dimension type?

It solved my problem, but it uses a different type of dimension of the one I need.

1 Like