CH_W
March 13, 2019, 10:44pm
1
I’m trying to use Dynamo to make dimensions of multiple siding components.
First run works well. The second time I run it in a different view, it creates a new dimension based on new components. Then dimensions in the first run are changed. See screenshots:
Code:
"
#Original code from @Einar_Raknes
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
Curve_List = IN[0]
Dim_All = []
Line_2 = IN[1]
opt = Options()
opt.View = doc.ActiveView
for i in range(0, len(Curve_List)):
#Converting input from Dynamo to Revit
Line_1 = UnwrapElement(Curve_List[i]).GeometryCurve
line = UnwrapElement(Line_2[i]).GeometryCurve
ref = ReferenceArray()
ref.Append(Line_1.GetEndPointReference(0))
ref.Append(Line_1.GetEndPointReference(1))
#Create the dimension in a transaction
TransactionManager.Instance.EnsureInTransaction(doc)
dim = doc.Create.NewDimension(doc.ActiveView, line, ref)
TransactionManager.Instance.TransactionTaskDone()
Dim_All.append(dim)
OUT = Dim_All
";
Kulkul
March 14, 2019, 2:50am
2
Hi @CH_W
Edit: I tested your code in multiple views i didn’t see any changes in first run . Try restarting your pc.
@Kulkul - Were your views parallel but reversed normals?
CH_W
March 14, 2019, 11:42pm
4
Hi @Kulkul
Thank you for your answer. I tried what you said. Now there is an error "list object has no attribute ‘ToDSType’ "
Then I tried this
for j in range(0, len(Dim_All)):
Dim_All[j].ToDSType(True)
OUT = Dim_All
It runs without error. But it still gives me the same dimension result. The second dimension is still messed.
CH_W
March 14, 2019, 11:45pm
5
@Kulkul
I tried to restart PC and Revit. Still the same.
In my case, I’m making dimensions in EAST and WEST elevation. And it doesn’t work. But if I do EAST and SOUTH elevations, it works well.
I have no idea why.
SeanP
March 15, 2019, 12:40am
6
Try using .ToDSType(False) so they aren’t Dynamo owned elements. This may keep them from changing each run, but it also means you can get duplicates if you run it twice on the same view.
You mean “aren’t Dynamo owned elements.”
This does sound like an element binding issue. Check the forum as I have a good post from last month on that topic.
1 Like
Kulkul
March 15, 2019, 2:30am
8
@CH_W Could you please share rvt file.
And the .dyn.
Found the post I was referring to before.
Element binding is the name given to the process which Dynamo manage to ‘track’ the items created in non-Dynamo files. In this case, I’m going to focus entirely on element binding as it refers to Dynamo for Revit, but the mechanism exists to allow for this behavior in other applications (advanced steel, fusion, alias, etc.) as well. In the context of Revit, ‘elements’ refers to anything with an Element ID in the Revit database. When utilized correctly, element binding will expand how you leverag…
CH_W
March 15, 2019, 8:37pm
10
Hi @SeanP
I tried .ToDSType(False) then when i run it in the second view, it delete the first dimensions
CH_W
March 15, 2019, 8:41pm
11
Hi @jacob.small
I read this post but don’t really understand why it’s related…