Hi there,
I' have a small project, but I'm struggling setting my ideas in to reality i hope the board can help me.
About me:
I'm a design and measurement engineer normally using Fusion 360/Catia and so on...
I have a small knowledge about python programming.
For a project I need a cone as STEP file which has changeable parameters for diameter 1 and 2. An External program should deliver the two parameters and the script should generate a STEP file.
I tried to use FreeCAD 0.20 and its opened Python libraries.
As IDE I use PyCharm.
I opened a new project and used "C:\Program Files\FreeCAD 0.20\bin\python.exe" as the interpreter.
I used \bin is also as library source.
I'm helpless to write now the code for my cone with the two parameters.
The code should work like (without visualisation):
• new body
• new drawing
• points and lines for the cone
• extrude the body with 360° rotation
• export as STEP
I go thru the hole Wiki for FreeCad but every try was setback for me.
I'm also not sure If my Idea can work with FreeCAD.
Is there anyone can help me? To get me to the right direction?
I'm theankfull fot every food for thought.
Generate and save cone as STEP with Python and PyCharm
Forum rules
Be nice to others! Respect the FreeCAD code of conduct!
Be nice to others! Respect the FreeCAD code of conduct!
-
- Posts: 1
- Joined: Mon Jul 04, 2022 11:50 am
-
- Veteran
- Posts: 3180
- Joined: Thu Sep 24, 2020 10:31 pm
- Location: Hawaii
- Contact:
Re: Generate and save cone as STEP with Python and PyCharm
Run the following script.py:
with
Use your own directory of course.
Code: Select all
import FreeCAD as App
doc = App.newDocument("ConeDoc")
#doc = App.ActiveDocument
body = doc.addObject('PartDesign::Body','Body')
cone = doc.addObject('PartDesign::AdditiveCone','Cone')
bc = body.addObject(cone)
doc.recompute()
cone.Radius1 = 2
cone.Radius2 = 5
cone.Height = 10
dir = '/Users/ed/FreeCAD/'
Part.export([body],dir + 'Body.step')
Code: Select all
freecadcmd script.py