Custom Node Behavior - 2

Hi everyone,

I’m creating a custom node to wrap a string at a specified index, as you can see below the python scripts works properly until I create the custom node and use an integer lower than 10.
Obviously the custom node and the python script contain exactly the same code.

Any idea why this is happening?

Hi @Mauro ,

It works for me (Dynamo 1.3.0)

1 Like

For me it works as well. Try to add the traceback library to check what is the Exception thrown. The if statement for length <= 0 is just to avoid 0 or negative values to be used.

import clr
clr.AddReference('ProtoGeometry')
from Autodesk.DesignScript.Geometry import *

import sys
sys.path.append(r'C:\Program Files (x86)\IronPython 2.7\Lib')
import textwrap
import traceback

#The inputs to this node will be stored as a list in the IN variables.
text = IN[0]
length = IN[1]

def wraptext(tx, l):
	b = textwrap.dedent(tx).strip()
	for width in [l]:
		c = textwrap.fill(b, width = width)
		return c

#Assign your output to the OUT variable.
try:
	if(length <= 0):
		length = 1
	OUT = wraptext(text, length)
except:
	OUT =traceback.format_exc()
1 Like

Thanks,

I just tried to put together the custom node again and it worked properly.