Forum archive

pythonOCC

Technical discussions preserved from the public OCCT community forum.

Topics
72
Replies
143
Files
60

Discussions

Page 1 of 2

Showing 60 discussions, ordered by the latest archived activity.

How do i know if a point on the surface is inside or outside the wire

The face is a part surface bounded by edges, and edges are organized into wires. How do i know if a point on the surface is inside or outside the wire? This point is generated from UV parameters, so it is on the surface, i want to know whether the point is in valid range (inside the wire).

0 replies

How can i get face geometry infomation from STEP file ?

I use pythonocc to load a STEP file, and then I want to extract geometry info of its every surface. My STEP file is a simple pipe(pipe.png)It have 6 faces: the pipe has 2 cylindrical outer surfaces, 2 cylindrical inner surfaces, and the top and bottom annular planar surfaces, totaling 6 surfaces. Ho

1 reply1 file

BRepAlgoAPI_Common produces no geometry

Hi everyone, I have 2 breps and i would like to get their intersection (see image attatched). The shapes are valid closed solids and they do intersect. However the result is a topods_compound that does not contain any geometry. Does anyone have any tips how to fix this? The report says "BOPAlgo_Aler

2 replies4 files

How to export GLTF with materails?

Following is my code that exports Shape to GLTF base54 encoded string. But its all grey. How do I add materials? def export_shape_gltf(shp: TopoDS_Shape, asc: bool = False) -> str: """ Export shape to gltf Returns the base64 encoded gltf (glb) file """ doc = TDocStd_Document("pythonocc-doc-gltf-expo

0 replies

Strange behavior when highlighting and selecting a surface in QtViewer

Hello all, I have observerd a strange behavior in the QtViewer when I move my mouse over some surfaces. The surfaces are created using BRepPrimAPI_MakeRevol , revolving a single edge around the z-axis. I create one surface that is completely parallel to the z-axis, and another where the surface is a

2 replies1 file

Convert JT to STL

Experts, I'm looking for convert JT to STL pythonOCC source code. OCC JT import/export components can't convert JT to STL. CAD Assistant can view JT, but can't save as STL. Help!

1 reply

Convert from GLTF to STEP

Hi, I am trying to make simple converter from GTLF (GLB) to STEP format. I am using a simple box as my test input (see attached .zip). Reading of the GTLF file seems to work fine using: # Create an handle to a document doc = TDocStd_Document("gltf-convert-doc") # Create GLTF reader gltf_reader = RWG

3 replies2 files

How to calculate normals of faces from catia

Hi, i am using the following code to get the faces from CATIA, but I don't know how can i calculate the normals for these faces. There is so way to first convert the CATPart to stp and then use python occ (GProp_GProps) but i don't want to use that method. import win32com.client def search_items(sea

0 replies

PythonOCC Help!! Creating a propeller blade from 3d airfoil data

Hello, I am new to PythonOCC. Currently, I am working on a project where I need to build a 3D blade from airfoil data. There are 10 airfoils in the Excel file. After exporting the 3D coordinate points for all the airfoils (each airfoil has 199 data points with x,y, and z coordinates), I create wires

0 replies2 files

Importing CSV files and creating splines from points

Hello, I am new to PythonOCC. For my project, I am trying to import a CSV file that contains the coordinates of some airfoil profiles. My plan is to import in those points, create splines through the points to construct 2D airfoil profiles, and then loft and connect these 2D profiles to build a 3D w

0 replies

Get solid, faces, edges and vertices from id

How can I get the solid, faces, edges, and vertices from this STEP file id: #28=TRIANGULATED_FACE('',#26,10,((-1000.,-0.,-0.)),$,(),((10,9,8),(10,8,7),(10,7,6),(10,6,5),(10,5,4),(10,4,3),(10,3,2),(10, 2,1))); Thanks in advance.

1 reply

Using pythonOCC to get Weld Bead

Hello everyone. I want to be able to use Python to read a .STP file, exported by solidworks as STEP 242 using MBD. In the read file, I want to be able to find the edges that I mark in the SW as weldments. By looking at the ASCII of the .STP file I can see this line: #69=TESSELLATED_SHELL('Weld Bead1

6 replies

Check if a Point is in a Surface

Hello, I am currently trying to create a function which checks whether a 3D-Point (gp_Pnt(0,0,0)) is inside a TopoDS_Face Object. While browsing other forum topics I came across the BRepClass_FaceClassifier, which does exactly that but only in 2D. Is there a simple way using OCC, or do I have do do

0 replies

How to avoid showing a lot of OpenGL/Nvidia-information when starting my script?

Hi, I have a pythonOCC-file with something like the following: from OCC.Display.SimpleGui import init_display ... ... class myOCCclass: def __init__(self, args): .... self.display, self.start_display, self.add_menu, self.add_function_to_menu = init_display() When I run it, I get something like: qt-p

1 reply

Isocurve outside the Surface

Hello Idk why my isocurve lies outside the surface. I have attached images for reference. from OCC.Display.SimpleGui import init_display from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire from OCC.Core.TColgp import TColgp_Array1OfPnt from OCC.Core.gp import gp_Pnt

3 replies3 files

PythonOCC challenges in 3D Modeling and Mesh Generation!

Hey everyone, I have been encountering a challenge with PythonOCC in my CAD project, specifically while working on 3D modeling and mesh generation tasks. Despite diligently following the documentation and relevant examples, I'm facing unexpected behavior in the output. For instance, issues arise whe

0 replies

Why BRepOffsetAPI_MakeOffsetShape crashes?

I attempted to offset some surfaces in a STEP file, but the offset was not applied correctly. Here is the code I used and the output I got. CODE: from OCC.Core.TopoDS import topods_Face, TopoDS_Face from OCC.Core.STEPControl import STEPControl_Reader from OCC.Display.SimpleGui import init_display fr

1 reply1 file

Efficient Way to Update Display

Hi there, I'm looking for the best way to update a shape that is already displayed. I've noticed that pythonocc seems to use EraseAll, which only hides shapes, not remove them. I was considering saving the AIS_Shape output when you use DisplayShape and using it as a reference, but I'm finding it har

0 replies

Custom Camera Controller

I am looking to manipulate a camera in pythonocc. I want to make an orbit camera: Camera is always looking at 0,0,0 Right Mouse Drag X rotates camera around the y axis in the scene Right Mouse Drag Y raises or lowers the tilt or yaw of the camera, but to never exceed 90 deg or go below -90 deg Mouse

0 replies

Help needed: Projection of a shape on a plane

Hi together! Currently i am working on a little project using pythonocc, and have a problem I can't get my head around. My problem is the following: I have a solid and a plane. I would like to project the solid onto this plane to create a new 2 shape (the "outline" of the solid). Then, i would like

6 replies

STEP file not exported correctly (but iges and brep are exported correctly)

I created a shape using Booleans and then tried to export it to the STEP file, but the output was wrong. I was successfully able to export it in IGES and BREP. Code to Replicate it. from OCC.Core.BRepPrimAPI import * from OCC.Core.gp import * from OCC.Core.TopLoc import * from OCC.Core.BRepAlgoAPI i

6 replies5 files

Get vertices coordinates on an edge

I have this function: shape = read_step_file(input_path) t = TopologyExplorer(shape) edges = [] for edge_idx, edge in enumerate(t.edges()): d = {'edge': edge, 'edge_index': edge_idx, 'vertices_coordinates': []} vertices = t.vertices_from_edge(edge) for i, vertice in enumerate(vertices): c = vertice.

2 replies2 files

Jupyter notebook STEPControl_Reader.TransferRoot(s) issue

Hi there, I am trying to load a Step file on a Jupyter notebook/Jupyter-lab file. However, when I execute STEPControl_Reader.TransferRoot() the kernel dies. If I run the same code via a python script everything works fine. Is this a known issue? step_reader = STEPControl_Reader() step_reader.ReadFil

3 replies1 file

Project a brep on XY plane

Hi, I want to write a python code to project a brep on xy plane. I found this C++ code and was hoping to convert it to pythonOCC: https://dev.opencascade.org/node/77142#comment-11973 However the class Prs3d_Projector seams to no longer be available in OOC Version 7.7.0 ( https://dev.opencascade.org/

1 reply

Displaying a tooltip when a 3D object is clicked in pythonOCC 3D viewer

In PythonOCC, I am trying to make a tooltip or popup of sorts to display some text when I click a sphere that I created in 3D space. The code that I used and the resulting window is attached below. I would greatly appreciate it if anyone could explain how I can add a tooltip using PythonOCC to direc

2 replies4 files

How to get rid of holes completely

Hi, how do I get rid of a hole completely? I tried fusing it with a shape that has the same geometry but the edges of the hole are still there. I want an approach that removes it entirely as if it was never there.

1 reply2 files

Wrong oriented bounding box

Hello I am getting a wrong oriented bounding box for a TopoDS_Shell consisting of two rectangular faces in the XY plane rotated by 23 degrees about the Z-axis. The long side of the overall shape is 2 and short is 1 but I get 0.75 and 0.5.The body was imported using the STEP file importer and I used

0 replies2 files

Wire to Face not working properly

Hi together, i made a wire from edges, and now i am trying to create a face from it. I used BRepBuilderAPI_MakeFace(wire), however the result seems wrong. The resulting face and wire are visualized in the picture i attached. Appearently, the MakeFace has problems with round parts of a wire. Does any

3 replies2 files

can't get app.Open() to work in pythonOCC, but it works fine in C++

I want to use PythonOCC to load a file saved in .xbf format then save it in .step format. I have attached C++ code that works fine. Below is my PythonOCC script which doesn't work. Can anyone tell me what I need to do to get this to work? #!/usr/bin/env python """ File: read-XDE.py copyright 2022 Do

1 reply1 file

FindAttribute not working

When using TNaming_NamedShape and FindAttribute to get the attribute from a label, I cannot get the shape stored in that attribute, the return is None. Is there anyone who has the same problem with me?

1 reply2 files

The read speed of read_stl_file(filename)

OCC.Extend.DataExchange module read_stl_file(filename) opens a stl file, reads the content, and returns a BRep topods_shape object I thought this method is too slow to read a STL file, when it's come to 100M. Has anyone found and solved this problem, thanks you.

10 replies3 files

problems with BRepAlgoAPI_Cut: lost control of surface complexity after the cut

Dear all, I'm finding several difficulties in a very simple tool that creates a box. All the surfaces of the box are defined starting from simple curves, by means of the BRepOffsetAPI_ThruSections function. Each curve is built from a list of points (by means of GeomAPI_PointsToBSpline) provided as i

0 replies3 files

How to erase message

I used OCCViewer's method, which is called DisplayMessage to display some number. Now, I want to know how can I erase them, thanks.

0 replies2 files

API: PythonOCC and FreeCAD are incompatible when imported into the same python File

When I import FreeCAD and Part module, I also import some module in OCC.Core. But, I got some errors listed below. "ImportError: /OCC/Core/_STEPControl.so: undefined symbol: " However, if I only import one of them,(e.t. only import OCC or only import FreeCAD), I won't got the above errors. So, can a

0 replies2 files

Standalone GUI to extract surface

Dear all, Would anyone kindly help me? I can pay around USD 500 for this task. I would like to write a GUI (PyQt5) to do the following: 1. The user opens a Step file. 2. On the 3D view, the user can rotate the model and select some surfaces. 3. When the user clicks a button "Select", then the select

4 replies3 files

BRepClass_FaceExplorer.CurrentEdge - TypeError for Orientation

I am having trouble invoking the method to get the handle and orientation of the current edge of a face. I did this from OCC.Core.BRepClass import BRepClass_FaceExplorer from OCC.Core.BRepClass import BRepClass_Edge from OCC.Core.TopAbs import TopAbs_Orientation facetopo = BRepClass_FaceExplorer(fac

0 replies

display: how to hide a face within an AISColored shape

Dear all, I'm quite new to pythonOCC, so let me apologize if my question will results trivial for the experts. I'm trying to develop a tool in which the user can select different faces of an object. I would like also to include a function to hide some selected faces. Unfortunately, after several att

4 replies2 files

How to use occ blanking algorithm

I am using the blanking algorithm in occ. I want to know how I should find the corresponding line data in the three-dimensional entity through the line data after the blanking. thank you very much!

1 reply

Depth map generation from a step file

Hello all, I am a newcomer and have very little experience with pythonOCC. I ran a few examples and realized how powerful it is... However I have a quite specific need, and wonder if pythonOCC is the right technology for that. I would like to import a step file, and generate a rastered top view of t

0 replies

FitAll() very very strange result

I'm having a very strange issue when apply a display.FitAll() to two simple shapes. The first shape is a cube (CUBE_ON_ZERO.stp) generated by an external CAD in the world position (0,0,0). When I try to display.FitAll() everything is correctly shown: the shape is properly fitted in the view. Archive

0 replies1 file

Disabling edges when working with BRepPrimAPI_MakeRevol

Hello! I have a question about working with BRepPrimAPI_MakeRevol. I create a faсe and apply BRepPrimAPI_MakeRevol. Creation code: from OCC.Core.BRepBuilderAPI import BRepBuilderAPI_MakeEdge, BRepBuilderAPI_MakeWire, BRepBuilderAPI_MakeFace from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeRevol from

1 reply1 file

identify holes on surface

Hello, I have a model with surface that has holes in it (for exmaple - cylidriical holes) I have identified the type of the surface, but I need now to get the dimensions of the holes - I can I do it using pythonocc? Please advice Zofit

0 replies

arc of conic

Hi, I would like to create a 2d arc (or segment) of a conic. The controls are: Point A, Point B, tangent angle at point A, tangent angle at point B and the conic constant (rho). This type of object exist in commecial CAD packages (Proe, Solidworks,..) Thanks for the help! Stephane.

1 reply

MakeHalfSpace Runtime Error - Only when run on Linux

I am working on a code to use the BRepPrimAPI_MakeHalfSpace command. It works with Windows 7, but has an error on Linux (CentOS 7.7). The error is: Traceback (most recent call last): File "Example_Case_Fail.py", line 10, in <module> half_space_obj = BRepPrimAPI_MakeHalfSpace(temp_face, gp_pnt_obj) F

2 replies

How to split a solid

I'm trying to split a very complex solid in 2 portion using a prism. I keep getting an error: RuntimeError: StdFail_NotDone BRep_API: command not done Here is a snippet that reproduce the problem box = BRepPrimAPI_MakeBox(5,5,5).Shape() profile = BRepBuilderAPI_MakeEdge(gp_Pnt(-1., 2., 0.),gp_Pnt(6,

1 reply

How to get information about openings in a shape?

Hello everyone, i want to disassemble a shape, save it in three lists (a vertices list with coordinates, a edges list with numbers of vertices that refer to the vertices list, a wires list with numbers of edges that refer to the edges list) and rebuild the shape again afterwards. It works fine for m

2 replies1 file

How to get parameters from the Geom_Curve(s) ?

Hi, All I've asked question few days ago wrt getting and extracting features from the STEp file using OCC/Python. See https://www.opencascade.com/content/extract-shape-parameters-topodssolid... details, STEP file itself and solution proposed by Guido. I pretty much converted his code to Python-OCC (

5 replies1 file

Intersection between two faces

Hello everyone, I am trying to find whether there was an intersection between two faces. I need the result True or false. For this intersection, I used GeomAP_IntSS for finding the intersection. But the problem is, even two faces doesnot intersect each other, it returns True. Can anyone help me why

3 replies

PythonOCC for reading parasolid

We need to import parasolid (X_T) file format and check some geometry data like: volume, surface area, etc. I understand Open CASCADE Technology -The Parasolid Import interface reads X_T.

6 replies

Visibility of edges & vertexes through shells

I'm making an app that's primarily for visualization, not manipulation. That is, I just want to show the user how things relate to each other, they don't have to be able to change much. My app is based off of 'wxDisplay.py' and 'OCCViewer.py'. What I've got is a bunch of solid objects, lines, and po

2 replies

Bnd_Box module

Hello, We are using Bnd_Box api to calculate a bounding box of a component (STEP & IGES format) parallel to all principle planes. However this does not give the exact dimensions for the bouding box and has some tolerance added to these values. For example a cylinder with a diameter 100 and height 50

1 reply

Make components of STEP object selectable

Hello, I'm new with OCC and pythonOCC. I need to load a step file, which is working. It contains an assembly of three components. I want to make these components selectable. Unfortunately following the examples (with SimpleGUI), I can only select the whole component (or surfaces). How can I access t

4 replies2 files

converting surface or curve to Bezier patches/segments produces just 1 patch/segment

Hi, I'm having some issues trying to convert a curve and surface into Bezier segments/patches, the functions GeomConvert_BSplineCurveToBezierCurve GeomConvert_BSplineSurfaceToBezierSurface Even though the curve and surface are rather complex, both just generate 1 curve/patch resp . Perhaps I'm missi

1 reply1 file

issue transparency / z-ordering OCC 6.8.0

Hi All, I'm having issues working with transparency in pythonocc, which is wrapping OCC 6.8.0. In the image you see that the larger box is at 90% transparency, while the smaller darker grey shell lies within the box, but is rendered on top of it. Is there a flag in ( V3d_View? ) that I need to set s

1 reply1 file

cut does not work with imported STL files

Hello, I am using pythonocc. I could successfully cut sphere and box. When I try same code with imported STL files, it does not perform cut. It does not give any error as well. Fude operation with same imported STL files work well. The code and STL files are attached.

1 reply1 file

Problems using PythonOCC with Python2.6

Hello guys, i downloaded and installed PythonOCC like written on the pythonOCC homepage and with simply testing : from OCC import * i got this error: Traceback (most recent call last): File " ", line 1, in from OCC import * File "C:\Python26\lib\site-packages\OCC\Standard.py", line 28, in _Standard

5 replies

Problem with surface normal

Hello everybody! I am trying to find out the normal vectors in two planar surfaces. These surfaces construct the end parts of a blade turbine models (the uploaded image). Apparently, the surfaces normals are (-1,0,0) for the first one and (1,0,0) for the second. The BRepLProp_SLProps.Normal() functi

4 replies

Handle_Poly_Triangulation doesn't have Nodes() and Triangles() attributes!

Hello Everybody! I triangulated a face using BRepMesh_IncrementalMesh and BRepTool_Triangulation methods as follows: MyMesher=BRepMesh_IncrementalMesh(Surf1Shape,0.5) MyMesher.Perform() MyMesher.Update(Surf1Shape) ff=MyMesher.IsDone() Face1Tri=BRep_Tool_Triangulation(TheSurf1,T) Everything OK till h

1 reply