PDA

View Full Version : convert raw code to a plugin?



djwaterman
10-15-2014, 05:19 AM
I was looking around on the Blender forums and found this http://blenderartists.org/forum/showthread.php?229346-AddOn-Duplicate-Multiple-Linked

But I don't know how you take that code and save it so that it becomes a plugin (addon), am I supposed to paste it into a word doc or something? This stuff mystifies me. Any help?

djwaterman
10-15-2014, 08:07 AM
It's not a Blender question, just a general what do you paste these strings of code into and what do you you save them as. Looks like you paste them into a text file, I used note pad, and save as the name of the script with the script extension, in this case .py. Also have to set the encoding to a specified type, in this case UTF-8. It didn't work for me though, doesn't matter.

BigHache
10-15-2014, 09:41 AM
It depends on the host application and the scripting language, as a short answer.

In terms of LW and Python, the text file needs to have specific calls for LW to recognize it as a plug-in, otherwise it will return an error and not load.

I looked at the Blender thread and the author posted an update almost a year later because the host application changed. It's entirely possible that two years later Blender has changed enough for this script to not work again.

ernpchan
10-15-2014, 10:20 AM
Also python is very specific in how the code has to be formatted. Instead of open and closing braces it uses indents. So if your indents are off the code will fail.

bazsa73
10-15-2014, 12:28 PM
It's not a Blender question, just a general what do you paste these strings of code into and what do you you save them as. Looks like you paste them into a text file, I used note pad, and save as the name of the script with the script extension, in this case .py. Also have to set the encoding to a specified type, in this case UTF-8. It didn't work for me though, doesn't matter.

There are some examples in your Lightwave install folder under support
YourLightwaveInstall\support\plugins\scripts\Pytho n
check in Layout\Generic "addnull.py" for example

ncr100
10-15-2014, 12:33 PM
@djwaterman - https://en.wikipedia.org/wiki/Cross-platform#Challenges_to_cross-platform_development summarizes the problems with taking code that works on one 'platform' (Blender) and having it work on another (LW).

Don't get me wrong, cross-platform is one of The Big Dreams of programmers - it's just a really hard problem to solve.

Sensei
10-15-2014, 12:53 PM
am I supposed to paste it into a word doc or something? This stuff mystifies me. Any help?

No doc! No Word! Or any other text processor.
You need text editor, not text processor.
The best one is ConTEXT.
http://www.contexteditor.org
It's programmer's text editor.
It's highlighting syntax of language (determined from extension of file).
It allows configuring compilers to keys.

spherical
10-15-2014, 06:00 PM
I prefer Notepad++ (http://notepad-plus-plus.org/). Lean, low resource use, per-language syntax highlighting, flexible S/R with regex, highlights open/close HTML tags and (), {}, [], collapes sections. Loads of plugins to add functionality to its already robust capabilities as a programmer's editor.

ncr100
10-16-2014, 01:22 PM
One editor to bind them! Sublime Text! (http://www.sublimetext.com/)