OCP icon indicating copy to clipboard operation
OCP copied to clipboard

Problem with IVtkOCC_Shape at 7.7.2

Open BlankuApp opened this issue 1 year ago • 1 comments

When i install the OCP using conda install -c conda-forge -c cadquery ocp , I cannot run the following code:

        vtk_shape = IVtkOCC_Shape(self._ocp)
        shape_data = IVtkVTK_ShapeData()
        shape_mesher = IVtkOCC_ShapeMesher()

        drawer = vtk_shape.Attributes()
        drawer.SetUIsoAspect(Prs3d_IsoAspect(Quantity_Color(), Aspect_TOL_SOLID, 1, 0))
        drawer.SetVIsoAspect(Prs3d_IsoAspect(Quantity_Color(), Aspect_TOL_SOLID, 1, 0))
        drawer.SetFaceBoundaryDraw(True)

        shape_mesher.Build(vtk_shape, shape_data)

        rv = shape_data.getVtkPolyData()

it returnes rv=None

But when i install the older versions conda install -c conda-forge -c cadquery ocp=7.7.0 the problem is solved.

BlankuApp avatar Apr 28 '24 02:04 BlankuApp

Use the conda-forge build: conda install -c conda-forge ocp=7.7.2.

adam-urbanczyk avatar Apr 28 '24 08:04 adam-urbanczyk

ran into this issue too using poetry, will try with conda

dvc94ch avatar Jul 01 '24 11:07 dvc94ch

python packages are still a mess, conda doesn't support nushell, arch linux doesn't have a proper conda package (only aur), but finally got it working with pixi to install the conda packages + pip and using pip to install build123d. (also tried nix and going on some other tangents). but the result seems like the simplest way to show a model without vscode:

# build model
import build123d as bd

length, width, thickness = 80.0, 60.0, 10.0
center_hole_dia = 22.0

ex2 = bd.Box(length, width, thickness)
ex2 -= bd.Cylinder(center_hole_dia / 2, height=thickness)


# convert to pyvista
import OCP
import pyvista as pv

vs = OCP.IVtkOCC.IVtkOCC_Shape(ex2.solid().wrapped)
sd = OCP.IVtkVTK.IVtkVTK_ShapeData()
sm = OCP.IVtkOCC.IVtkOCC_ShapeMesher()
sm.Build(vs, sd)
data = sd.getVtkPolyData()
mesh = pv.PolyData(data)


# plot mesh in pyvista
plotter = pv.Plotter()
plotter.add_mesh(mesh)
plotter.show()

dvc94ch avatar Jul 03 '24 09:07 dvc94ch

The conclusion here is that one needs to use abi compatible builds of OCP/OCCT/VTK. The most robust way is to install on any distro/shell is to directly download micromamba, not init the shell, but rather use micromamba run. https://mamba.readthedocs.io/en/latest/user_guide/micromamba.html

BTW, you can use show from cadquery.vis for visualizing TopoDS_Shape with VTK only.

adam-urbanczyk avatar Jul 03 '24 17:07 adam-urbanczyk