donalffons / opencascade.js

Port of the OpenCascade CAD library to JavaScript and WebAssembly via Emscripten.
https://ocjs.org/
GNU Lesser General Public License v2.1
582 stars 85 forks source link

can i modify or replace a shape for an assembly ? (Adding new shape replacing the old opencascade shape) #261

Open RajanHexa opened 9 months ago

RajanHexa commented 9 months ago

i have the following code for replacing the shape for non assembly model but it doesn't work on an assembly. so is there any different approach for it

function  replaceOpenCascadeShape(inShapeTool, oldOpenCascadeShape, newOpenCascadeShape, openCascade) {
    let reShapeTool = new openCascade.BRepTools_ReShape()
    reShapeTool.Replace(oldOpenCascadeShape, newOpenCascadeShape)
    let label  = inShapeTool.FindShape_2(oldOpenCascadeShape, true);
    let newShape = reShapeTool.Apply(newOpenCascadeShape, openCascade.TopAbs_ShapeEnum.TopAbs_SHAPE)
    let assembly  = getAssembly(inShapeTool, openCascade)
    if (!openCascade.XCAFDoc_ShapeTool.IsAssembly(assembly)) {
        inShapeTool.SetShape(label, newShape)
    }
}