mirror of
https://github.com/xibyte/jsketcher
synced 2025-12-06 16:33:15 +01:00
fix double import bug in freecad file importer
This commit is contained in:
parent
6b8213519e
commit
ac6e8dc567
1 changed files with 20 additions and 24 deletions
|
|
@ -9,6 +9,7 @@ import { LocalFile } from "ui/components/controls/FileControl";
|
||||||
import CadError from "../../../../../web/app/utils/errors";
|
import CadError from "../../../../../web/app/utils/errors";
|
||||||
import { parseStringPromise } from 'xml2js';
|
import { parseStringPromise } from 'xml2js';
|
||||||
import * as jszip from "jszip";
|
import * as jszip from "jszip";
|
||||||
|
import { FcElectricalSensor } from 'react-icons/fc';
|
||||||
|
|
||||||
|
|
||||||
interface ImportModelParams {
|
interface ImportModelParams {
|
||||||
|
|
@ -56,38 +57,33 @@ export const ImportModelOpperation: OperationDescriptor<ImportModelParams> = {
|
||||||
|
|
||||||
for (const itemToLookAt in DecodedXmlFreeCADData) {
|
for (const itemToLookAt in DecodedXmlFreeCADData) {
|
||||||
const flattenedObject = flattenJSON(DecodedXmlFreeCADData[itemToLookAt]);
|
const flattenedObject = flattenJSON(DecodedXmlFreeCADData[itemToLookAt]);
|
||||||
let importBrepFlag = true;
|
let importBrepFlag = false;
|
||||||
let importBrepShapeName = "";
|
let importBrepShapeName = "";
|
||||||
let visiblePropertyName = "";
|
let visiblePropertyName = "";
|
||||||
for (const propertyToLookAt in flattenedObject) {
|
for (const propertyToLookAt in flattenedObject) {
|
||||||
console.log(propertyToLookAt + " = " + flattenedObject[propertyToLookAt]);
|
//console.log(propertyToLookAt + " = " + flattenedObject[propertyToLookAt]);
|
||||||
|
importBrepFlag = false;
|
||||||
if (propertyToLookAt.includes("Part.0.$.file")) importBrepShapeName = flattenedObject[propertyToLookAt];
|
if (propertyToLookAt.includes("Part.0.$.file")) importBrepShapeName = flattenedObject[propertyToLookAt];
|
||||||
|
if (importBrepShapeName !== "PartShape.brp"){
|
||||||
if (propertyToLookAt.includes("$.name") && flattenedObject[propertyToLookAt] == "Visibility") {
|
if (propertyToLookAt.includes("$.name") && flattenedObject[propertyToLookAt] == "Visibility") {
|
||||||
let propToCheck = propertyToLookAt.replace(".$.name", ".Bool.0.$.value");
|
let propToCheck = propertyToLookAt.replace(".$.name", ".Bool.0.$.value");
|
||||||
if (flattenedObject[propToCheck] == "false") importBrepFlag = false;
|
let shouldItImport = flattenedObject[propToCheck];
|
||||||
}
|
console.log(shouldItImport, importBrepShapeName);
|
||||||
|
if (shouldItImport == "true") {
|
||||||
}
|
|
||||||
if (importBrepFlag == true) {
|
|
||||||
try {
|
try {
|
||||||
await FS.writeFile(importBrepShapeName, `DBRep_DrawableShape\n` + await zipContents[importBrepShapeName].async("string"));
|
await FS.writeFile(importBrepShapeName, `DBRep_DrawableShape\n` + await zipContents[importBrepShapeName].async("string"));
|
||||||
await oci.readbrep(importBrepShapeName, importBrepShapeName);
|
await oci.readbrep(importBrepShapeName, importBrepShapeName);
|
||||||
returnObject.created.push(occ.io.getShell(importBrepShapeName));
|
returnObject.created.push(occ.io.getShell(importBrepShapeName));
|
||||||
|
console.log(importBrepShapeName);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
console.log(e)
|
console.log(e)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for (const property in zipContents) {
|
|
||||||
// if (property.endsWith("brp")) {
|
|
||||||
// FS.writeFile(property, `DBRep_DrawableShape\n` + await zipContents[property].async("string"));
|
|
||||||
// oci.readbrep(property, property);
|
|
||||||
// returnObject.created.push(occ.io.getShell(property));
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
//console.log(zipContents);
|
|
||||||
} else if (FileName.endsWith("STEP") || FileName.endsWith("STP")) {
|
} else if (FileName.endsWith("STEP") || FileName.endsWith("STP")) {
|
||||||
|
|
||||||
//step Import
|
//step Import
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue