twk Posted September 6, 2016 Share Posted September 6, 2016 Greetings Pythonistas, Getting "SyntaxError EOL while scanning literal" script error, when there is an apostrophe in one of the parameter fields of my custom plugin object. I am trying to figure out how to catch/handle this exception before it gets processed. Any thoughts @Dieter @ DWorks, @JBenghiat@Hippocode.. trying to think of others.. @Miguel Barrera@Pat Stanford@Matt Panzer.. Quote Link to comment
Pat Stanford Posted September 7, 2016 Share Posted September 7, 2016 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. 1 Quote Link to comment
JBenghiat Posted September 7, 2016 Share Posted September 7, 2016 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 1 Quote Link to comment
twk Posted September 7, 2016 Author Share Posted September 7, 2016 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 Quote Link to comment
Hippocode Posted September 7, 2016 Share Posted September 7, 2016 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. Quote Link to comment
twk Posted September 7, 2016 Author Share Posted September 7, 2016 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.. Quote Link to comment
Dieter @ DWorks Posted September 13, 2016 Share Posted September 13, 2016 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. Quote Link to comment
twk Posted September 15, 2016 Author Share Posted September 15, 2016 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? Quote Link to comment
Vectorworks, Inc Employee PVA - Admin Posted September 15, 2016 Vectorworks, Inc Employee Share Posted September 15, 2016 @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. Quote Link to comment
Dieter @ DWorks Posted September 16, 2016 Share Posted September 16, 2016 @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. Quote Link to comment
Will Posted September 21, 2016 Share Posted September 21, 2016 (edited) 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 September 21, 2016 by Will Quote Link to comment
twk Posted September 21, 2016 Author Share Posted September 21, 2016 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/ Quote Link to comment
twk Posted October 20, 2016 Author Share Posted October 20, 2016 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 Quote Link to comment
Hippocode Posted October 21, 2016 Share Posted October 21, 2016 I never used these in VS. Maybe it's not exposed to VS and only available in the SDK. Quote Link to comment
JBenghiat Posted October 22, 2016 Share Posted October 22, 2016 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 1 Quote Link to comment
twk Posted October 27, 2016 Author Share Posted October 27, 2016 Thanks @JBenghiat.. will submit bug and hopefully get this sorted out. One of the final steps to releasing some plugins for beta testing Quote Link to comment
Will Posted October 28, 2016 Share Posted October 28, 2016 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. Quote Link to comment
twk Posted October 28, 2016 Author Share Posted October 28, 2016 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 Quote Link to comment
twk Posted October 26, 2017 Author Share Posted October 26, 2017 Interesting thing, this has started to work with Vectorworks 2017 SP4 Quote Link to comment
hlipperjohn Posted December 31, 2019 Share Posted December 31, 2019 An EOL ( End of Line ) error indicates that the Python interpreter expected a particular character or set of characters to have occurred in a specific line of code, but that those characters were not found before the end of the line . This results in Python stopping the program execution and throwing a syntax error . The SyntaxError: EOL while scanning string literal error in python occurs when while scanning a string of a program the python hit the end of the line due to the following reasons: Missing quotes Strings spanning multiple lines Strings can't normally span multiple lines. If you don't want the string to appear on multiple lines but you want to initialize it on multiple lines (so you can read it more easily), you can "escape" the newline by putting a backslash before the newline. If you want it to appear on multiple lines, you can use triple quotes around the string. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.