Hi folks, I am new to this forum, and to Python, but Blender and me have been friends for a while now.
Is it possible to create a new mesh in a Python script using the tools which are available in the GUI of Blender? A simple example would be creating a sphere. In Blender we just press ‘Space’, then specify the following:
Add > Mesh > UVSphere
Segments: 32
Rings: 32
and presto! we have a sphere. I would like to be able to make an equivalent call in Python, something of the form:
(Excuse my pseudo-py!). From what I’ve examined of the Blender Python API, it seems as though I have to specify the position of each vertex individually, then create lines and faces too. I’m ashamed to say, my maths just isn’t up to it! Any help would be appreciated.
Construct a UV sphere mesh. The defaults create a 32 by 32 sphere with a diameter of 2*sqrt(2) Blender units, identical to the Blender UI.
Parameters:segments - optional number of longitudinal divisions. Value must be in the range [3,100].
(type=int) rings - optional number of latitudinal divisions. Value must be in the range [3,100].
(type=int) diameter - optional diameter of the sphere.
(type=float) Returns: returns a mesh object.
Thanks for steering me in the right direction with this one. I only just got round to trying out your advice.
For the record, the following line lead to the following error:
me = Mesh.MeshPrimitives.UVsphere(10,10,2)
AttributeError: ‘module’ object has no attribute ‘MeshPrimitives’