i have tried but i didn’t get any node for this.
if you have so many text notes when you need to drag each and every text notes one by one.
i wonder we can drag multiple text notes with help of dynamo.
is this possible with dynamo ?
Thanks in Advance.
Sure, you can adjust the text width through the width property in the API. Here is an example Python script, where it doubles the width of the textnotes. You can change it to a specific number if you know it or just increase the multiplication.
Python:
import clr
# Import RevitAPI
clr.AddReference('RevitAPI')
import Autodesk
# Import DocumentManager and TransactionManager
clr.AddReference('RevitServices')
import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager
doc = DocumentManager.Instance.CurrentDBDocument
if isinstance(IN[0], list):
txts = UnwrapElement(IN[0])
else:
txts = [UnwrapElement(IN[0])]
# Place your code below this line
output = []
for txt in txts:
TransactionManager.Instance.EnsureInTransaction(doc)
try:
width = txt.Width
txt.Width = width * 2 #change this to whatever width needed
output.append("success")
except:
output.append("failed")
TransactionManager.Instance.TransactionTaskDone()
# Assign your output to the OUT variable.
OUT = output
Keep in mind that every time you run the script (careful for automatic mode) it will double whatever textnotes you put in the IN[0]
Yes lol. Please read what was written carefully, instead of just trying to copy and paste everything without understanding. First off, it requires an input. That input should be a textnotes list. If you want to do every text note in the document, you can use categories (text notes) → all elements of category → IN[0] of the python.
Second, please pay attention when you copy and paste things. Clearly the “Keep in mind…” portion is not inside the code, so you should not have it added inside the python (your line 34). That is a warning for you to read.
Dear @kennyb6
lol. i was totally lost. sorry for that
see below image i have select text notes with “select model elements” node.
but still not change text width.
i have removed line 34. but still getting this error.
Ahh I see the problem, when I copy and pasted the code, two indents were lost. Line 16 and line 18 should have an indent before them. Press tab before the txts = … for both of those lines. I have edited the original post to fix it.
No problem! Glad you can find it useful. But keep in mind that I wrote in the script to only double the width. Depending on your text note contents, that might not be enough for all of them. You can always increase it by adjusting the line 26 of the python script to another number.
Width of a single character is tricky because that requires you to know the font and the width of charaacters in the font, which I don’t think is possible.
For the number of characters, that is easier. You can take the textnote’s .Text property (this returns the string inside the textnote), get the length of that string, and multiply it by some number (what you think the average width of a single character is) to get an approximation.