added what needed to link a curve to an object (modification of Object_link
authorJacques Guignot <guignot@wanadoo.fr>
Wed, 9 Jul 2003 12:25:27 +0000 (12:25 +0000)
committerJacques Guignot <guignot@wanadoo.fr>
Wed, 9 Jul 2003 12:25:27 +0000 (12:25 +0000)
added 2 functions Curve_CheckPyObject and Curve_FromPyObject
that I had forgotten

source/blender/python/api2_2x/Curve.c
source/blender/python/api2_2x/Object.c

index 38ae90746fece65ecd557343c30afe84accfb4b2..5c4d671e8af593b219268ba6c34937d3562564b1 100644 (file)
@@ -143,6 +143,14 @@ PyObject *Curve_Init (void)
   return (submodule);
 }
 
+int Curve_CheckPyObject (PyObject *pyobj)
+{
+  return (pyobj->ob_type == &Curve_Type);
+}
+Curve *Curve_FromPyObject (PyObject *pyobj)
+{
+  return ((BPy_Curve *)pyobj)->curve;
+}
 /*****************************************************************************/
 /* Python BPy_Curve methods:                                                   */
 /* gives access to                                                           */
index ec5fd12b770624c7b2e3b70ca9c2535e376f1b83..718bed0a2dd5b1119c4cc33487d77b03a32b7647 100644 (file)
@@ -828,6 +828,8 @@ static PyObject *Object_link (BPy_Object *self, PyObject *args)
         data = (void *)Camera_FromPyObject (py_data);
     if (Lamp_CheckPyObject (py_data))
         data = (void *)Lamp_FromPyObject (py_data);
+    if (Curve_CheckPyObject (py_data))
+        data = (void *)Curve_FromPyObject (py_data);
     /* TODO: add the (N)Mesh check and from functions here when finished. */
 
     oldid = (ID*) self->object->data;
@@ -857,6 +859,13 @@ static PyObject *Object_link (BPy_Object *self, PyObject *args)
                     "The 'link' object is incompatible with the base object"));
             }
             break;
+        case ID_CU:
+            if (self->object->type != OB_CURVE)
+            {
+                return (PythonReturnErrorObject (PyExc_AttributeError,
+                    "The 'link' object is incompatible with the base object"));
+            }
+            break;
         default:
             return (PythonReturnErrorObject (PyExc_AttributeError,
                 "Linking this object type is not supported"));