Clockwork - add a Text.Width node?

Andreas, don’t know if you’re “listening” or not, but:
I’m working on a graph to help fix the 2017 text issues.
Basically what I’m doing is exporting a list of all Text Elements from 2016.
Then, after the .rvt file is upgraded, I run another graph and compare the two.
If the 2017 file’s Text Element has more lines, that tells me that a word got wrapped, so I make the Text Box a bit wider.
I bastardized the Clockwork nodes TextElement.Text and TextElement.SetText and in Python, changed the item.Text parameter to item.Width.

I thought it would behave itself, and it does if I pass a single element.
But if I pass a list, it looks like it only does the first one & tries to change that one repeatedly.
If I use the unchanged TextElement.SetText, it works as expected. But all I did was change “.Text” to “.Width” !

So, is this something I screwed up, or is it something in the TextElement.SetText node? Or is it working as intended and I don’t know how to use it properly?

BTW. Thanks for writing Clockwork. I don’t know where I’d be without it!

TextElement.SetWidth.dyf (10.5 KB)
TextElement.Width.dyf (4.3 KB)

1 Like

Hi Dave,

I have modified custom node. It looks good now. Check this out TextElement.SetWidth.dyf (10.2 KB)

Could you drop the other custom node “TextElement.SetText” so that i will modify that node as well.

Thanks, kulkul.i didn’t modify the SetText node. That’s straight out of the latest build of Clockwork.
I’m on my way to RTC this morning, so unfortunately I can’t test your fix. That’ll have to wait till Monday.
Thanks again.

You may be able to run into some of the Bad Monkeys there and discuss ideas! Find Marcello and let him know, he has been experimenting with stuff along this line. :wink:

Back from RTC. Lots of good stuff there!
Thanks for the node.
I’m afraid, however, that I’m not seeing any difference.
I’m wondering it you uploaded the old file? I can’t see any difference in either the custom node or the Python code and I’m getting the same results. Or perhaps I’m still somehow pointing at the old code.
I opened up what I downloaded and other than the location of some nodes, I can’t see anything different. Since the nodes moved, I assume I have the correct version.
Could you possibly send the the Python Code as a text file? Sadly, I know very little about Python.

I don’t have Dynamo 0.9 installed anymore, but I’m wondering if something changed in 1.0.
I created a simple version of my graph, with just a Select Model ELements, and the SetWidth node. I also added a straight OOTB node from Clockwork TextElement.SetText and it fails in the same mannerTextTest.dyn (6.4 KB)

Hello Dave,

I suspect that the DS condtional statement behavior has chanced. (to work similar to the if node with shortest lacing, can anyone confirm?)

Try to replace the codeblock with this:

num = List.Count(seq1);
cond = List.Count(seq2) < 2 && num > 1;
repseq = List.OfRepeatedItem(seq2[0],num);
Flatten(cond ? repseq<1> : seq2);
1 Like

Hi Dave,

I would suggest you uninstall clockwork package temporary and try what @Einar_Raknes suggested. I have tested from my side it works fine.

@DaveP, within the clockwork node, there should be a “Turn Into List” node. If you expand this node what do you see?

There’s just an input and an output node, with a Code Block in between.
That has just one line:

Hmm, I just looked back at your first example where you are setting the text “bob”. The input list is longer than the value, so you should be able to change the lacing to longest in a situation like this.

Exactly John, and that’s what the code block is for, but it doesn’t work as it should. I think it can be fixed like this:

An other option is to remove the lists in the custom node all togheter and let dynamo do the lacing.

I’m verifying with different situations, but for the first few cases I’ve tried, it looks like the change suggested by Einar is working.
Jon, for that first sample, I added the SetText node just as a test to see if the unchanged node from Clockwork behaved the same as the one I had modified. My actual code that uses my modified SetWidth (all I did in Python was change “.Text” to “.Width”) passes two lists that are of the same length. First list is Element IDs, second is the original Width for each multiplied by my “Embiggen Factor”.

I’m pretty close to getting this whole thing to work. Just a couple of tweaks and a lot of cleaning up & I’ll post the working code. FIngers crossed.

The other option: Make a much simpler python script that work for one element and one string. Make sure to define the inputs in the custom node as shown below. That way dynamo will know how to apply the correct lacing options.

import clr
from Autodesk.Revit.DB import *

import Revit

import RevitServices
from RevitServices.Persistence import DocumentManager
from RevitServices.Transactions import TransactionManager

doc = DocumentManager.Instance.CurrentDBDocument
element = UnwrapElement(IN[0])
text = IN[1]


element.Text = text


OUT = element
1 Like

I redid the node according to Einars’ suggestion and it works great.
Here’s the code

and here’s what my entire graph does.
I export a bunch of info about the text from 2016 to Excel.
Then I run the same thing in 2017 and examine how many lines are in each text box. If the text Word-wrapped because the 2017 text got bigger, there is more than one additional line of text. If so, I increase the width of the text box (about 6%)
Here’s three PDFs. the original 2016 text, after upgrading to 2017, and finally after running my script.
Doesn’t fix everything, but it gets rid of the worst cases.
I need to clean up a few items yet. Once I do, I’ll post the final graph in a new thread
2016 General Notes.pdf (22.8 KB)
2017 General Notes Before.pdf (55.5 KB)
2017 General Notes After.pdf (55.4 KB)

1 Like


I was giving this a go but get null values as a result. Might have something to do with the picture below. Do you know how I get it to not have the error “cannot find type element”?


You can only type Element.
This removes the error.

Thanks, script seems to fail then though?


Try element : var or something like that. Important is what comes after the colon. It tells Dynamo that the input is a single element and Dynamo will repeat the python script accordingly.

1 Like