Closed kdsin23 closed 4 years ago
I think, there is no type for Object in data_structures
for cimport
. Can you elaborate on why do you need Object type in .pyx
?
I think, there is no type for Object in
data_structures
forcimport
. Can you elaborate on why do you need Object type in.pyx
?
Thank you for your reply! for example, i want to get patilces from ParticleSystem,I maybe write a python file like this:
import bpy
from ... base_types import AnimationNode
from ... utils.depsgraph import getEvaluatedID
class ExtractParticlesNode(bpy.types.Node, AnimationNode):
bl_idname = "an_ExtractParticlesNode"
bl_label = "Extract Particles"
def create(self):
self.newInput("Object", "Object", "object")
self.newOutput("Generic", "Particles", "particles")
def execute(self, object):
if object is None:
return
ParticleList = []
for p in getEvaluatedID(object).active.particles:
ParticleList.append(p)
return ParticleList
but the speed is very slow when performace,so i tried to wirite the function "ExtractParticles()" to the cython file like this:
def ExtractParticles(Object object):
cdef Py_ssize_t i
cdef Py_ssize_t count = len(getEvaluatedID(object).particle_systems.active.particles)
cdef ParticleList = list(length = count)
for i in range(count):
ParticleList.append(getEvaluatedID(object).particle_systems.active.particles[i])
return ParticleList
it gave me an error: c_utils.pyx:58:21: 'Object' is not a type identifier,
my question is how to import "object" data_structures,or to create a "Object" data in .pyx
,thank you very much!
There is no object
data type in data_structures
. However, your code will run even if you do not define the object type. Here is code of the Particle System from Object node:
https://github.com/3DSinghVFX/animation_nodes/blob/0ed95e2c842681c81395f7477bb95f20900388fe/animation_nodes/nodes/particles/particle_systems_from_object.py#L15-L19
There is no
object
data type indata_structures
. However, your code will run even if you do not define the object type. Here is code of the Particle System from Object node:
Thank you for your explanation ! but this code can not be put into the .pyx
file ,right?
You can put the code in .pyx
if you want. However, to get the benefits of the Cython
we have to specify the types.
You can put the code in
.pyx
if you want. However, to get the benefits of theCython
we have to specify the types.
Thank you very much!
Is it resolved?
Is it resolved?
yes,it is. thank you
You're welcome.
hi, i learn to write a cython code file in animation nodes,but i am trouble with cython,yesterday,i tried the way OmarEmaraDev provided,still doesn't work. for example, i want to import "object" to cython, so I add :
from ...data_structrues cimport Object
def getfunction(Object object):
....
when Cythonizing the .pyx file, it appering an error: 'Object' is not a type identifier,i don't know why, i need some help,Thank you very much!