Jump to content
twk

SyntaxError EOL while scanning literal

Recommended Posts

Yeah,

The single quote that you have in the name is going to cause you all sorts of trouble. VW uses single quotes to define string literals. Therefore it does not understand how to handle your line with three single quote marks in it.

The best option would be to change the name of the Custom Title so it does not contain quote marks.

The second and are worse option would be to somehow "escape" the single quote inside the string so it can be recognized.

My Python is not good enough to do that from memory and I don't have time to work it out right now. Hopefully this will put you on the right track.

  • Like 1

Share this post


Link to post

This has been acknowledged as a bug, but from what I can surmise, it's not an easy fix.  If memory serves me correctly, you should be able to escape the quote with a backslash -- \

The upside is you can actually add any escaped special character -- \t, \r, etc via the parameter field.

-Josh

  • Like 1

Share this post


Link to post

Thanks Josh and Pat,

So Josh, you mentioned it has been "acknowledged" as a bug and "not an easy fix"

 does this mean that :

  • the-powers-that-be at the Vectorworks Dev section know that this is a fix and it will take a long time to fix it? or
  • the Vectorworks Dev people know of this and are actively finding a fix? or
  • this is a bug that can't be fixed?

I'm wondering whether i need to tag JimW and ask him to forward this to the relevant parties. By the way, where do we submit bugs for stuff like this? or when functions don't behave the way they should? are the forums the best place? @JimW

Share this post


Link to post

A bug or not, it's never a good idea to have a parameter contain a special character.

Since you can localise a parameter, have you tried that instead ? This makes the original name of the param "PARAM" and then you localise it in anything you'd like "PARAM's"
When working (codewise) with the value you need the first one, the second one is only used when displaying to the end user in the OIP.

Share this post


Link to post

Maybe the screenshot is a bit misleading..

The actual parameter name doesn't have an apostrophe in it. Its the value of the parameter.

eg

If I want the value of this Parameter ('title_cust') to have a value of : Floor Plan 01, it works, once I include an apostrophe it breaks. And the only way to use the plugin again, is to restart vectorworks.

eg, I cant type Floor Plan 'Existing'.. it will have to be typed into the object info pallette as Floor Plan \'Existing\'

The whole plugin works well until you enter a value into this parameters field (title_cust), and that value has an apostrophe. What Josh suggested, is at the moment, the only way we can have it work. (By adding escape characters \' to include the apostrophe into the fields value)

Hope this clears things up..

 

 

Share this post


Link to post
On 13/09/2016 at 6:32 PM, Dieter @ DWorks said:

As it's VW that sets these values for you, it's a bug in VW, and you will not be able to do something about it.

Hi @Dieter @ DWorks, to where would we submit these bugs? Is there a different portal? or just on this board? I'm hesitant to post it here as its an API issue. @JimWthoughts?

Share this post


Link to post

@twkUnfortunately I do not understand pretty much anything going on in this thread. If you file them as bugs in troubleshooting however I will absolutely get with someone here who actually does understand it and get them filed properly.

Share this post


Link to post

@twk, most of the time when I encounter such bug, I just do a normal bug submit, after confirming on the scripting list that it's really a bug.

Share this post


Link to post

I think maybe some confusion here.

If you have a line of python code that you have written in the script for you plugin that looks like this

vs.Ptitle_cust = 'Ground Floor Plan ''

Then to fix the problem you need to change the code to

vs.Ptitle_cust = 'Ground Floor Plan \''

This is because your original python code finishes a string then starts a new string but doesn't finish it which is why you are getting a 'syntax error EOL while scanning string literal' because you opened a new string with your third quote mark and python has read all the way to the end of the line (EOL) looking for a forth quote mark to terminate the string and not found it. The correction adds a backslash character to escape the quote so python ignores it when looking for the end of the string. 

If the error occurs when you type the text into the object info pallet then that would definitely be a bug in vectorworks. But from looking at your error message I'm pretty sure that is code you have written that it causing the problem?

Edited by Will

Share this post


Link to post

Hi @Will, thanks for your feedback.

That snippet in the debug window :

vs.Ptitle_cust = 'Ground Floor Plan ''

Was NOT written by me. When setting up parameters for a plugin in the VW Plugin Editor, whatever parameter name you specify, in the background, VW will store it as variable with an extra 'P' in front of it. 

example:

- I set a parameter name in the Plugin Editor as 'title_cust' with a default value of 'hello'.

- In the background VW stores whatever value that's assigned to this parameter in a variable called vs.Ptitle_cust = 'hello'

This is further discussed by others here :

https://forum.vectorworks.net/index.php?/topic/42954-python-newbie-retrieving-parameters-from-oip/

 

 

 

Share this post


Link to post

So.. further to this threads discussion, I had an idea for this problem from another thread (

https://forum.vectorworks.net/index.php?/topic/45875-evaluating-if-a-variable-has-changed/

 

The idea was to add a custom widget to the plugin using :

 

result = vs.vsoAddWidget(widgetID, widgetType, locName)

WidgetTypes:

	kFieldLongInt     = ;
	kFieldBoolean     = ;
	kFieldReal        = ;
	kFieldText        = ;
	kFieldCalculation = ;
	kFieldHandle      = ;
	kFieldCoordDisp   = ; 
	kFieldPopUp       = ;
	kFieldRadio       = ;
	kFieldCoordLocX   = ;	
	kFieldCoordLocY   = ;

	kWidgetButton     = ;
	kWidgetStaticText = ;
	kWidgetDisclosure = ; 

 

..and using the widgetType = 4 (Text)

 

The problem is, as @JBenghiathas mentioned, is that there is no way to get values from these added/inserted widgets. Does anyone know then, what these Widgets are used for then?

( @Pat Stanford, @orso b. schmid, @Dieter @ DWorks, @Hippocode, @GioPet, @MarissaF), sorry just tagging people who've helped me in the past :):) . Tagging you Marrisa because this happens in Marionette as well, with Text Parameters for Marionette Objects.

 

Cheers

 

Share this post


Link to post

Buttons, dividers, and static text are the only useful standalone widgets in VS. Any other widgets must be linked to a parameter. 

 

There's really no workaround for your issue from a coding standpoint, as Vectorworks isn't escaping the parameter field values. Your only option is to have the user escape special characters with a backslash. 

 

 

You can submit bugs bugs directly with this online form:

 

http://www.vectorworks.net/support/bugsubmit

  • Like 1

Share this post


Link to post

Thanks @JBenghiat.. will submit bug and hopefully get this sorted out.

 

One of the final steps to releasing some plugins for beta testing ;)

Share this post


Link to post

As a workaround could you add a button which opens a custom dialog and have fields there which allow you to enter the information. I Just tried this and it works fine.

Share this post


Link to post
14 minutes ago, Will said:

As a workaround could you add a button which opens a custom dialog and have fields there which allow you to enter the information. I Just tried this and it works fine.

 

Yes will, that is the current (undersired) work-around.

 

Cheers

Share this post


Link to post

Interesting thing, this has started to work with Vectorworks 2017 SP4

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×