Dynamo making dimensions changes earlier dimensions

dynamo

#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

";


#2

Hi @CH_W

Edit: I tested your code in multiple views i didn’t see any changes in first run :thinking:. Try restarting your pc.


#3

@Kulkul - Were your views parallel but reversed normals?


#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.


#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.


#6

Try using .ToDSType(False) so they aren’t Dynamo :wink: 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.


#7

You mean “aren’t Dynamo owned elements.” :slight_smile:

This does sound like an element binding issue. Check the forum as I have a good post from last month on that topic.


#8

@CH_W Could you please share rvt file.


#9

And the .dyn. :slight_smile:

Found the post I was referring to before.


#10

Hi @Sean1

I tried .ToDSType(False) then when i run it in the second view, it delete the first dimensions


#11

Hi @JacobSmall

I read this post but don’t really understand why it’s related…


#12

Hi @Kulkul

Here are my test files…
First go to East elevation, choose “…east” family type and run
Then in West elevation, choose “…west” and run
You will see what’s going on…

CH-W Dynamo test.rvt (3.5 MB)

CH-W Dynamo test.dyn (45.7 KB)