How can I save edited nodes in the visual scenes library?

41 views
Skip to first unread message

Shatha Salem

unread,
Feb 21, 2018, 3:53:22 AM2/21/18
to pycollada
Hello all,

Thank you for this library. It has been very helpful. 

I am currently using pycollada to edit .dae files produced/exported by Sketchup. I have successfully edited and saved geometry meshes in the geometries library. The pycollada documentation has a good reference on how to do this. 

However, I am having trouble saving the arrays I edit which are found in the Visual Scenes library. I have attached the a snapshot of the .dae file showing the array I'd like to edit and save. 


Below is the code I'm using to access and then edit and then save the array (shape is 4, 4): 



import numpy as np
from collada import *

mesh_file = Collada('Turbine.dae')
 
HH = 80
HH_diff = HH - 65.07521057

blade_arr_1 = mesh_file.scene.nodes[0].children[2].children[1].children[0].matrix

for k in range(len(blade_arr_1)):
if k == 2:
blade_arr_1[k][3] += HH_diff
 
mesh_file.scene.nodes[0].children[2].children[1].children[0].matrix = blade_arr_1

mesh_file.write('turbine_mod.dae')

 

If I print  mesh_file.scene.nodes[0].children[2].children[1].children[0].matrix, I can see the changes I made. However, when I save the file, the changes I made are not saved. 


Please, help me find a solution to this. I have tried everything! Including reading the documentation cover to cover, and trying other libraries in lxml. 


FYI I'm new to coding.


Best Regards,
Shatha
 
 
 
 
 
 

 

 
 
 
 
  
 
DAE_file_array.PNG

Jeff Terrace

unread,
Feb 21, 2018, 12:06:43 PM2/21/18
to pyco...@googlegroups.com
The matrix attribute is computed based on all the transforms on the scene node. I think you need to modify the transform itself, in the .transforms list on the scene node. Based on what your DAE looks like, I think .transforms should be a list with a single element of MatrixTransform. The MatrixTransform .matrix property can be modified and should be saved.

So in your code, try using mesh_file.scene.nodes[0].children[2].children[1].children[0].transforms[0].matrix

--
You received this message because you are subscribed to the Google Groups "pycollada" group.
To unsubscribe from this group and stop receiving emails from it, send an email to pycollada+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Shatha Salem

unread,
Feb 22, 2018, 2:05:52 AM2/22/18
to pycollada
Thank you for your reply! 

I tried your suggested fix and unfortunately, the problem is still there.. the output file remains unchanged.

I was able to access the numpy array as before (without transforms[0])  
To unsubscribe from this group and stop receiving emails from it, send an email to pycollada+...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages