def cloneMeshInstance(self, oldObject, newName): """ Clone a mesh object into a new name and attach it to the current geometryInstance """ print "AcdOptiGeometryInstance::cloneMeshInstance()" assert not newName in self.meshInsts newMesh = AcdOptiMeshInstance.createNew_clone(os.path.join(self.folder, self.meshInstanceFolderName, newName), oldObject, self) self.meshInsts[newName] = newMesh self.write()
def createNew_clone(folder, cloneFrom): """ Creates a new geomInstance in a not previously existing folder, which has identical settings as an already existing geometryInstance. The newly created geomInstance is then returned. This is a deep copy, meshInstances etc. are also cloned. """ #Create the new geomInstance AcdOptiGeometryInstance.createNew(folder) newInstance = AcdOptiGeometryInstance(folder, cloneFrom.template) #Copy information for key in cloneFrom.templateOverrides_getKeys(): newInstance.templateOverrides_insert(key, cloneFrom.templateOverrides_get(key)) for (meshName, mesh) in cloneFrom.meshInsts.iteritems(): newMesh = AcdOptiMeshInstance.createNew_clone(os.path.join(folder,"meshInstances",meshName), mesh, newInstance) newInstance.meshInsts[meshName] = newMesh newInstance.write() return newInstance