1
$\begingroup$

This object here is supposed to a be a model of a p orbital in chemistry. I wish to cause it to elongate and widen at one end and narrow down at the other. Is there any way to do it that doesn't involve altering every vertex to get the required shape. This task will be handled by a script.

One method I thought of is a way of linking adjacent vertices for relative movement. Being a beginner at Blender, I have no clue if this is supported or not.

Thanks

Edit1 : Reason for requirement: This orbital is intended to stretch and deform like an electron cloud under the influence of an electric field. I was trying to model this behaviour using the script. For example, after each alternate frame, stretch the orbital 'x' amount to model an increasing electric field.

Any suggestions of a different approach to this is more than welcome.

orbital

$\endgroup$
  • $\begingroup$ Why do you need to do this with a script? there are ways to do this without scripting it all manually. (warp modifier) $\endgroup$ – David Dec 13 '17 at 15:27
  • 1
    $\begingroup$ @David I apologise for not mentioning it in the question, I shall update it right away. The reason is this orbital is intended to stretch and deform like an electron cloud under the influence of an electric field. I was trying to model this behaviour using the script. For example, after each alternate frame, stretch the orbital 'x' amount to model an increasing electric field. $\endgroup$ – NightHowler Dec 14 '17 at 15:53
0
$\begingroup$

It'll be something like this, assuming Icosphere at origin.
Note: you have to start in Edit mode for some reason, otherwise it throws an error.

import bpy
import bmesh

obj  = bpy.data.objects['Icosphere'] ## set name
mesh  = bpy.data.meshes['Icosphere']

bpy.ops.object.mode_set(mode = 'EDIT')
bm  = bmesh.from_edit_mesh( mesh )

minX  = 0
corners  = obj.bound_box
trans  = bpy.ops.transform

for corner in range(len(corners)):
  x = corners[corner][0]
  if x < minX:
    minX  = x

for v in range(len(bm.verts)):
  vert = bm.verts[v]
  if vert.co.x == minX:
    vert.select_set(1)
  else:
    vert.select_set(0)

trans.translate( value = (-5, 0, 0), 
                 constraint_axis = (False, False, False), 
                 constraint_orientation = 'GLOBAL', 
                 mirror = False, 
                 proportional = 'ENABLED', 
                 proportional_edit_falloff = 'SMOOTH', 
                 proportional_size = 2 )

trans.resize(value = (0.3, 0.3, 0.3), 
             constraint_axis = (False, False, False), 
             constraint_orientation = 'GLOBAL', 
             mirror = False, 
             proportional = 'ENABLED', 
             proportional_edit_falloff = 'SMOOTH', 
             proportional_size = 2 )
$\endgroup$

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.