Skip to content

Instantly share code, notes, and snippets.

View satishgoda's full-sized avatar

Satish Goda satishgoda

View GitHub Profile
@satishgoda
satishgoda / SCREEN_OT_toggle_grid.py
Last active December 10, 2015 06:28
SCREEN_OT_toggle_grid.py : Blender 2.65a Python Operator : Toggles the Grid display in all 3D Views for the current screen"
# http://learningblender3dsoftware.blogspot.in/2012/12/learning-about-operators-2-screen.html
import bpy
def main(context):
screen = context.screen
for area in screen.areas:
if area.type == 'VIEW_3D':
active_space = area.spaces[0]
attrs = ['show_floor', 'show_axis_x', 'show_axis_y', 'show_axis_z']
@satishgoda
satishgoda / numSpacesPerArea.py
Last active May 21, 2023 18:21
The goal of this script is to print the number of Spaces in each area of the current screen in Blender (http://learningblender3dsoftware.blogspot.in)
# http://www.blender.org/documentation/blender_python_api_2_65_3/bpy.types.Area.html
# http://www.blender.org/documentation/blender_python_api_2_65_3/bpy.types.Space.html
import bpy
template_Area = "Area: {0}\n"
template_Space = "\tSpace: {0} {1}\n"
for area in bpy.context.screen.areas:
print(template_Area.format(area.type))
@satishgoda
satishgoda / Makefile
Last active December 10, 2015 11:19
A simple Makefile that I have written and use for my toy projects. http://www.gnu.org/software/make/ http://www.gnu.org/software/make/manual/make.html
# Name of the project
# The binary file will use the name of the project!
PROJECT := $(shell basename $(shell pwd))
# Header files
HEADERS = -I../../util/
# C++ source files
SOURCES := $(shell find ./ -name "*.cpp")
@satishgoda
satishgoda / c++11Features1.cpp
Last active December 11, 2015 15:18
A quick example program that is using some of the new features that are part of C++11. Tested and compiled with gcc 4.7.1
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
//----------------------------------------------------------------------------
using VectorOfIntPointers = vector<const int *>;
void printPointersToElements(const VectorOfIntPointers& pointers)
@satishgoda
satishgoda / git-completion.tcsh
Created January 30, 2013 07:54
Tcsh shell completions for git based on work by David Adler, David Aguilar
# Source this script in tcsh to setup shell completions
# for git. Completions are activated by typing or Control-D
# in the shell after entering a partial command.
#
# Usage:
# source git-completion.tcsh (e.g. in ~/.cshrc)
#
# Supported completions:
# Create a bezier curve object
>>> bpy.ops.curve.primitive_bezier_curve_add()
{'FINISHED'}
# Get a reference to the curve object
>>> curve_object = bpy.context.active_object
# Print out its data path
import bge
controller = bge.logic.getCurrentController()
sensor = controller.sensors['up_WKEY']
if sensor.getKeyStatus(bge.events.WKEY) == bge.logic.KX_INPUT_JUST_ACTIVATED:
owner = controller.owner
actuator = controller.actuators['upkeycount']
actuator.value = str(owner.get(actuator.propName) + 1)
controller.activate(actuator)
import bge
controller = bge.logic.getCurrentController()
owner = controller.owner
print(type(owner))
print(owner.getPropertyNames())
import bpy
from mathutils.geometry import interpolate_bezier
def get_points(spline, clean=True):
knots = spline.bezier_points
if len(knots) < 2:
return
import socket
if __name__ == "__main__":
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
sock.connect(("localhost", 9000))
data = "some data"
sock.sendall(data)
result = sock.recv(1024)
print result
sock.close()