!1143 修复:复合实体导出expv,expd时没有导出材质的问题

pull/1143/MERGE
ChenX 4 years ago
parent 424db1de35
commit abdf3e4e24

@ -113,16 +113,11 @@ type Data = {
export function Entitys2Data(ents: Entity[]): Data
{
let d: Data = { Entitys: [], Materials: [] };
let materials: Set<ObjectId> = new Set();
for (let e of ents)
{
let index = d.Entitys.length;
if (e instanceof Board)
{
d.Entitys.push(ConvertBoard2Data(e));
if (e.Material?.Object)
materials.add(e.Material);
}
else if (e instanceof SweepSolid)
d.Entitys.push(ConverSweep2Data(e));
else if (e instanceof Region)
@ -139,11 +134,24 @@ export function Entitys2Data(ents: Entity[]): Data
for (; index < d.Entitys.length; index++)
d.Entitys[index].Visible = e.Visible;
}
if (materials.size > 0)
let materials = new Set<number>();
for (let e of d.Entitys)
{
if (e.MaterialId !== undefined)
materials.add(e.MaterialId);
}
for (let idIndex of materials)
{
for (let m of materials)
if (idIndex !== 0)
{
d.Materials.push(ConverMaterial(m.Object as PhysicalMaterialRecord));
let id = app.Database.GetObjectId(idIndex);
if (id.Object)
{
let mtl = id.Object as PhysicalMaterialRecord;
d.Materials.push(ConverMaterial(mtl));
}
}
}
return d;

Loading…
Cancel
Save