Jump to content

How does vs.Message work?


relume

Recommended Posts

Hello

 

I would like to use the vs command vs.Message in pyhton like I used it in vectorscript. But it seems that vs.Message does not work as expected. As far I can see the Message window is only opened at the end of the called python script. Is there any possibility to make vs.Message to work as it should  - the window is opened at the first call to vs.Message and updated on every futher vs.Message call. Otherwise the command is useless.

 

Many thanks in advance and best regards

 

 

Link to comment

Hi

I agree, I also wish we had some kind of report Window or Message Window. Which can show more than a few characters and which could add the messages. This would be grate.

 

"Useless" is a hard word :-) vs.Message shows the last Message Window called in a Script. This could make quite sense but makes it useless to report several happenings during runtime of the script (See, how values change etc. -> this also just would work if we slow-down script). I Think you are searching for a "debug" function, which do not exists at the moment for python scripts inside the script editor. 

 

Maybe "vs.AlrtDialog()", could be an alternative to show messages. I use this, if I have only a few values I want to debug.

Also we can switch on the Program Option "run script in debug modus" and use the print() command. I  often use this, to check values in a loop. Where vs.AlrtDialog() would open endless dialogs.

 

Example:

for i in range(10):
    print(str(i)+' Line4 '+str(i+i))
    print(str(i)+' Line5 '+str(i*i))
    print(str(i)+' Line6 '+str(i**i))

Besides that ... cool, we have colored python code now in the forum!

This code returns values in an "Error-Window"

58a21bd78fd28_Bildschirmfoto2017-02-13um21_49_10.png.c115c3410d0ced3d1d76ecc0c00a49c6.png

 

Edited by DomC
  • Like 1
Link to comment

I submitted an enhancement request to have the Message command work during the execution of a script and it came back (for the first time ever) marked as actually being a bug. I expect this to be fixed eventually, but maybe not for VW2017.

 

AlrtDialog(Concat(     ));

 

Is the best work around for right now. Hopefully you don't have too many needs for it in the script as you have to hit return or click OK on each execution.

Link to comment

Message() in VectorScript, and vs.Message() in Python are equally broken now. In both environments Message() only reports the last message issued, and only after the script ends. This has been reported several times. No idea if or when we will see a return to previous behavior. Fingers crossed, we will.

 

Pat's suggested workaround is good for a few iterations, but it won't work well with loops that might iterate 100 times or more. The old Message() behavior in VS would, and I've used it to monitor scripts that iterate more than 1,000,000 times. I'd love to have that back again.

 

Raymond

Link to comment
  • 8 months later...
What you really want is a log file, You just put this in your code:
log_file = open(vs.GetFolderPath(-2) + 'log.txt', 'a')
log_file.write('Whatever you want to log')
log_file.close()

This wil create a log.txt on a relative place in the user folder.

You can open this with a program as baretail: https://www.baremetalsoft.com/baretail/  the free version will do fine.

You can delete the file without having to reopen it.

 

Link to comment

Hello Nebeor

 

Thank you for your suggestion. The log-file approach is some kind of a workaround, but is not the intended function, that a GUI should provide. In VectorWorks-script "Message" worked perfectly, but in python it does not work, during a script-execution. So there is no "visual" feedback to the user, in order to get an idea, what is happening.

 

best regards

 

P.S. hopping vs.Message will work in VW 2018

Link to comment

Message in Vectorscript and therefore vs.Message in Pythonscript is broken. It only displays at the end of the script.

 

It appears to still be broken in VW2018.

 

The best workaround I have come up with for debugging is AlrtDialog, but this requires operator attention to close the dialog and proceed with the script.

 

No other good solutions other than the logging suggested by Nebeor.

 

A bug has been filed, but there is no update on when it will be fixed. Probably not for VW2018.

Link to comment

Agree ...

 

In 2018 the Message Window shows much more characters. As much, the Window size allows (look screenshot). I think that's a great improvement. Amd cause we use python we have so much more possibilities. One good Idea is the logfile. And this logfile could be opened at the end of the script to have a good comfort.

import subprocess
    subprocess.call(['open', '-a', 'TextEdit', thepathtologfile])

 

That will open an application (TextEdit as example) after the script. That's very comfortable. Also It allows to copy/paste Values, which seems not possible by vs.Message()

 

59ef90f1e69b1_MessageWindow2018.png.b5fb2130741b3a0999a16f7680a4ed30.png

 

Link to comment
18 hours ago, DomC said:

Also It allows to copy/paste Values, which seems not possible by vs.Message()

 

Dom,

   Actually, you can copy text from the Message window, but you have to use the COPY command in the contextual menu. Select the text in the MESSAGE window, Right Click, Copy ... Paste elsewhere (any way you like.) I assume it works on Windows as it does on the Mac, but I have no idea why CMD-C doesn't work in the Message window. I just checked back to VW 2013 and it works at least back that far.

 

HTH,

Raymond

  • Like 1
Link to comment

Hello

Many thanks for the diverse inputs.

 

If I understand Dom's input correctly about the vs.Message window in VW2018, the window appearance has improved, but still it will show only at the end of the script?

 

As Dom mentioned the use of a subprocess for logging to a file (more precisely to open it on MacOS in TextEdit), I had today a look at python and tkinter to implement a message window that "lives" in its own process. At the moment I have no working solution, but it seems to be feasible to communicate from the VW2018 python environment over sockets/pipes to a tkinter window's mainloop.

 

best regards

 

Link to comment

If you are on Mac, you might want to look at viewing the file using the Console app found in the Applications:Utilities folder. This is specifically designed to work with log files and I think automatically handles new data being appended to a file you are viewing. I am not certain that TextEdit likes to have the file changed by another process while it has it open.

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...