Part TopoShape: Difference between revisions

From FreeCAD Documentation
(Any object created by importing a STEP, BREP, and similar solid format files.)
(Marked this version for translation)
Line 32: Line 32:
* Any object created by importing a STEP, BREP, and similar solid format files.
* Any object created by importing a STEP, BREP, and similar solid format files.


== Scripting ==
== Scripting == <!--T:11-->


<!--T:12-->
{{Emphasis|See also:}} [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]], and [[scripted objects|scripted objects]].
{{Emphasis|See also:}} [[FreeCAD Scripting Basics|FreeCAD Scripting Basics]], and [[scripted objects|scripted objects]].


<!--T:13-->
All objects derived from {{incode|Part::Feature}} will have a [[Part TopoShape|Part TopoShape]], which is normally accessible from its {{incode|Shape}} attribute.
All objects derived from {{incode|Part::Feature}} will have a [[Part TopoShape|Part TopoShape]], which is normally accessible from its {{incode|Shape}} attribute.
</translate>
</translate>
Line 47: Line 49:
<translate>
<translate>


<!--T:14-->
A TopoShape has many attributes (variables) and methods that contain information about it, and which allow doing operations with it. These variables and methods can be tested in the [[Python_console|Python console]].
A TopoShape has many attributes (variables) and methods that contain information about it, and which allow doing operations with it. These variables and methods can be tested in the [[Python_console|Python console]].
</translate>
</translate>
Line 62: Line 65:
<translate>
<translate>


<!--T:15-->
For a full list of attributes and methods, consult the [[Source_documentation|source documentation]], and the [[Std_PythonHelp|Std PythonHelp]] tool.
For a full list of attributes and methods, consult the [[Source_documentation|source documentation]], and the [[Std_PythonHelp|Std PythonHelp]] tool.



Revision as of 08:29, 11 January 2020

Introduction

A Part TopoShape, or formally a Part::TopoShape, is a class that defines a parametric topological shape in the software. Objects in the document that show something in the 3D view normally have a TopoShape.

The topological shapes, as well as their methods, are defined by the OpenCASCADE Technology kernel (OCCT). FreeCAD uses these shapes, and builds App DocumentObjects around them.

Simplified diagram of the relationships between the core objects in the program. The Part::TopoShape class is embedded in the Part::Feature object and from there it is propagated to all objects that are derived from it.

How to use

The Part TopoShape is an object that is assigned to some App DocumentObjects.

In particular, the basic object that handles these types of attributes is the Part Feature (Part::Feature class). All objects derived from this class will have access to a Part TopoShape.

Some of the most important objects with Part TopoShape are the following:

Scripting

See also: FreeCAD Scripting Basics, and scripted objects.

All objects derived from Part::Feature will have a Part TopoShape, which is normally accessible from its Shape attribute.

import FreeCAD as App

doc = App.newDocument()
obj = App.ActiveDocument.addObject("Part::Box", "Box")
print(obj.Shape)

A TopoShape has many attributes (variables) and methods that contain information about it, and which allow doing operations with it. These variables and methods can be tested in the Python console.

print(obj.Shape.Area)
print(obj.Shape.BoundBox)
print(obj.Shape.CenterOfMass)
print(obj.Shape.ShapeType)

obj.Shape.check()
obj.Shape.copy()
obj.Shape.exportStep("my_file.step")
obj.Shape.exportStl("my_file.stl")

For a full list of attributes and methods, consult the source documentation, and the Std PythonHelp tool.