@@ -37,6 +37,12 @@ interface PrintConfig {
3737 printerSettingsId : string // 打印机设置ID
3838 printSettingsId : string // 打印设置ID
3939 compression : 'none' | 'standard' // 压缩方式
40+
41+ metadata : Partial < {
42+ Application : string // 应用名称
43+ Copyright : string // 版权信息
44+ ApplicationTitle : string
45+ } > & Record < string , string >
4046}
4147
4248// 默认的打印配置 (基于 Bambu Lab A1)
@@ -50,6 +56,11 @@ export const defaultPrintConfig: PrintConfig = {
5056 printerSettingsId : 'Bambu Lab A1 0.4 nozzle' ,
5157 printSettingsId : '0.20mm Standard @BBL A1' ,
5258 compression : 'standard' ,
59+
60+ metadata : {
61+ Application : 'BambuStudio-02.04.00.70' ,
62+ ApplicationTitle : 'Exported 3D Model' ,
63+ } ,
5364} as const
5465
5566const JSZipCompressionMap = { standard : 'DEFLATE' as const , none : 'STORE' as const }
@@ -84,7 +95,7 @@ export async function exportTo3MF(
8495 const transform = calculateCenteringTransform ( modelCenter , boundingBox , printConfig )
8596
8697 // 创建 3MF 所需的基本文件结构
87- const mainModelXml = createMainModelXML ( objectId , components , transform )
98+ const mainModelXml = createMainModelXML ( objectId , components , transform , printConfig )
8899 const objectModelXml = createObjectModelXML ( components )
89100 const modelSettingsXml = createModelSettingsXML ( objectId , components )
90101 const projectSettingsConfig = createProjectSettingsConfig ( materials , printConfig )
@@ -281,7 +292,14 @@ function calculateCenteringTransform(modelCenter: ModelCenter, boundingBox: Boun
281292/**
282293 * 创建主3dmodel.model文件的XML数据
283294 */
284- function createMainModelXML ( objectId : number , components : ComponentInfo [ ] , transform : string ) : string {
295+ function createMainModelXML ( objectId : number , components : ComponentInfo [ ] , transform : string , printConfig : PrintConfig ) : string {
296+ const metadata = [ ]
297+ const metadataConfig = printConfig . metadata
298+ metadata . push ( { '@_name' : 'CreationDate' , '#text' : new Date ( ) . toString ( ) } )
299+ for ( const key in metadataConfig ) {
300+ metadata . push ( { '@_name' : key , '#text' : metadataConfig [ key ] } )
301+ }
302+
285303 const model = {
286304 model : {
287305 '@_unit' : 'millimeter' ,
@@ -290,12 +308,7 @@ function createMainModelXML(objectId: number, components: ComponentInfo[], trans
290308 '@_xmlns:slic3rpe' : 'http://schemas.slic3r.org/3mf/2017/06' ,
291309 '@_xmlns:p' : 'http://schemas.microsoft.com/3dmanufacturing/production/2015/06' ,
292310 '@_requiredextensions' : 'p' ,
293- 'metadata' : [
294- { '@_name' : 'Application' , '#text' : 'BambuStudio-01.07.04.52' } ,
295- { '@_name' : 'Title' , '#text' : 'Exported 3D Model' } ,
296- { '@_name' : 'CreationDate' , '#text' : new Date ( ) . toString ( ) } ,
297- { '@_name' : 'Copyright' , '#text' : 'Copyright (c) 2023. All rights reserved.' } ,
298- ] ,
311+ metadata,
299312 'resources' : {
300313 object : {
301314 '@_id' : `${ objectId } ` ,
0 commit comments