diff --git a/.gitignore b/.gitignore index ba0430d..8b29db5 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ -__pycache__/ \ No newline at end of file +__pycache__/ +.idea/ \ No newline at end of file diff --git a/PythonOCC/add_function_box_example.py b/PythonOCC/add_function_box_example.py index 9d54f4c..acf29af 100644 --- a/PythonOCC/add_function_box_example.py +++ b/PythonOCC/add_function_box_example.py @@ -1,7 +1,8 @@ -class BrepPrimAPINodeBase(PythonOCCNodeBase): #The parent class of the box - color = '#aabb44' #The color atributed to the parent class +class BrepPrimAPINodeBase(PythonOCCNodeBase): # The parent class of the box + color = '#aabb44' # The color attributed to the parent class -class Box_Node(BrepPrimAPINodeBase): #explicit class name(parent class name) + +class Box_Node(BrepPrimAPINodeBase): # explicit class name(parent class name) """ Generates box_________- o_Width_______________- @@ -9,34 +10,33 @@ class Box_Node(BrepPrimAPINodeBase): #explicit class name(parent class name) o_Height______________- #it indicates what inputs are expected """ init_inputs = [ - NodeInputBP(dtype=dtypes.Data(size='s')), #number of inputs ollowing what your function needs + NodeInputBP(dtype=dtypes.Data(size='s')), # number of inputs ollowing what your function needs NodeInputBP(dtype=dtypes.Data(size='s')), NodeInputBP(dtype=dtypes.Data(size='s')), ] init_outputs = [ - NodeOutputBP(), #output of the node + NodeOutputBP(), # output of the node ] - title = 'box' #the title name of your node - + title = 'box' # the title name of your node def apply_op(self, elements: list): - width = elements[0] #your inputs + width = elements[0] # your inputs length = elements[1] height = elements[2] - from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox #import of the method + from OCC.Core.BRepPrimAPI import BRepPrimAPI_MakeBox # import of the method from OCC.Core.gp import gp_Pnt - box = BRepPrimAPI_MakeBox(gp_Pnt(), width, length, height).Shape() #the function to get a result + box = BRepPrimAPI_MakeBox(gp_Pnt(), width, length, height).Shape() # the function to get a result - return box #the output of the node + return box # the output of the node -BRepPrimAPI_nodes = [ #add the node to the list if its family +BRepPrimAPI_nodes = [ # add the node to the list if its family Box_Node, ] export_nodes( - *BRepPrimAPI_nodes, #specified the family nodes to export and to make available in Ryven -) \ No newline at end of file + *BRepPrimAPI_nodes, # specified the family nodes to export and to make available in Ryven +) diff --git a/README.md b/README.md index 8786691..20c65fe 100644 --- a/README.md +++ b/README.md @@ -1,33 +1,42 @@ # Pythonocc-nodes-for-Ryven -Pythonocc nodes for Ryven - +Pythonocc nodes package for Ryven. Here a way to work on Pythonocc with a node editor, Ryven in that case. To get it functional you will have to execute Ryven in an environment where pythonocc is installed. -**Install Ryven**: https://github.com/leon-thomm/Ryven +### Installation + +Prerequisites: + +1. Ryven: https://github.com/leon-thomm/Ryven +2. Anaconda: https://docs.anaconda.com/anaconda/install/index.html +3. pythonocc-core: https://anaconda.org/conda-forge/pythonocc-core +4. pythonocc-utils: https://github.com/tpaviot/pythonocc-utils -**Install Pythonocc** : https://github.com/tpaviot/pythonocc-core +### Usage -You just have to import the `Nodes.py` file in Ryven, then all nodes are available under the right-click of the mouse. +You just have to import the `nodes.py` file in Ryven. + +### Examples + +Here a small example: https://www.youtube.com/watch?v=lUNYstrfvmg -Here a small example of a definition : -https://www.youtube.com/watch?v=lUNYstrfvmg ![exemple_tutogithub](https://user-images.githubusercontent.com/81742654/131111996-7d586497-ecb0-4908-9da7-b8fd9ba72055.jpg) ![exemple_tutogithub_1](https://user-images.githubusercontent.com/81742654/131112006-300cb113-ad9c-406c-9bd4-4ce6629f54ee.jpg) -You can load this project saved in this file : `demo_example.json` - -It's just a beginning to explore the possibilities given by matching the two, I've just coded simple functions to see how it works and how it should be to perform complex operations. +You can load this project from `demo_example.json` another example: ![torus_example](https://user-images.githubusercontent.com/81742654/134700246-54ce5366-cb8f-43c1-acd9-fdd091cd802f.jpg) -# Contribute ! -The nodes are of course open for contribution, as there are thousands of functions in OpenCascade and thousands of way to developp properly the nodes! +It's just a beginning to explore the possibilities given by matching the two, I've just coded simple functions to see how it works and how it should be to perform complex operations. + +### Contribute ! -The functions yet implemented in the nodes.py file are : +The nodes are of course open for contribution, as there are thousands of functions in OpenCascade and thousands of ways to develop properly the nodes! + +The functions currently implemented are: `Gp_nodes = Pnt_Node, DeconstructPnt_Node, PointZero_Node,Dir_Node, Vec_Node, DX_Node, DY_Node, DZ_Node,Ax2_Node, Pln_Node, Trsf_Node, Move2pts_Node, MidPoint_Node,` @@ -51,7 +60,6 @@ The functions yet implemented in the nodes.py file are : `DataExchange_nodes = ExportStep_Node, ImportStep_Node, ExportStl_Node, ImportStl_Node,` -Each "nodes" family is a class with a color attributed. Node's name are nearly the same than in Pythonocc - -To add a function from Pythonocc you have to generate a code as in the `add_function_box_example.py` file +Each "nodes" family is a class with a color attributed. Node names are correspond to the functions from Pythonocc. +To add a function from Pythonocc you have to generate a code as shown in `add_function_box_example.py`.