A python app for reordering the graph tree from a CATIA V5 product.
⚠️ The layout of this app is heavily biased towards the workflow and needs of my companies' engineering team. Although almost everything can be changed via config files and presets, the apps basic functionality is built to work in the environment of said company.
⚠️ Due to lack of an API based implementation of the reorder graph tree command, the app uses a window based approach. This may result in unexpected behavior when using the app.
Check out the pytia ecosystem:
- pytia (web, repo): The heart of this project.
- pytia-property-manager (web, repo) : An app to edit part and product properties.
- pytia-bounding-box (web, repo): For retrieving the bounding box of a part.
- pytia-reorder-tree (web, repo): Exports the bill of material and data of a product.
- pytia-title-block (web, repo): An app to edit a drawing's title block.
- pytia-quick-export (web, repo): Single file export with useful features.
- pytia-reorder-tree (web, repo): Brings order in your product graph tree.
- pytia-ui-tools (web, repo): A toolbox for all pytia apps.
Table of contents:
- pytia reorder tree
✏️ For a guided installation visit https://pytia.deloarts.com
⚠️ Do not manually install any dependencies. The app installs all required packages on its own.
On the users machine you need to install the following:
When the user starts the app it will automatically install all its requirements. Further the app also updates outdated dependencies if needed. The apps environment will be created in the users appdata-folder: C:\Users\User\AppData\Roaming\pytia\pytia_reorder_tree
Recommended python install options for the user:
python-installer.exe /passive PrependPath=1 Include_doc=0 Include_test=0 SimpleInstall=1 SimpleInstallDescription="python for pytia"
For convenience there is a powershell script that will install the required python version for you, see assets/python_installer.ps1.
All configuration is done via json files inside the resources folder.
You can leave the default configuration if it suits your needs, but you can always copy any default json file, rename (get rid of 'default') it and edit its content.
Example: If you want to change the content of the properties.default.json you have to copy this file, and paste it as properties.json. Then you can edit the content of your newly generated properties-settings file. Same for any other default-resource file.
✏️ For a full description of all default files, see docs/DEFAULT_FILES.md.
Files that are named like settings.sample.json must be copied, renamed and edited. Sample files exists only for you to have a guide, of how the config file must look.
Example: Before you can build the app you have to copy the settings.sample.json and rename it to settings.json. Then you can edit its content to match your requirements.
✏️ For a full description of all sample files, see docs/SAMPLE_FILES.md.
Files without 'default' or 'sample' in their names cannot be changed! Just leave them there, they are needed for the app to work.
To be able to launch the app from within CATIA you need to provide a release folder, where the app and a launcher file are stored. Both files (the app and the launcher) will be created with the _build.py script, and released to the release-folder with the _release.py script.
❗️ Add this release folder to the settings.json file as value of the paths.release key.
❗️ Do not build the app with poetry! This package is not not meant to be used as an import, it should be used as an app.
To build the app and make it executable for the user run the _build.py python file. The app is only built if all tests are passing. The app will be exported to the _build-folder. Additionally to the built python-file a catvbs-file will be exported to the same build-folder. This file is required to launch the app from within CATIA, see the next chapter.
✏️ You can always change the name of the build by editing the value from the files.app key of the settings.json.
✏️ The reason this app isn't compiled to an exe is performance. It takes way too long to load the UI if the app isn't launched as python zipfile.
To release the app into the provided release folder run the _release.py script.
To run the app from within CATIA, add the release-folder to the macro-library in CATIA. CATIA will recognize the catvbs-file, so you can add it to a toolbar.
You can always change the path of the release folder by editing the value from the paths.release key of the settings.json.
⚠️ Once you built and released the app you cannot move the python app nor the catvbs script to another location, because absolute paths will be written to those files. If you have to move the location of the files you have to change the paths in the settings.json config file, build the app again and release it to the new destination.
You can find the documentation in the docs folder.
Use the launcher (a.k.a the catvbs-file) to launch the app. On the first run all required dependencies will be installed:
After the installation you can run the app using the launcher:
The app runs fully automatic:
- It scans the product for existing
group identifiers
and removes them - Then new
group identifiers
will be added by thegroup
property of all children (groups are available since v0.2.4 of the pytia-property-manager). This can be changed in the settings.json - Afterward the app reorders the graph tree by issuing the
reorder graph tree
command - At last all instance numbers are renumbered
The workspace is an optional config file, that can be used to alter the behavior of the app. The workspace file is a yaml-file, which must be saved somewhere in the project directory, where the catia document, from which to manage the properties, is also stored:
your-fancy-project
├─── main.CATProduct
├─── subfolder-A
│ ├─── product-A.CATProduct
│ ├─── part-A-01.CATPart
│ └─── part-A-02.CATPart
├─── subfolder-B
│ ├─── product-B.CATProduct
│ ├─── part-B-01.CATPart
│ └─── part-B-02.CATPart
└─── workspace.yml
As long as the workspace file is located somewhere in the project, and as long as this file is in the same folder, or any folder above the CATProduct file, it will be used.
For a detailed description of the workspace config file, see WORKSPACE_FILE.
The filename of the workspace file can be changed in the settings.json file, see SAMPLE_FILES.
For developing you would, additionally to the system requirements, need to install:
Clone the repo to your local machine:
cd $HOME
New-Item -Path '.\git\pytia-reorder-tree' -ItemType Directory
cd .\git\pytia-reorder-tree\
git clone git@github.com:deloarts/pytia-reorder-tree.git
Or use GitHub Desktop.
❗️ Never develop new features and fixes in the main branch!
The main branch is protected: it's not allowed to make changes directly to it. Create a new branch in order work on issues. The new branch should follow the naming convention from below.
- Use grouping tokens at the beginning of your branch names, such as:
- feature: A new feature that will be added to the project
- fix: For bugfixes
- tests: Adding or updating tests
- docs: For updating the docs
- wip: Work in progress, won't be finished soon
- junk: Just for experimenting
- Use slashes
/
as delimiter in branch names (feature/docket-export
) - Avoid long descriptive names, rather refer to an issue
- Do not use bare numbers as leading parts (
fix/108
is bad,fix/issue108
is good)
Use the issue templates for creating an issue. Please don't open a new issue if you haven't met the requirements and add as much information as possible. Further:
- Format your code in an issue correctly with three backticks, see the markdown guide.
- Add the full error trace.
- Do not add screenshots for code or traces.
If you prefer the environment inside the projects root, use:
poetry config virtualenvs.in-project true
⚠️ Make sure not to commit the virtual environment to GitHub. See .gitignore to find out which folders are ignored.
Install all dependencies (assuming you are inside the projects root folder):
poetry install
Check your active environment with:
poetry env list
poetry env info
Update packages with:
poetry update
Tests are done with pytest. For testing with poetry run:
poetry run pytest
⚠️ Test discovery in VS Code only works when CATIA is running.
Don't forget to install the pre-commit hooks:
pre-commit install
Documentation is done with pdoc3.
To update the documentation run:
python -m pdoc --html --output-dir docs pytia_reorder_tree
For preview run:
python -m pdoc --http : pytia_reorder_tree
On a new revision, do the following:
- Update dependency versions in
- Update dependencies:
poetry update
- Update the version in
- Run all tests:
poetry run pytest
- Check pylint output:
poetry run pylint pytia_reorder_tree/
- Update the documentation:
poetry run pdoc --force --html --output-dir docs pytia_reorder_tree
- Update the lockfile:
poetry lock
- Update the requirements.txt:
poetry export --with dev -f requirements.txt -o requirements.txt
v0.2.1: Run app windowed.
v0.2.0: Add GUI, fix hidden product tab, set iso view, renumber nodes.
v0.1.2: Fix deprecation & logon.
v0.1.1: Run hide from bom
command last.
v0.1.0: Initial commit.
Using VS Code Comment Anchors to keep track of to-dos.