Difference between revisions of "Part Module"

From FreeCAD Documentation
Jump to: navigation, search
Line 6: Line 6:
  
 
To create primitives over the user interface switch to the Part design workbench and click on 'Create primitives...' menu item under the Part menu. This opens a dialog where your are able to define the type of primitive and define further properties depending on the type you have chosen. Then click on the 'Create' button to create such an element.
 
To create primitives over the user interface switch to the Part design workbench and click on 'Create primitives...' menu item under the Part menu. This opens a dialog where your are able to define the type of primitive and define further properties depending on the type you have chosen. Then click on the 'Create' button to create such an element.
 +
 +
== Command line ==
 +
 +
There are two further primitives that can only be created over the command line. So far there does not exists a user interface for them.
 +
 +
To create a line element switch to the Python console and type in
 +
 +
<code python>
 +
import Part,PartGui
 +
doc=App.newDocument()
 +
# add a line element to the document and set its points
 +
l=Part.line()
 +
l.setStartPoint((0.0,0.0,0.0))
 +
l.setEndPoint((1.0,1.0,1.0))
 +
doc.addObject("Part::Line","Line").Line_=l
 +
doc.recompute()
 +
</code>
 +
 +
A circle can be created in a similar way
 +
 +
<code python>
 +
import Part
 +
doc = App.activeDocument()
 +
c = Part.circle() # create a circle object with undefined radius
 +
c.setRadius(10) 
 +
f = doc.addObject("Part::Circle", "Circle") # create a document with a circle feature
 +
f.Circ = c # Assign the circle object to the Circ property
 +
doc.recompute()
 +
</code>

Revision as of 10:33, 31 January 2008

The Part module deals with the CAD data structures.

At the moment the CAD capabilites of FreeCAD are very limited but it already supports a few basic CAD primitives like plane, box, cylinder, cone, sphere and torus. For all these primitives a user interface exists to create such elements. Moreover there are several additional primitives for which no user interface exists but that can be created over their Python interface. These primitives are circle and line. More primitives will follow.

User interface

To create primitives over the user interface switch to the Part design workbench and click on 'Create primitives...' menu item under the Part menu. This opens a dialog where your are able to define the type of primitive and define further properties depending on the type you have chosen. Then click on the 'Create' button to create such an element.

Command line

There are two further primitives that can only be created over the command line. So far there does not exists a user interface for them.

To create a line element switch to the Python console and type in

import Part,PartGui doc=App.newDocument()

  1. add a line element to the document and set its points

l=Part.line() l.setStartPoint((0.0,0.0,0.0)) l.setEndPoint((1.0,1.0,1.0)) doc.addObject("Part::Line","Line").Line_=l doc.recompute()

A circle can be created in a similar way

import Part doc = App.activeDocument() c = Part.circle() # create a circle object with undefined radius c.setRadius(10) f = doc.addObject("Part::Circle", "Circle") # create a document with a circle feature f.Circ = c # Assign the circle object to the Circ property doc.recompute()