|
|
|
@ -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)
|
|
|
|
|
{
|
|
|
|
|
for (let m of materials)
|
|
|
|
|
if (e.MaterialId !== undefined)
|
|
|
|
|
materials.add(e.MaterialId);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (let idIndex 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;
|
|
|
|
|