{"id":15060494,"url":"https://github.com/aljoshakoecher/step-to-json","last_synced_at":"2025-10-04T19:31:25.401Z","repository":{"id":57370789,"uuid":"236973862","full_name":"aljoshakoecher/STEP-to-JSON","owner":"aljoshakoecher","description":"A parser that can be used to extract the system structure of a step file and output as json","archived":false,"fork":true,"pushed_at":"2023-11-30T15:52:58.000Z","size":418,"stargazers_count":26,"open_issues_count":2,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-09-29T06:05:17.327Z","etag":null,"topics":["assembly","cad","cae","component-structure","converter","json","parser","step"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":"hsu-aut/STEP-to-JSON","license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/aljoshakoecher.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-01-29T12:10:24.000Z","updated_at":"2024-09-21T21:35:15.000Z","dependencies_parsed_at":null,"dependency_job_id":null,"html_url":"https://github.com/aljoshakoecher/STEP-to-JSON","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljoshakoecher%2FSTEP-to-JSON","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljoshakoecher%2FSTEP-to-JSON/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljoshakoecher%2FSTEP-to-JSON/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/aljoshakoecher%2FSTEP-to-JSON/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/aljoshakoecher","download_url":"https://codeload.github.com/aljoshakoecher/STEP-to-JSON/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":219876758,"owners_count":16554786,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["assembly","cad","cae","component-structure","converter","json","parser","step"],"created_at":"2024-09-24T22:59:29.873Z","updated_at":"2025-10-04T19:31:19.953Z","avatar_url":"https://github.com/aljoshakoecher.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# STEP-to-JSON\nA parser for STEP-files that can be used in node.js as well as in frontend development. STEP-to-JSON parses STEP-files (IS0 10303-44) into a JSON structure. It extracts product definitions, relations and creates the assembly tree of all components.\n\n## How to install\nSTEP-to-JSON can be used in both Back- and Frontend projects. To use it in your own project, simply install via NPM:\n```\nnpm install step-to-json --save\n```\n\nIt also features a CLI tool if you're just interested in parsing STEP-files manually. To use the CLI-tool, you currently have to clone / download this repository and execute the following steps:\n\n```\n$ git clone https://github.com/aljoshakoecher/STEP-to-JSON\n$ cd \u003cthe folder you cloned to\u003e\n$ npm install\n$ node step-to-json.js -f \"\u003cyour STEP-file\u003e.stp\"\n```\n\n## How to use\nThe most simple way to convert your STEP file's assembly structure into JSON is by using the parser's `parse()`-function. After instaling the parser you import the it into your project and create an instance of it. Make sure to pass an Athe path to your STEP-file to the constructor. Then you can just call `parse()` as shown below:\n\n### Node.js Example\n\n```javascript\n// Add to your imports\nconst StepToJsonParser = require('step-to-json').StepToJsonParser;\n\n// To get your STEP-file's assembly structure as JSON:\nconst filePath = \"this should be a valid path to your STEP-file\"\nconst stepFile = fs.readFileSync(filePath);\nconst parser = new StepToJsonParser(stepFile);\n\nconst assemblyStructure = parser.parse();\n```\n\n### Frontend Example (e.g. Angular)\nUsing the parser in a frontend application is a bit more tricky since interacting with the filesystem is not as easy as it is in Node.js. In the following example you can see how to parse a file that you grab from an input with `type=\"file\"`:\n\nLet's assume this is your html:\n```html\n\u003c!-- parsing-component.component.html --\u003e\n\u003cinput type=\"file\" (change)=\"onFileChange($event)\"\u003e\n```\n\nYou can then use the parser as follows:\n```ts\n// parsing-component.component.ts\nimport {StepToJsonParser} from 'step-to-json';\n\n// ...\n// is called as soon as a file is selected with the input\nonFileChange(fileChangeEvent) {\n    const inputReader = new FileReader();\n\n    // setup onload handler that is executed as soon as file is completely loaded\n    inputReader.onload = (event:any)=\u003e{\n        const fileContent = event.target.result\n        const parser = new StepToJsonParser(fileContent);       // Instantiate parser with file\n        console.log(parser.parse());                            // Log parser output\n    }\n\n    // start reading the selected file\n    inputReader.readAsText(fileChangeEvent.target.files[0]);\n}\n```\n\n\n## API-Documentation\nFunctionality of the `StepToJsonParser` class\n\n### parse(visitorFunction = undefined, sub = new Subject())\nMain parse function that parses the current STEP file and outputs its contents as a JSON tree. Accepts a visitor function, that is called for every product element. The visitor function always gets the current element with the following attributes passed as an argument:\n```javascript\n{\n    id: any;        // ID string\n    name: any;      // Name string\n    contains: []    // Array of sub components\n}\n```\nThe visitor function can be used to manipulate the id or name of products or in general to hook into the parsing process.\nIn addition, an rxjs subject can be passed to track the progress. On each new element, the subject emits the number of elements that were parsed.\n\n### parseWithUuid(sub = new Subject())\nThe function `parseWithUuid()` is basically one example of the more general `parse()` function shown above. It uses a default visitor function that creates a UUID ID for every element. Just like with `parse()`, you can pass a subject to get notified of the current parsing state. If you don't want to get UUID IDs and want to customize the generated objects, check out the `parse()` function above.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faljoshakoecher%2Fstep-to-json","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Faljoshakoecher%2Fstep-to-json","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Faljoshakoecher%2Fstep-to-json/lists"}