0

I use python for some scripting tasks in Vectorworks (CAD application). Vectorworks offers a visual programming interface like grasshopper with python under the hood called 'marionette'.

Now I have the following problem. Vectorworks offers a string 'node' to allow to input strings. Works great but: if I try to input text with a line break by pressing ctrl+ enter between two words the python code stops with an error message: 'EOL while scanning string literal'.

The underlying python code of the sting 'node' is as follows. Question: is there a way to modify the code in a way to accepting strings with line breaks?

The problem is: the user is making the input by entering text in a dialog that is served by the parent application (Vectorworks).

So the only way to solve the problem is to figure out how to modify the code shown below to cope with the input. The 'core' of the code is only made by two lines as it seems. Therefore it may be impossible to solve the problem?

Any help appreciated, kind regards, Um

class Params(metaclass = Marionette.OrderedClass):
#APPEARANCE
#Name
this = Marionette.Node( 'String' )
this.SetDescription('A text string defined in the OIP')  

#Input Ports

#OIP Controls
String = Marionette.OIPControl( 'string', Marionette.WidgetType.Text, '')
String.SetDescription('A text string')

#Output Ports
s = Marionette.PortOut()
s.SetDescription('The string')

#BEHAVIOR

def RunNode(self):
#inputs
s = self.Params.String.value

#script

#outputs
self.Params.s.value = s

1 Answers1

0

The EOL (end of line) error is caused by the fact that you start a string with a quote but you did not finish it (i.e. you go into a new line before closing the quote).

Let's say you want to write:

Hi
Everybody

In Python, valid string representations are:

'''
Hi
Everybody
'''

Or 'Hi\nEverybody' (\n is the newline character).

mkrieger1
  • 19,194
  • 5
  • 54
  • 65
Davide Laghi
  • 116
  • 1
  • 5
  • Thank you for the info, but this doesn't solve the problem in my case. – Um drehung Feb 06 '22 at 08:12
  • The input is made by the user in a dialog that is served by the parent application. The problem occurs when the user enters text and uses ctrl+option+Enter to generate a new line within the input. So the question is: how to modify the code shown above to cope with this entry? There is only the #inputs line to do this I guess. Is it possible in any way? – Um drehung Feb 06 '22 at 08:19