PDA

View Full Version : Python help



mummyman
08-10-2017, 06:18 AM
Hello.. I have no clue how to use Python. Can anyone point me in the right direction to getting this code working: http://www.clintons3d.com/plugins/lightwave/sosl.html

I copied the whole page and pasted it into the Python Console... then clicked CTL-Enter to "run" it. Nothing but errors. Would love some help on this one!

Thanks
Brett

ernpchan
08-10-2017, 06:29 AM
Save it to a text file that has the file extension .py and install it like you would a plugin.

ernpchan
08-10-2017, 06:37 AM
On my website I have a script that does something similar. It's called Surface Copy if you're looking to just batch copy surfaces from one object to others.

mummyman
08-10-2017, 06:39 AM
I am... I'll check it out... thank you.

Update... I got yours to run, but once I picked the folder, it gave me a bunch of line errors.. no clue..

mummyman
08-10-2017, 06:51 AM
That's definitely what I'm looking to do

ernpchan
08-10-2017, 06:56 AM
I am... I'll check it out... thank you.

Update... I got yours to run, but once I picked the folder, it gave me a bunch of line errors.. no clue..

What are the line errors?

We're you able to get Clinton's to work?

mummyman
08-10-2017, 06:59 AM
No... Clintons did something similar in giving errors in the console. After I run yours and pick the designated folder, I get the Console window and it shows:

Traceback (most recent call last):
File "D:\Scripting\SurfaceCopy\SurfaceCopy.py", line 48, in process
File "D:\Scripting\SurfaceCopy\SurfaceCopy.py", line 59, in execute
File "C:\Program Files\NewTek\LightWave_2015.3\bin\lwsdk\pris\__ini t__.py", line 2020, in store
raise InitException('Could not determine id of current script')
lwsdk.pris.InitException: Could not determine id of current script

ernpchan
08-10-2017, 07:03 AM
OK I'll look into this. Never seen this error before and the script works on my end.

mummyman
08-10-2017, 07:09 AM
Most likely, it's on my end / user error.. lol At least I usually assume that. In my objects folder, is 1 object, then the 100 object sequences. Is there a limit to how many objects should be in the folder?

ernpchan
08-10-2017, 07:11 AM
Not to my knowledge as the idea behind the script is very basic. Do you have files other than lwos in the folder?

raymondtrace
08-10-2017, 07:18 AM
What programs are being used to copy/paste?

Could line endings be the issue? ( https://en.wikipedia.org/wiki/Newline )

I use Geany instead of Windows Notepad. It does not mangle line endings. ( https://www.geany.org/ )



EDIT: I now see that copying the python script from the browser produces different line endings than if one directly downloads (right-click, save target [or link] as...) the PY file from this page. ( http://www.clintons3d.com/plugins/lightwave/sosl.html )

Try downloading the file without copying from the browser.

mummyman
08-10-2017, 07:32 AM
Bingo.... that worked on Clinton's script for me. I didn't think to right click and "save as" Hence my stupidity. Thanks... giving it a check...

mummyman
08-10-2017, 07:42 AM
Yes... Clinton's worked.. either way... either plugin... I really appreciate the help with this!