enter image description here I am creating a for loop to connect pairs of objects by a Splines To understand better image atoms in a molecule. It seems that every time I create a new spline is in someway taking in consideration some parameter of the spline before amplifying the result.

How can i stop it (I tried several things, also moving cursor thinking was some hidden dependence from the universe origin but it is not) also if I convert the curve to mesh every time... still propagating the error.

                   #Manca assegnazione nome a oggetti 
                   for index, row in df_BND.iterrows(): 
                       print('START - CREATE_BOUNDS_1')                       
                       bound_name = 'BOUND_'+str(int(row['BONDS_1']))+'_' +str(int(row['BONDS_2']))
                       BNDS_EXTR = [float(row['A1_CD_X'])+PLUS_FACTOR,float(row['A1_CD_Y']), float(row['A1_CD_Z']),float(0.0),float(row['A2_CD_X'])+PLUS_FACTOR,float(row['A2_CD_Y']), float(row['A2_CD_Z']),float(0.0) ]
                       bpy.context.scene.cursor.location = (BNDS_EXTR[0],BNDS_EXTR[1],BNDS_EXTR[2]) #muve cursor
                       obj = bpy.context.object
                       obj.data.dimensions  = '3D'
                       obj.data.fill_mode   = 'FULL'
                       obj.data.bevel_depth = 0.1
                       obj.data.bevel_resolution = 0
                       # set first point to centre of sphere1
                       bpy.context.scene.cursor_location = (0.0, 0.0, 0.0)
                       obj.data.splines[0].bezier_points[0].select_left_handle = True
                       obj.data.splines[0].bezier_points[0].co = (BNDS_EXTR[0],BNDS_EXTR[1],BNDS_EXTR[2])
                       obj.data.splines[0].bezier_points[0].handle_left_type = 'VECTOR'
                       # set second point to centre of sphere2
                       obj.data.splines[0].bezier_points[1].select_right_handle = True
                       obj.data.splines[0].bezier_points[1].co = (BNDS_EXTR[4],BNDS_EXTR[5],BNDS_EXTR[6])                           
                       obj.data.splines[0].bezier_points[1].handle_left_type = 'VECTOR'
                       #obj.data.splines[0].bezier_points[1].handle_right_type = 'VECTOR'
                       obj = bpy.context.selected_objects[-1]
                       obj.name = bound_name 
                       CURRENT = bpy.data.objects.get(bound_name)
                       bpy.ops.object.convert(target='MESH', keep_original= False)
                   return ('DONE')
  • 1
    $\begingroup$ Recommend posting an example of usage. $\endgroup$ – batFINGER Oct 27 at 17:23
  • $\begingroup$ To give some more detail or example giving a sub-example I woud like to connect this 2 points: poit1 = [101.6645, -2.0291, -0.2209] point2={ 101.1637, -2.9724, -0.3932] (they are part of the dataframe I sue in the function . the problem is thatI would like that the cure I am creating is not only passing by this 2 points ,but also starting and ending from them ....but in the loop , more splines I am creating , more the length grow withount control $\endgroup$ – Evander 3 Oct 27 at 19:53

I FOUND THE SOLUTION!!! I resume the problem to be sure to be helpful:

you have a dataframe or 2 list of points , and you need to connect pairs of points. the faster way is to create splines between them but .... ..in my case blender was generating the connection in different position than expected and unexpected lengths ... but not really randomly .

The problem was bpy.context.scene.cursor.location that was not in the center of the world origin

The solution is to reset at every loop the position of the cursor in the center of the world origin.

| improve this answer | |

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.