Not able to use this utility locally in VSCode ?
onkarp12 opened this issue · 12 comments
I want to test this utility and if possible, want to do some changes which are relevant for me. When I try all the mentioned steps and then tried running the utility it fails with error. The error dump is large and does not give any idea what went wrong. I am new to web development, so I followed the mentioned steps from readme file and only did one extra step of installing open cascade js explicitely.
"npm install opencascade.js@beta".
My node installed version is 20. Can you please guide on how to resolve the issue ?
=====Dump starts========================================
WebAssembly version of OpenCASCADE Technology initialized successfully in 4223 ms
file:///D:/opencascade-tools/node_modules/opencascade.js/dist/opencascade.full.js:9
var Module=typeof Module!="undefined"?Module:{};var readyPromiseResolve,readyPromiseReject;Module["ready"]=new Promise(function(resolve,reject){readyPromiseResolve=resolve;readyPromiseReject=reject});var moduleOverrides=Object.assign({},Module);var arguments_=[];var thisProgram="./this.program";var quit_=(status,toThrow)=>{throw toThrow};var ENVIRONMENT_IS_WEB=typeof window=="object";var ENVIRONMENT_IS_WORKER=typeof importScripts=="function";var ENVIRONMENT_IS_NODE=typeof process=="object"&&typeof process.versions=="object"&&typeof process.versions.node=="string";var scriptDirectory="";function locateFile(path){if(Module["locateFile"]){return Module"locateFile"}return scriptDirectory+path}var read_,readAsync,readBinary,setWindowTitle;function logExceptionOnExit(e){if(e instanceof ExitStatus)return;let toLog=e;err("exiting due to exception: "+toLog)}var fs;var nodePath;var requireNodeFS;if(ENVIRONMENT_IS_NODE){if(ENVIRONMENT_IS_WORKER){scriptDirectory=require("path").dirname(scriptDirectory)+"/"}else{scriptDirectory=dirname+"/"}requireNodeFS=()=>{if(!nodePath){fs=require("fs");nodePath=require("path")}};read=function shell_read(filename,binary){requireNodeFS();filename=nodePath"normalize";return fs.readFileSync(filename,binary?undefined:"utf8")};readBinary=filename=>{var ret=read(filename,true);if(!ret.buffer){ret=new Uint8Array(ret)}return ret};readAsync=(filename,onload,onerror)=>{requireNodeFS();filename=nodePath"normalize";fs.readFile(filename,function(err,data){if(err)onerror(err);else onload(data.buffer)})};if(process["argv"].length>1){thisProgram=process["argv"][1].replace(/\/g,"/")}arguments_=process["argv"].slice(2);process["on"]("uncaughtException",function(ex){if(!(ex instanceof ExitStatus)){throw ex}});process["on"]("unhandledRejection",function(reason){throw reason});quit_=(status,toThrow)=>{if(keepRuntimeAlive()){process["exitCode"]=status;throw toThrow}logExceptionOnExit(toThrow);process"exit"};Module["inspect"]=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_WEB||ENVIRONMENT_IS_WORKER){if(ENVIRONMENT_IS_WORKER){scriptDirectory=self.location.href}else if(typeof document!="undefined"&&document.currentScript){scriptDirectory=document.currentScript.src}if(scriptDir){scriptDirectory=scriptDir}if(scriptDirectory.indexOf("blob:")!==0){scriptDirectory=scriptDirectory.substr(0,scriptDirectory.replace(/[?#].*/,"").lastIndexOf("/")+1)}else{scriptDirectory=""}{read=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.send(null);return xhr.responseText};if(ENVIRONMENT_IS_WORKER){readBinary=url=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,false);xhr.responseType="arraybuffer";xhr.send(null);return new Uint8Array(xhr.response)}}readAsync=(url,onload,onerror)=>{var xhr=new XMLHttpRequest;xhr.open("GET",url,true);xhr.responseType="arraybuffer";xhr.onload=()=>{if(xhr.status==200||xhr.status==0&&xhr.response){onload(xhr.response);return}onerror()};xhr.onerror=onerror;xhr.send(null)}}setWindowTitle=title=>document.title=title}else{}var out=Module["print"]||console.log.bind(console);var err=Module["printErr"]||console.warn.bind(console);Object.assign(Module,moduleOverrides);moduleOverrides=null;if(Module["arguments"])arguments=Module["arguments"];if(Module["thisProgram"])thisProgram=Module["thisProgram"];if(Module["quit"])quit_=Module["quit"];var POINTER_SIZE=4;function warnOnce(text){if(!warnOnce.shown)warnOnce.shown={};if(!warnOnce.shown[text]){warnOnce.shown[text]=1;err(text)}}var tempRet0=0;var setTempRet0=value=>{tempRet0=value};var getTempRet0=()=>tempRet0;var wasmBinary;if(Module["wasmBinary"])wasmBinary=Module["wasmBinary"];var noExitRuntime=Module["noExitRuntime"]||true;if(typeof WebAssembly!="object"){abort("no native wasm support detected")}var wasmMemory;var ABORT=false;var EXITSTATUS;function assert(condition,text){if(!condition){abort(text)}}var UTF8Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf8"):undefined;function UTF8ArrayToString(heapOrArray,idx,maxBytesToRead){idx>>>=0;var endIdx=idx+maxBytesToRead;var endPtr=idx;while(heapOrArray[endPtr]&&!(endPtr>=endIdx))++endPtr;if(endPtr-idx>16&&heapOrArray.buffer&&UTF8Decoder){return UTF8Decoder.decode(heapOrArray.subarray(idx,endPtr))}else{var str="";while(idx<endPtr){var u0=heapOrArray[idx++];if(!(u0&128)){str+=String.fromCharCode(u0);continue}var u1=heapOrArray[idx++]&63;if((u0&224)==192){str+=String.fromCharCode((u0&31)<<6|u1);continue}var u2=heapOrArray[idx++]&63;if((u0&240)==224){u0=(u0&15)<<12|u1<<6|u2}else{u0=(u0&7)<<18|u1<<12|u2<<6|heapOrArray[idx++]&63}if(u0<65536){str+=String.fromCharCode(u0)}else{var ch=u0-65536;str+=String.fromCharCode(55296|ch>>10,56320|ch&1023)}}}return str}function UTF8ToString(ptr,maxBytesToRead){ptr>>>=0;return ptr?UTF8ArrayToString(HEAPU8,ptr,maxBytesToRead):""}function stringToUTF8Array(str,heap,outIdx,maxBytesToWrite){outIdx>>>=0;if(!(maxBytesToWrite>0))return 0;var startIdx=outIdx;var endIdx=outIdx+maxBytesToWrite-1;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343){var u1=str.charCodeAt(++i);u=65536+((u&1023)<<10)|u1&1023}if(u<=127){if(outIdx>=endIdx)break;heap[outIdx++>>>0]=u}else if(u<=2047){if(outIdx+1>=endIdx)break;heap[outIdx++>>>0]=192|u>>6;heap[outIdx++>>>0]=128|u&63}else if(u<=65535){if(outIdx+2>=endIdx)break;heap[outIdx++>>>0]=224|u>>12;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63}else{if(outIdx+3>=endIdx)break;heap[outIdx++>>>0]=240|u>>18;heap[outIdx++>>>0]=128|u>>12&63;heap[outIdx++>>>0]=128|u>>6&63;heap[outIdx++>>>0]=128|u&63}}heap[outIdx>>>0]=0;return outIdx-startIdx}function stringToUTF8(str,outPtr,maxBytesToWrite){return stringToUTF8Array(str,HEAPU8,outPtr,maxBytesToWrite)}function lengthBytesUTF8(str){var len=0;for(var i=0;i<str.length;++i){var u=str.charCodeAt(i);if(u>=55296&&u<=57343)u=65536+((u&1023)<<10)|str.charCodeAt(++i)&1023;if(u<=127)++len;else if(u<=2047)len+=2;else if(u<=65535)len+=3;else len+=4}return len}var UTF16Decoder=typeof TextDecoder!="undefined"?new TextDecoder("utf-16le"):undefined;function UTF16ToString(ptr,maxBytesToRead){var endPtr=ptr;var idx=endPtr>>1;var maxIdx=idx+maxBytesToRead/2;while(!(idx>=maxIdx)&&HEAPU16[idx>>>0])++idx;endPtr=idx<<1;if(endPtr-ptr>32&&UTF16Decoder){return UTF16Decoder.decode(HEAPU8.subarray(ptr>>>0,endPtr>>>0))}else{var str="";for(var i=0;!(i>=maxBytesToRead/2);++i){var codeUnit=HEAP16[ptr+i*2>>>1];if(codeUnit==0)break;str+=String.fromCharCode(codeUnit)}return str}}function stringToUTF16(str,outPtr,maxBytesToWrite){if(maxBytesToWrite===undefined){maxBytesToWrite=214
Hi @onkarp12,
could you please also share the following information:
- opencascade.js version number installed
- changes made to the source code (if any)
- command you tried to execute via the terminal
That will help me to remote debug your problem. Thanks!
BR, Georg
Hello Georg, I have followed only steps mentioned in the readme file for developers.
Clone the Git repository:
git clone https://github.com/ghackenberg/opencascade-tools.git
Install development and production dependencies:
cd opencascade-tools && npm install
Afterwards you can use the following scripts:
🖥️ Scripts
Remove JavaScript binaries and TypeScript type definitions from previous builds:
cd opencascade-tools && npm run clean
Compile TypeScript sources to JavaScript binaries and TypeScript type definitions:
cd opencascade-tools && npm run build
Install your version of opencascade-tools into local NPM registry:
cd opencascade-tools && npm run deploy-local
As I mentioned earlier I was expecting all dependencies will get installed with this command "cd opencascade-tools && npm install" but somehow it is not the case for me. I did only one extra step of installing opencascade.js. Tried both commands.
"npm install opencascade.js@beta".
npm install opencascade.js@2.0.0-beta.b5ff984
When I tried to run locally from command prompt then it is not working and throwing dump.
Thanks,
Onkar
PS :
I am looking to read Attributes from STEP file( Dimensions, Color). Wanted to check the output with below code. Without my changes only I got problems, so I am not able to test the changes further.
reader.SetColorMode(true);
reader.SetGDTMode(true);
reader.SetLayerMode(true);
reader.SetMatMode(true);
reader.SetSHUOMode(true);
Thank you for the details! I have one more question:
- Are you getting the error when executing
npm install opencascade.js@...
? - Or are you getting the error when executing
opencascade-tools ...
?
Getting the error when executing command like this from command line "C:\Users\OP>opencascade-tools --format gltf D:\warehouse-32.snapshot.1\Warehouse.step".
Thanks! I think you are missing the --input
flag. Could you please try the following command:
opencascade-tools --format gltf --input D:\warehouse-32.snapshot.1\Warehouse.step
You could also try the --help
flag to print all the options that you can supply to the command:
opencascade-tools --help
I just noticed that the documentation in the README file was not up-to-date. Fixed that!
I am okay with this thread gets closed. Want to understand your thoughts if any. I want to display the PMI ( dimensions ) from STEP file to GLTF file.
I am able to successfully convert the STEP file to GLTF and used the same file for display purpose. But with code changes which I shared earlier; I am still getting same file. Is there anything I am missing?
Referred this link and tried changing the properties from code while reading STEP file.
https://dev.opencascade.org/doc/occt-7.6.0/overview/html/occt_user_guides__step.html#occt_step_7
reader.SetColorMode(true);
reader.SetGDTMode(true);
reader.SetLayerMode(true);
reader.SetMatMode(true);
reader.SetSHUOMode(true);
======================================================
I am not sure, what problem you are facing. Could you please explain again, what you are missing? Are you missing color information in the output for example?
I just tested the current version of the CLI on https://www.steptools.com/docs/stpfiles/ap214/as1-ac-214.stp. In the following, you see a screenshot of the original STEP file loaded with CAD Assistant. In the screenshot, you can see the assembly hierarchy stored inside the STEP file as well as the volumes and colors of the different parts.
The second screenshot below shows the GLTF model generated with the CLI. Again, the screenshot shows the generated assembly hierarchy as well as the part volumes and colors. Note that during conversion the coordinate system flips. Also the names of the assemblies change, because GLTF requires unique names of subassemblies.
Hi @onkarp12,
as far as I understand, the OpenCascade GLTF writer cannot (or does not) consider the PMI data. I assume that it only supports triangles and does not support "simple" line and path geometries, but not sure! Please read the following post from the OpenCascade forum to dive into the details:
https://dev.opencascade.org/content/xcaf-getting-gdt-visible-form
However, you can access the original PMI data using the OpenCascade API. The following post from the OpenCascade forum explains some details of using the OpenCascade API for PMI data extraction:
https://dev.opencascade.org/content/it-possible-create-pmi-gltf-files-and-make-it-visible
Maybe you can use a data format different from GLTF, which supports all, the assembly hierarchy, the part geometries, and the PMI data (not sure one exists!). Or you stick with GLTF for the assembly hierarchy and the part geometries, and use a different (maybe even custom) data format for the PMI data.
Hi @onkarp12, did these links help you find a solution for your problem?
Yes and NO. I have already gone through these links earlier before. I was looking for a sample code which will help me to guide through the process of reading PMI and a way to display in GLTF\web format.
I am looking for the sample code which helps me give idea on how to achieve this. Nevertheless, thanks for these links. Hope I will get some way to do this.