Filled cuboid problem

kass_datay1800

Looking around for some CAD
Hello! I am new to the CAD coding thing. I have an easy problem I need to solve. I have a 3D cuboid (provided as a STEP file or alike) that needs to be filled with foam and plastic. I want to visualize the central section of the cuboid, add 5cm thick foam layers on the upper, left, and right sides (offsets), and then fill the remaining space with plastic. I need to ensure that the plastic has dimensions of at least 10cm in length and width. If not, change locally the foam thickness, Finally, I want to display the final result with dimensions (something like in the image).

Is it possible to do it with code? and How?1711726299399.png
 

Quaoar

Administrator
Staff member
You can probably build local prisms starting from the side faces of your cuboid inwards the enclosed volume and fuse them together to model the foam. Then cut the foam solid from the cuboid and obtain the plastic filling this way.

1711728435149.png

To offset a single planar face, it should be sufficient to use BRepOffset_MakeSimpleOffset. To fuse prisms together, use BRepAlgoAPI_Fuse. To cut foam from cuboid use BRepAlgoAPI_Cut.

I prototyped it using Analysis Situs commands as putting it all together in C++ would be quite a time consuming exercise:

Code:
> clear
> make-box a 0 0 0 10 8 5
> set-as-part a; donly
> explode -face
> set i 1; while { $i < 7 } { set-as-part "FACE $i"; offset-shell -1.5 -simple -solid; set-as-var foamSide_$i; incr i }
> bop-fuse res foamSide_2 foamSide_3; donly res
> bop-fuse res res foamSide_1; donly res;
> bop-fuse res res foamSide_4; donly res;
> bop-fuse res res foamSide_5; donly res;
> set-as-part res
> maximize-faces
> set-as-var foam
> bop-cut plastic a foam; donly plastic

Each command has its C++ implementation that should be quite straightforward to understand.
 

kass_datay1800

Looking around for some CAD
Thanks Quaoar, I will try this.
Otherwise, can i make a cross-section and display the dimensions in order to have something like in the image which I found within the documentation but I have no idea how it's done.
1711977555923.png
 

Quaoar

Administrator
Staff member
That's the embedded example in Draw Test Harness. You can run it like this:

1711982491043.png
The trick is then to match up all these Tcl commands to C++, but it proves it's doable.
 
Top