Skip to content

Commit

Permalink
improved README and node definition example
Browse files Browse the repository at this point in the history
  • Loading branch information
leon-thomm committed Dec 1, 2021
1 parent 1d03b2b commit 90d9c98
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 31 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
__pycache__/
__pycache__/
.idea/
28 changes: 14 additions & 14 deletions PythonOCC/add_function_box_example.py
Original file line number Diff line number Diff line change
@@ -1,42 +1,42 @@
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_______________-
o_Length______________- #the text that will appear when your mouse will stay on the node in Ryven
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
)
*BRepPrimAPI_nodes, # specified the family nodes to export and to make available in Ryven
)
40 changes: 24 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -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,`

Expand All @@ -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`.

0 comments on commit 90d9c98

Please sign in to comment.