TextElement.SetWidth for 1000s of texts

Hi Jonathan,

Would you mind showing how that looks? (Going through the width sub-list and text list)

Thanks :slight_smile:

Mark

Building on the work by @MartinSpence I would add this clause:

for i,x in zip(text, width):

This would allow to iterate through the two lists at the same time :slight_smile: (Be aware that the else statement has been slightly changed as well.)

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

doc = DocumentManager.Instance.CurrentDBDocument 
text = UnwrapElement(IN[0])
width = UnitUtils.ConvertToInternalUnits(IN[1], DisplayUnitType.DUT_MILLIMETERS)
bool = IN[2]
TransactionManager.Instance.EnsureInTransaction(doc)
if bool == True:
	for i,x in zip(text, width):
		min = i.GetMinimumAllowedWidth()
		max = i.GetMaximumAllowedWidth()
		if i.Width < min:
			i.Width = min
		elif i.Width > max:
			i.Width = max
		else:
			i.Width = x
		OUT = 0
else:
	OUT = 'Set bool to true'	
TransactionManager.Instance.TransactionTaskDone()
1 Like

Arg, yeah I saw that in a post from Kulkul when I did some searching, but I have to implement the update company wide, so there was a bit more work to it, then just me installing the update :-).

I’ll get it done though, and thx for the tip :slight_smile:

I completely missed the fact, that @vanman was attempting to set a width for each Note. Zip would definately be the way to go.

Another way would be to acquire the width and perform the actual multiplication in the python node instead of setting the width with a slider :slight_smile:

1 Like

Fantastic! Thanks!

Thanks for all the help! Sorry to be a pain… Not sure what I’ve done wrong applying @Jonathan.Olesen code? I took away the millimeters format. I do use the metric system. I just dont know to adjust dynamo for that.

Fooling around and tried to make a node… no luck…

Please share your .rvt and .dyn :slight_smile:

The output of the script is purposely 0 if successful though, check revit if the changes have been applied successfully :slight_smile: