2
$\begingroup$

I have a straight curve that's hooked with hooks at both ends to two objects. I'm creating the curve in python and applying the following to make it look like a cylinder in a python Bond-class (for a chemical bond between two atoms):

obj.data.dimensions = '3D'
obj.data.fill_mode = 'FULL'
obj.data.bevel_depth = self.bevel_depth
obj.data.bevel_resolution = self.bevel_resolution

This works fine. Now I would need to be able make these into two or three "cylinders" to represent double and triple bonds as needed. These should stretch lengthwise as the atoms move closer or further apart, but they should stay otherwise unmodified. Any ideas how to do this as simply as possible in python?

Could I use a bevel object on the curve, say a curve-object consisting of two circles? If yes, how do you control which point on the bevel object follows the curve?

$\endgroup$
0
$\begingroup$

You can totally duplicate your circle in Edit Mode on the Bevel Object. The origin of the Bevel Object is the point which follows the curve. you can Tilt the curve with CTRL + T to control its rotation.

Multiple curves in Curve Data

$\endgroup$
  • $\begingroup$ Great! Thanks! How would I do that in python? I assume I can create three bevel objects: a circle, two circles and three circles. Then I can reuse these for all the bonds. Where do I put the circles as obviously I don't want them to appear in the animation? $\endgroup$ – Melodius Jun 30 '14 at 11:35
  • $\begingroup$ You'd have to create a Bezier Circle object with bpy.ops.curve.primitive_bezier_circle_add() then duplicate it and move the duplicate in Edit Mode. Then you can bind the two curve objects using eg. obj.data.bevel_object = bpy.data.objects['BezierCircle'] The Bevel Object is not rendered since it is not a surface but only a curve, so it's okay to leave it whereever you find it convenient. $\endgroup$ – Pisurquatre Jun 30 '14 at 12:33
  • $\begingroup$ Why am I getting a: "AttributeError: 'Curve' object has no attribute 'data'", when trying to "curve.data.bevel_object = bpy.data.objects["TripleBond"]" (I've saved the reference to the curve object when creating it). $\endgroup$ – Melodius Jun 30 '14 at 13:10
  • $\begingroup$ I think the "curve" variable is already the data for your object, so you need to either write "curve.bevel_object" or "obj.data.bevel_object". But then again, I didn't see your whole script, so it's a bit hard to guess. $\endgroup$ – Pisurquatre Jun 30 '14 at 15:14
  • $\begingroup$ "curve.bevel_object" was correct. $\endgroup$ – Melodius Jul 1 '14 at 16:02

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.