Filename get lost during export of workspace

First things first: Great Job! Kiri is exactly what i was looking for!

However, there is one litte problem: when exporting a workspace, all filenames get lost. After re-importing a workspace all parts are listed as “no name”.

So I drilled down into the API and code and I do not find the location where filenames are stored and I do not find a way (either via API or directly with Javascript) to set/change the filename of a part.

Can you pls put me on the right the track here?

I am using CAM for nesting purposes of simple parts and integrated it with my own web base part administration. Without having a name (or even better a uuid) for each part all the backreference gets lost after saving the workspace.

1 Like

thanks for the bug report. We’ll investigate that shortly.

To change a part name in the UI, you can hover on the carrot next to the object, and select the rename button.

image
In the API, it’s the widget’s meta.file property.

Hope this helps😎 Don’t hesitate to reach out if you need further support.

Thanks a lot! I just spent some more time in this and figured that setting meta.file requires kiri.api.platform.changed() to make the change visible.

My current workaround is:

var exprt = kiri.api.conf.export({work: work, clear: clear});
//make object names persistant by tranferring them into the export:
var fn = function(widget) {exprt.settings.widget[widget.id].file = widget.meta.file};
kiri.api.widgets.each(fn);
//finally base64encode
exprt = kiri.cwin.kiri.api.util.b64enc(exprt);

Maybe this already does the trick… if not I will copy the filenames back.

However, filenames are even more tricky: I load STL files from my own code via kiri.frame (found no direct way to do so yet) and finally want to have the filename added to the widget:

kiri.parseSTLASCII = function (STLCode, filename) {

	window.myLastFilename = filename; //really, really ugly... ok, I do not use window tbh... ;)
	kiri.frame.parse(STLCode, 'stl');   
}


kiri.frame.on('parsed', (data) => {
	try {
		kiri.api.widgets.map()[data[0]].meta.file = window.myLastFilename;
	}
	catch(e) {							
	}
	kiri.api.platform.changed();
			
});

I guess my garbage code could be simplified with two lines of code in kiri/frame.js and have filename as an extra parameter for parse(). Will you accept pull request for little improvements like this?

Made a PR to resolve filename not being saved to .kmz

merged. will be in the 4.3.4 release going out this weekend

2 Likes

Thanks a lot! I looked into the code change and saw that you copy the entire meta object over. Will it be safe to add my own userData object under meta to store my own uuids and such here?

if you inject data there (that’s json codable) it will be preserved in the workspace

Thanks! I did so and it works like charme!

2 Likes