Code Monkey home page Code Monkey logo

3dpart-blender-python's Introduction

3dpart-blender-python

Learning to create 3d parts with blender using Python

Source

https://www.youtube.com/watch?v=gVUvnSJ-t3M

Tips

Main steps to use Python

Documentations of functions:

https://docs.blender.org/api/2.81/bpy.ops.mesh.html

Use text editor to add main code

import bpy

Select and Remove objects

bpy.ops.object.select_all(action='SELECT') bpy.ops.object.delete(use_global=False)

Add objects

bpy.ops.mesh.primitive_monkey_add(location=(0,0,0))

Find and copy code to the script

  • Set up the 'info' tab in the right window
  • Make actions by hand
  • Note the change of code and copy that

Apply smooth operations to the objects

bpy.ops.object.shade_smooth()

For loops in Python

`from random import randint number = 600 for i in range(0,number): x = randint(-20,20) y = randint(-20,20) z = randint(-20,20) bpy.ops.mesh.primitive_monkey_add(location=(x,y,z))

`

Create 3D parts

Functions help:

https://docs.blender.org/api/2.81/bpy.ops.mesh.html

Add cylinder

bpy.ops.mesh.primitive_cylinder_add(radius=0.0105, depth = 0.022, enter_editmode=False, location=(0,0,0.045))

Adds cube with custom size

bpy.ops.mesh.primitive_cube_add(size = 0.012, enter_editmode=True, location=(0, 0, 0.055))

How to rotate things

  1. add radians function

from math import radians

  1. Rotate using radians(90)

bpy.ops.mesh.primitive_cylinder_add(radius=0.0025, depth = 0.022, enter_editmode=False, location=(0,0,0.015), #align='VIEW', rotation=(0,radians(90),0))

How to position parts on Z axis

Example1.

Adding cylinder on top of another cylinder:

  • location Z =

-- sums of depth of previous cylinder -- plus 1/2 of the depth of the new cylinder

How to apply parts transformations within the code

3dpart-blender-python's People

Contributors

vladdsm avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.