(the info for my version, etc. is at the bottom but essentially I'm using the latest git)
I'm working on a project where I need to essentially wrap a honeycomb pattern around a cylinder. I have already done this successfully manually by creating a hexagonal sketch, making a clone of it many times on the y axis, then cloning the results of that and setting constraints appropriately between the two to make the offset for the pattern and then finally using Draft:Polar Array to wrap it around the center of the cylinder, and then padding the result of that. I realized I have to do this programmatically because I will have to replicate this for various cell wall thicknesses as well as widths of the overall cell over the course of this project. So I tried looking up some tutorials on what I should do and everything I've found that does half of what I need seems to require things that don't seem to be in the API any longer("draftlibs" for example). Where can I find some working examples of doing each of these tasks that will work with my version?
OS: "Gentoo Base System release 2.2"
Word size of OS: 64-bit
Word size of FreeCAD: 64-bit
Version: 0.17.8140 (Git)
Build type: Release
Branch: (HEAD detached at refs/git-r3/HEAD)
Hash: 7e310b2444edc3aef68aef9451c5eac853a4e8f7
Python version: 2.7.10
Qt version: 4.8.7
Coin version: 3.1.3
OCC version: 6.9.0
honeycomb and a cylinder
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 11
- Joined: Tue Jan 26, 2016 5:46 pm
Re: honeycomb and a cylinder
What you have been done once manually could also be repeated easily by a thorough parametric design.
Think about a draft polar array of a draft ortho array. So instead of manually copying clones of the hexagonal sketch, you can use a draft ortho array for the same purpose.
For further automation a spreadsheet can be used to define the radius of the cylinder and the number of the hexagons wrapped around it. Give your numbers an alias name in the spreadsheet. These numbers can then be used in the sketch of the hexagon, the placement of the sketch and in the draft-array. So at the end, you just change a number in the spreadsheet and get an updated model.
If going for a macro, You maybe interested in this forum thread: viewtopic.php?f=8&t=14710
Macros to have a look into are published here: http://www.freecadweb.org/wiki/index.ph ... os_recipes
Here are code snippets: http://www.freecadweb.org/wiki/index.ph ... e_snippets
Introduction to part scripting: http://www.freecadweb.org/wiki/index.ph ... _scripting
The FreeCAD-documentation for python-functionality is not very up to date. In a lot of cases I do some steps in the python console and have a look what functions and properties are available for my created object. Have a look here for the general workflow: http://www.freecadweb.org/wiki/index.ph ... ng_FreeCAD
You can execute your macro in the python console with and have later access to your created objects. Just type the object name in the python-console and add a dot!
For draft-functionality it is best to have a look into the draft python-files directly. I am using "Geany" as a lightweight development environment. It gives you easy access to all functions and definitions for an opened python-file.
Ulrich
Think about a draft polar array of a draft ortho array. So instead of manually copying clones of the hexagonal sketch, you can use a draft ortho array for the same purpose.
For further automation a spreadsheet can be used to define the radius of the cylinder and the number of the hexagons wrapped around it. Give your numbers an alias name in the spreadsheet. These numbers can then be used in the sketch of the hexagon, the placement of the sketch and in the draft-array. So at the end, you just change a number in the spreadsheet and get an updated model.
If going for a macro, You maybe interested in this forum thread: viewtopic.php?f=8&t=14710
Macros to have a look into are published here: http://www.freecadweb.org/wiki/index.ph ... os_recipes
Here are code snippets: http://www.freecadweb.org/wiki/index.ph ... e_snippets
Introduction to part scripting: http://www.freecadweb.org/wiki/index.ph ... _scripting
The FreeCAD-documentation for python-functionality is not very up to date. In a lot of cases I do some steps in the python console and have a look what functions and properties are available for my created object. Have a look here for the general workflow: http://www.freecadweb.org/wiki/index.ph ... ng_FreeCAD
You can execute your macro in the python console with
Code: Select all
execfile("my path to the macro")
For draft-functionality it is best to have a look into the draft python-files directly. I am using "Geany" as a lightweight development environment. It gives you easy access to all functions and definitions for an opened python-file.
Ulrich