tag:blogger.com,1999:blog-2986679130504525123.post3956101947826489773..comments2024-03-28T19:22:02.956+01:00Comments on Small Blender Things: Copying vertices to Numpy arrays in BlenderMichelhttp://www.blogger.com/profile/07415131908018321030noreply@blogger.comBlogger6125tag:blogger.com,1999:blog-2986679130504525123.post-58668110497845837862021-07-26T13:04:10.853+02:002021-07-26T13:04:10.853+02:00detail: you could use verts.ravel() (to flatten) i...detail: you could use verts.ravel() (to flatten) in the last foreach and not do verts.shape beforeAnonymoushttps://www.blogger.com/profile/14597534378226202988noreply@blogger.comtag:blogger.com,1999:blog-2986679130504525123.post-75366716425003250262017-02-19T20:58:52.140+01:002017-02-19T20:58:52.140+01:00But you can assign an array of floats to the pixel...But you can assign an array of floats to the pixels attribute, see http://blender.stackexchange.com/questions/643/is-it-possible-to-create-image-data-and-save-to-a-file-from-a-script<br /><br />You might try if this could be a numpy array as wellMichelhttps://www.blogger.com/profile/07415131908018321030noreply@blogger.comtag:blogger.com,1999:blog-2986679130504525123.post-91986372874187734012017-02-19T20:55:08.479+01:002017-02-19T20:55:08.479+01:00I don't think so: the image attribute is not a...I don't think so: the image attribute is not a bpy_prop_collection so doesn't have a foreach_get <br /><br />Michelhttps://www.blogger.com/profile/07415131908018321030noreply@blogger.comtag:blogger.com,1999:blog-2986679130504525123.post-68857066385842563752017-02-19T19:53:25.968+01:002017-02-19T19:53:25.968+01:00Can we use the foreach_set and foreach_get in imag...Can we use the foreach_set and foreach_get in images? I mean reading and writing pixel info.Anonymoushttps://www.blogger.com/profile/03395405540640822694noreply@blogger.comtag:blogger.com,1999:blog-2986679130504525123.post-85441918178721068982016-02-06T21:38:30.083+01:002016-02-06T21:38:30.083+01:00again a good point, if the additional precision is...again a good point, if the additional precision isn't needed then indeed it makes no sense using it.Michelhttps://www.blogger.com/profile/07415131908018321030noreply@blogger.comtag:blogger.com,1999:blog-2986679130504525123.post-71045566948020259592016-02-04T18:01:33.962+01:002016-02-04T18:01:33.962+01:00Have you tried vertices.foreach_get?>>> v...Have you tried vertices.foreach_get?<br><br>>>> vertices = D.objects['Cube'].data.vertices<br>>>> verts=np.zeros(len(vertices)*3)<br>>>> vertices.foreach_get('co',vests)<br><br>Of course you have to reshape but stillLinus Ynghttps://www.blogger.com/profile/10151314177737257861noreply@blogger.com