[Addon] SublimeBlender - Execute scripts from Sublime Text 3

As for the issue between st2 and st3, I’m sure it is the python versions. The error is in the url “request” module.
As far as autocomplete goes, the best I found was scraping the api web site here, but it didn’t seem like the best way to go about it:
http://www.blender.org/documentation/blender_python_api_2_69_release/genindex.html

As for the current plugin, so I’m getting it to work for basic things. But I just created a quick panel for the toolbar and I can seem to get the script to run in blender. If I run it in blenders text editor it works (this just creates a simple button and panel in the toolbar), but if I run it via sublime it doesn’t.

Here’s what I have right now that’s causing the problem.

import bpy

class addLightViewPanel(bpy.types.Panel):
    bl_label = "LightView"
    bl_space_type = 'VIEW_3D'
    bl_region_type = 'TOOLS'
    bl_context = 'objectmode'


    def draw(self, context):
        layout = self.layout
        row = self.layout.row()
        row.label(text="LightView")
        row.operator("object.lightview", text="Run!", icon="PLAY")


# Create Operator
class OBJECT_OT_makelight(bpy.types.Operator):
    bl_idname = "object.lightview"
    bl_label = "LightView"
    bl_description = "Create Light from current view"
    bl_options = {'REGISTER', 'UNDO'}
    
    def execute(self, context):
        scn = bpy.context.screen.scene
        scn.camera = coordcam
        viewcoords = coordcam.location
        print(coordcam)


obj = bpy.context.active_object
print(obj)
### Define Classes to register
classes = [addLightViewPanel, OBJECT_OT_makelight]


def register():
    for c in classes:
        bpy.utils.register_class(c)
    # bpy.types.WindowManager.curve_tracer = bpy.props.PointerProperty(type=TracerProperties)
def unregister():
    for c in classes:
        bpy.utils.unregister_class(c)
    # del bpy.types.WindowManager.curve_tracer
if __name__ == "__main__":
    register()

New features for Sublime Blender !

  • full auto-completion for the bpy module.
  • Auto save file when executing the script from Sublime.

Current Issues:
I am still looking into the correct way of executing the script in Blender, cause it is still doing crazy things.
example : execute ‘bpy.ops.mesh.primitive_cube_add()’ : will create a cube but after that it jumps into edit mode. The problem is probably because the code runs in a different thread. I am still looking in to it. But if someone for different alternatives.

@crazycourier
You can see in my source code how to implement auto-completion in Sublime. I was able to plug the system in the default auto-completion system of Sublime. Really easy to do but it is not in the online documentation.
I still have to test your ui code that you gave but it is probably connected to the same problem given above.

@@crazycourier your code works fine if you comment bellow two lines

obj = bpy.context.active_object
print(obj)

Reason may be blender python dosenot allow may be because to prevent crash acceing it even after delete

@Svennovich for Sublime 3

But here everything works except auto complete, it dose work slow some time more oten it dosenot. But code runs smooth and connection works cool.

Help me if its working for you. It will just moke it lot more faster to blender scripting.

Yeah, it works for me as well, except autocomplete.

I try to test it on Lubuntu 12.10… but dosen’t work

Addon in Blender, seems to work ok showing in the blender console:

Info: SublimeBlender Connection is open.

but sublime3 dosen’t do anything, not showing any errors on console…
my sublime package is under packages, and the name of the path is “Blender Development”, i can reach settings and keymap files, but shortcut don’t do anything (crtl + E, or alt + P), with command palette (crtl + shft + P) dosen’t work, too…

Cool! But, can you make an autocomplete function for the Blender text editor?Im not good enough to make it, but your code suggests that you are on a pretty high level.It could be blessing for everyone, as, I suppose, I am not the only one who usees Blneder’s text editor much more than external editors! It would be awesome!

thanks so much for this, very handy! :slight_smile:

I just started coding for Blender and this is so helpful, thank a lot for this, works great.

This is superb! I use SublimeText 3 all of the time and now it will be much more enjoyable.

You totally filled a need. This is super great.:smiley:

I’m glad I stopped by this forum! I just started using Sublime and I really like it, this will be a great addition to my toolbox!

Smart idea for an add-on! Thanks :slight_smile:

Anyone have this working with Sublime?

I know this is hella necro posting, but I found this thread in my own searching and figured I would chime in since I had some trouble getting it to work. Following the setup instructions on github, if you’re on windows, it’s likely not going to work right out of the box because the hotkey used to send the script to blender (alt+p) doesn’t work… it’ll just open the Project menu. You need to set or override a different hotkey in sublime’s keymap files. So, as an example- my Default.sublime-keymap (user) looks like:

[
	{ 
        "keys": ["ctrl+e"], "command": "sublime_blender_execute",
    }
]

Additionally, autocomplete and linting doesn’t work out of the box either- you’ll need to download Python and add it to your PATH environment variable, and install the Anaconda package for sublime text (if you have package control enabled in sublime, just “install package” and “anaconda”).

Hope that helps some other future person who ran into the same speedbumps I hit!

1 Like

hi there, I just stumbled upon this after I bought sublime 3. any plans on updating this to blender 2.80 ?
I am trying myself, but since I am too new to python and blender, I can’t get it to work.
I am trying to follow this conversion tutorial https://www.youtube.com/watch?v=Mjy-zGG3Wk4.
I got it to show up in the addon manager but the command or the panel is not appearing in blender.

thanks

1 Like

I think it’s in the blender institute plan to support sublime, I heard it in last stream with Pablo

1 Like

Bumpity bump bump…

1 Like

Is there a way to reload the addon script to blender witouth removing and reinstalling the addon everytime ?

Bumpy bump

1 Like