{"id":13626921,"url":"https://github.com/jpmlt/freecad-cadquery2-workbench","last_synced_at":"2025-04-16T19:30:54.392Z","repository":{"id":217082019,"uuid":"423076754","full_name":"jpmlt/freecad-cadquery2-workbench","owner":"jpmlt","description":"Workbench to render CadQuery 2.x script in FreeCAD","archived":false,"fork":false,"pushed_at":"2021-10-31T07:27:45.000Z","size":748,"stargazers_count":25,"open_issues_count":4,"forks_count":5,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-11-08T17:47:50.279Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jpmlt.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-10-31T06:58:48.000Z","updated_at":"2024-10-24T13:46:28.000Z","dependencies_parsed_at":null,"dependency_job_id":"c70daf92-5a87-4f90-a043-eb8482ce8bff","html_url":"https://github.com/jpmlt/freecad-cadquery2-workbench","commit_stats":null,"previous_names":["jpmlt/freecad-cadquery2-workbench"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpmlt%2Ffreecad-cadquery2-workbench","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpmlt%2Ffreecad-cadquery2-workbench/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpmlt%2Ffreecad-cadquery2-workbench/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jpmlt%2Ffreecad-cadquery2-workbench/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jpmlt","download_url":"https://codeload.github.com/jpmlt/freecad-cadquery2-workbench/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249268547,"owners_count":21240940,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T22:00:25.461Z","updated_at":"2025-04-16T19:30:53.728Z","avatar_url":"https://github.com/jpmlt.png","language":"Python","funding_links":[],"categories":["Editors and IDEs"],"sub_categories":[],"readme":"CadQuery 2.x Workbench for FreeCAD\n=======================\n![GitHub version](https://d25lcipzij17d.cloudfront.net/badge.svg?id=gh\u0026type=6\u0026v=0.0.1\u0026x2=0)\n![License](https://img.shields.io/badge/license-Apache2.0-lightgrey.svg)\n\n## Introduction\n\nThis is a FreeCAD Workbench to render CadQuery 2.x script in FreeCAD.\n\n\u003cimg src=\"docs/screenshot1.png\" alt=\"Screenshot\" width=\"70%\" /\u003e\u003cbr/\u003e\n\n\u003cimg src=\"docs/screenshot2.png\" alt=\"Screenshot\" width=\"70%\" /\u003e\n\n## Notable features\n* Dedicated CadQuery Python scripting editor\n  * It uses default FreeCAD python editor settings: Font, Font size, python Color Scheme\n* Dedicated Toolbar: File Management, Script exectution, ...\n* Cadquery Variables Editor\n* For detailed instruction see [Instruction](#usage)\n\n## Installation\n\nAs the easiest way to install CadQuery and its dependencies is using conda, it is recomanded to install both FreeCAD and CadQuery into a dedicated conda environment. Then download the [latest released version]() of this workbench, extract the archive file and copy the entire extracted directory to FreeCAD's `Mod` directory on your environment.\n\n#### Install cadQuery 2.x and FreeCAD in a conda environment\nFor more details regarding conda installation refer to [CadQuery](https://github.com/CadQuery/cadquery) and [FreeCAD](https://wiki.freecadweb.org/Conda)\n```\n# Set up a new environment\nconda create -n freecad_cadquery\n\n# Activate the new environment\nconda activate freecad_cadquery\n\n# Install both CadQuery and FreeCAD\nconda install -c conda-forge freecad\nconda install -c conda-forge -c cadquery cadquery=master\n```\n\n#### Seting up your conda environment\nTo preserve your system settings, it is suggested to create a dedicated `home` folder in your conda environment and to set FreeCAD to use this folder.\nFor more details, refer to [Conda Managing environments](https://docs.conda.io/projects/conda/en/latest/user-guide/tasks/manage-environments.html) and [FreeCAD Start up and Configuration](https://wiki.freecadweb.org/Start_up_and_Configuration).\n```\n# Create a home dir inside the conda environment\ncd $CONDA_PREFIX\nmkdir ./home\n\n# Set environment variables\nmkdir -p ./etc/conda/activate.d\nmkdir -p ./etc/conda/deactivate.d\ntouch ./etc/conda/activate.d/env_vars.sh\ntouch ./etc/conda/deactivate.d/env_vars.sh\n```\nEdit `./etc/conda/activate.d/env_vars.sh` as follows:\n```\n#!/bin/sh\n\nexport HOME=$CONDA_PREFIX/home\nexport FREECAD_USER_HOME=$CONDA_PREFIX/home\n```\nTo apply the changes, deactivate from the environment then activate it again.\u003cbr/\u003e\nThen run FreeCAD, so that it will create in your new environment home folder the `.FreeCAD/Mod` directory.\n```\nconda deactivate\nconda activate freecad_cadquery\n\ncd $Home\nfreecad\n```\nNote: having create a dedicated home folder, at first execution FreeCAD set all defaults settings. If you have FreeCAD already installed in your computer, and have already made some user setup, there are 3 configuration files you may find useful to copy from your system installation into your new conda environment.\n\nUnder `~/.FreeCAD` files `system.cfg` and `user.cfg`\n\nUnder `~/.config/FreeCAD` file `FreeCAD.conf`\n\n#### Install this cadquery2-workbench\n* Download the [latest released version]() of this workbench\n* Extract the archive file\n* Copy the entire extracted directory to FreeCAD's `Mod` directory on your environment.\n\n## Usage\n\n#### Activate CadQuery workbench\nIn FreeCAD, select CadQuery workbench from the Workbench dropdown list in the Workbench toolbar.\nIt opens CadQuery Editor and CadQuery variables Editor panes on the right DockWidget of FreeCAD.\u003cbr/\u003e\nTo Show/Hide the Editor, use the standard FreeCAD `View`-\u003e`Panels` from the menu.\n\n\n#### Commands\n\u003cimg src=\"docs/toolbar.png\" alt=\"ToolBar\" width=50%/\u003e\n\n* File Management\n  * `New Scirpt (Alt+Shift+N)` Start a new script from a template file\n  * `Open Script (Alt+Shift+O)` Open a pyton script file\n  * `Save Script (Alt+Shift+S)` Save current script\n  * `Save Script As` Open a Save As dialog box to save current script\n* Script Commands\n  * `Validate Script (F4)` Execute cadquery script but do not display the objects in FreeCAD. Use it to validate your script.\n  * `Execute Script (F9)` Execute cadquery script and display objects in FreeCAD. Variables use values from the Variables Editor. If you add a new variable in the script and run again Execute, the new variable is not added into the Variables Editor.\n  * `Rebuild Script (F5)` Rebuild and execute the script. Variables Editor is reset from the values in the script.\n  * `Toggle Debug Script` when toggle on, `debug()` objects will be displayed in FreeCAD.\n* Others\n  * `Clear Output (Alt+Shift+C)` clears all output from the Report View. This comes in handy during a heavy script debugging session.\n  * `Settings` open the Settings dialog box, see below for details.\n  * `Examples` Holds a list of all the CadQuery examples that are bundled with this workbench. They're a great tool for learning CadQuery. Those scripts come from [CadQuery](https://github.com/CadQuery/cadquery) project.\n  * `Expand Tree Groups` when using group in the `show_object()` method, FreeCAD collapse all the groups. This button expand all groups in the Tree View.\n\n\n#### User Settings\n\u003cimg src=\"docs/settings.png\" alt=\"Settings\" width=35%/\u003e\u003cbr/\u003e\n\n* `Key-binding` you can set your own shortcuts to **Execute**, **Validate** or **Rebuild** commands.\n* `Execute on Save` Automatically Rebuild a script every time you save it. The default is **False**.\n* `Show Line Numbers` show/hide the line numbers in cadquery editor. The default is **True**.\n* `Allow Reload` automatically reloads and executes the open script when an external change is made. This allows users to use their preferred code editor instead of the one included with this workbench. The default is **False**. When **False** is set, user will be prompt to reload or not the file when a change on disk is made.\n* Note: You may need to restart FreeCAD to have above new settings taken in count.\n* `Dock Widget Layout` allow to change the FreeCAD dock widgets layout for more convenience.\n\n#### Python editor\nUse the standard [FreeCAD Editor settings](https://wiki.freecadweb.org/Preferences_Editor#Editor) to change the Font, Font size and python color scheme.\n\n#### Showing Objects\nYou need use the `show_object(cq_obbject [, options])` method to render your model in FreeCAD\n* first parameter is a valid CadQuery object\n* optional options:\n  * name: `String` the name of the part\n  * group: `String` in FreeCAD you can organize your parts within Groups, providing a group name\n  * rgba (you can use one of those to define it):\n    * `CadQuery Color` see [Assembly colors](https://cadquery.readthedocs.io/en/latest/assy.html#assembly-colors) for a list of valid color name\n    * `String` `css style` like '#RRGGBB' or '#RRGGBBAA' with RR,GG,BB,AA hexa in range [0-255]\n    * `Tuple` (r, g, b, a) with r,g,b in range [0-255] and a in range [0.0-1.0]\n    * alternatively, instead of rgba you can provide separately both options\n      * color: as a `Tuple` (r, g, b) in range [0-255]\n      * alpha: `Float` in range [0.0-1.0]\n\n#### Debugging Objects\nIt is possible to do visual debugging of objects by using the `debug()` function to display an object instead of `show_object()`.\n```python\nimport cadquery as cq\n\nresult = cq.Workplane().box(10, 10, 10)\n\nhighlight = result.faces('\u003eZ')\n\nshow_object(result, name='box')\ndebug(highlight)\n```\nObjects displayed with `debug()` are colored in red and have their alpha set so they are semi-transparent. This can be useful for checking for interference, clearance, or whether the expected face is being selected, as in the code above.\nOptional `name` and `group` can be provided.\nYou have to toggle on the `Toggle Debug Script` \u003cimg src=\"docs/toggle_debug.svg\" alt=\"Toggle Button\" width=2%/\u003e tool button in CadQuery Editor to display `debug()` objects.\n\n#### Script variables\nThis workbench uses the following rules to find input variables for a script:\n  * only top-level `int` and `float` statements are considered\n  * only assignments of constant values to a local name are considered.\n\nFor example, in the following script:\n```python\nh = 10\nw = 2.0\nd = h / 2.0\nfoo = 'bar'\n\ndef some_function():\n    x = 1\n```\n`h` and `w` will be overridable script variables, but `d`, `foo` and `x ` are not.\n\nWe can assign a description of the variables in 2 different way:\n```python\n# Defines the cqvar(value, descrition) function\nfrom freecad.cadquery2workbench.cq_variables import cqvar\nsize = cqvar(10, 'Cube Size')       # set variable value and his description\nthickness = 1.25                    # Another way to setup a variable and his description\ndescribe_parameter(thickness,'Walls Thickness')\n```\n\u003cimg src=\"docs/cq_variables_editor.png\" alt=\"Variables Editor\" width=50%/\u003e Change values then press `Enter` to update your model.\n\n## License\n\nCadQuery 2.x Workbench for FreeCAD is licensed under the terms of the [Apache Public License, version 2.0](http://www.apache.org/licenses/LICENSE-2.0).\n\n## Acknowledgment\nThis workbench is a fork of the [cadquery-freecad-module](https://github.com/jmwright/cadquery-freecad-module) from **Jeremy Wright**, that was design for CadQuery v1.x\n\nA great thanks to all contributors to the great tool that is CadQuery and in particular to **David Cowden**, **Adam Arbanczyk** and **Jeremy Wright**.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpmlt%2Ffreecad-cadquery2-workbench","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjpmlt%2Ffreecad-cadquery2-workbench","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjpmlt%2Ffreecad-cadquery2-workbench/lists"}