Part TopoShape

From FreeCAD Documentation
Revision as of 20:39, 2 June 2020 by Renatorivo (talk | contribs)

Introduzione

Una Part TopoShape, o formalmente una Part::TopoShape, è una classe che definisce una "forma topologica" parametrica nel software. Gli oggetti del documento che mostrano qualcosa nella vista 3D normalmente hanno una TopoShape.

Le forme topologiche, così come i loro metodi, sono definiti dal kernel OpenCASCADE Technology (OCCT). FreeCAD usa queste forme e crea dei App DocumentObjects attorno ad esse.

Diagramma semplificato delle relazioni tra gli oggetti principali del programma. La classe Part::TopoShape è incorporata nell'oggetto Part::Feature e da lì viene propagata a tutti gli oggetti che ne derivano.

Utilizzo

TopoShape è un oggetto assegnato ad alcuni 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.