Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9298421
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T22:19:15+00:00 2026-06-18T22:19:15+00:00

After a good deal of work, I have developed the following code in Python

  • 0

After a good deal of work, I have developed the following code in Python to plot a vector [In this case (2,2,2)] so that it points in the way you would expect from the origin.
It took me some time to gather what the three rotation parameters meant in terms of roll, pitch and yaw. You may need to set Euler XYZ.

I have used a long thin cylinder to be my vector, which suits my purpose and fits with my thin experience of blender. This code plots a vector with an Arrow on it (a cone) half way along and suits my purpose quite well but is somewhat of a bodge.
I works for most vectors but fails when x<0 and y>0 and z>0

import bpy
import math
from math import *
x=-5  
y=-10
z=12
yParameter=-1.0
if y < 0:
    if x < 0: 
        yParameter = 1.0
#print ("y para is ",yParameter
for i in range (0,1):

    length=sqrt(z*z+y*y+x*x)


#Create a vector at correct orientation at the origin
bpy.ops.mesh.primitive_cylinder_add(vertices=16, radius=0.04, depth=length, end_fill_type='NGON', view_align=False, enter_editmode=False, location=(0,0,0),rotation=(-acos(z/sqrt(x*x+y*y+z*z)),0,yParameter*acos(y/sqrt(x*x+y*y))))
bpy.ops.transform.translate(value=(x/2, y/2, z/2))

bpy.ops.mesh.primitive_cone_add(vertices=32, radius1=0.1, radius2=0, depth=0.4, end_fill_type='NGON', view_align=False, enter_editmode=False, location=(0,0,0), rotation=(-acos(z/sqrt(x*x+y*y+z*z)),0,yParameter*acos(y/sqrt(x*x+y*y))))

bpy.ops.transform.translate(value=(x/2, y/2, z/2))

I feel certain that the huge API in vectors and matrix manipulation should make this job easier but I am struggling with finding how to do it other than with this self-developed cartesian work.

Can any one point me to an understandable code snippet or maybe a tutorial on how to manipulate vectors (in the mathematical sense) within blender python

I find that the blender API is pretty clear on the names of parameters and how to code them but I can find little or nothing on what the parameters actually mean.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-18T22:19:16+00:00Added an answer on June 18, 2026 at 10:19 pm

    This will create you a cylinder with (0,0,0) as one end and (x,y,z) as the other:

    def createVectorLikeThing(x,y,z):
        v = Vector((x,y,z))
        up = Vector((0,0,1))
        if v!=-up:
            rot = up.rotation_difference(v)
        else:
            rot = Quaternion((1,0,0),pi)
        bpy.ops.mesh.primitive_cylinder_add(vertices=16, radius=0.01, depth=v.length, end_fill_type='NGON', view_align=False, enter_editmode=True)
        bpy.ops.transform.translate(value=(0,0,v.length/2))
        bpy.ops.object.editmode_toggle()
        bpy.ops.transform.rotate(value=(rot.angle,), axis=rot.axis)
    

    The code works with blender 2.63 but not with 2.65.

    For 2.65 change the last line to:

        bpy.ops.transform.rotate(value=rot.angle, axis=rot.axis)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to get the final URL after redirection in python. What's a good
Small preamble. I was good java developer on 1.4 jdk. After it I have
After deploying WCF server (svc) on my Server, I have got this message when
Hello all. After a good long Sunday google I am going to have to
Personally, I've found that when good developers deal with clients, they often get sucked
I have a C interface that looks like this (simplified): extern bool Operation(void **
After following the advice in this question successfully, I added a couple additional lines
After learning good amount of c++, i'm now into STL containers and algorithms template
After reading Getting Good With Git, I've learnt how to use Git, but not
Good morning all, After a day of googling, I’m at a loss. I decided

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.