How to draw custom faces/lines/points in 3D space with python?

Like this addon.

I need just a simple example of how to draw these elements.

  • $\begingroup$ Take a look at the Github page: github.com/CGCookie/retopology-contours/blob/master/… $\endgroup$ Dec 6, 2014 at 17:59
  • $\begingroup$ Possibly off topic because involves external addon? $\endgroup$
    – Scalia
    Dec 6, 2014 at 18:17
  • 2
    $\begingroup$ @VinceScalia I think the OP mentioned the addon as an example of functionality, not because they were asking how to use it. IMO it's a perfectly good question. $\endgroup$
    – gandalf3
    Dec 6, 2014 at 18:26
  • $\begingroup$ Okay then. Just wondering. $\endgroup$
    – Scalia
    Dec 6, 2014 at 18:29

1 Answer 1


Blender provides opengl access through python with the bgl module which allows you to use opengl calls to draw to screen. Any opengl reference should help.

An example from the contours addon - countour_utilities.py

def draw_outline_or_region(mode, points, color):
        mode - either bgl.GL_POLYGON or bgl.GL_LINE_LOOP
        color - will need to be set beforehand using theme colors. eg
        bgl.glColor4f(self.ri, self.gi, self.bi, self.ai)

        if mode == 'GL_LINE_LOOP':

        # start with corner right-bottom
        for i in range(0,len(points)):


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.