STL files are best used to trace over. They are typically more trouble than they are worth.
They can be imported and converted to a solid. But, there is no parametric info in a STL file. The result of the import, if successful, is a solid, devoid of any parametric information.
The steps to import an STL file:
- Use File>Import to import the STL file Or, use Mesh workbench Import Mesh
- use tools in Mesh workbench to verify it is a manifold file Mesh workbench Analyze, Fill hole, etc. as needed.
- Use Mesh workbench Decimate Reduce as far below 100k triangles as possible.
- use Part workbench Convert to shape
- use Part WB Check geometry to make sure it produced a valid shape
- use Part WB Convert to solid
- use Part WB Check geometry to make sure it produced a valid solid
- if all that was successful, the solid can be used directly with Part workbench
- to use it with Part Design workbench, create a Part Design Body
- drag-n-drop the solid into the Body This will create a Basefeature. It is a solid that you can add to or cut away from with Part Design tools.
Sometimes when importing geometry from in DXF or other formats, it defines geometry that should never change. It may be that the geometry represents the dimensions of known product. Once convertd to a sketch, constraining can be laborious. THis can be avoided by locking all geometry in the sketch.
- Select the sketch in the tree view
- Press Ctrl+Shift+P
- In the python console (view menu -> panels -> python console) enter:
- import Sketcher
- for idx,geo in enumerate(obj.Geometry):obj.addConstraint(Sketcher.Constraint("Block",idx))
- This adds a Block Constraint to all geometry elements in the sketch.
- Select the edge in the 3D view.
- Press Ctrl+Shift+P.
- In the python console (view menu -> panels -> python console) enter: elt.Curve.Radius
- Select the edge in the 3D view.
- Press Ctrl+Shift+P.
- In the python console (view menu -> panels -> python console) enter: elt.Length
- For example, to use the z value of the Body placement
- Body.Placement.Base.z
- In the python console, enter: App.ActiveDocument.Sketch.detectMissingPointOnPointConstraints(100)
- This launch the detection process, returns the number of missing constraints.
- In the python console, enter: App.ActiveDocument.Sketch.MissingPointOnPointConstraints
- This returns a Python List of tuples that are the missing coincidences found at the previous step
- In the python console, enter: App.ActiveDocument.Sketch.OpenVertices
- This return a Python list of tuples that are the open vertexes.
Most discussions make this far more complicated than it is.
There are a few things to keep in mind:
- The chosen font must be viable for use.
- It must have closed profiles and no crossing or intersecting lines.
If working in Part Design, you can't pocket through your solid because letters like R, O, D, etc. are going to break the single solid rule. A Pocket into the surface, but not through, or a Pad is fine.
Many videos show various machinations that are out of date, since you can just drag the Shapestring into the Body, position it (grossly with Transform, then fine tune with the properties of the Shapestring), then Pad or Pocket.
Given Sketch has a constraint 'Constraint9' that has been named 'abc' the following can be used in an expression.
Sketch.Constraints.abc
But what is the syntax for an unnamed constraint?
Sketch.Constraints.Constraint9
Fails to parse.
Answer:
Sketch.Constraints[8]
Note: Look at the Properties view and see that the Constraints property is a Python list
In the Python console enter:
m = FreeCADGui.Selection.getSelection()[0].Shape.MatrixOfInertia m
Result:
Matrix ((61.7946,4.9086,-11.5488,0),(4.9086,66.5861,-18.4738,0),(-11.5488,-18.4738,102.199,0),(0,0,0,1))
In the Python console enter:
mass = FreeCADGui.Selection.getSelection()[0].Shape.CenterOfMass mass
Result:
Vector (21.63548536771986, 35.499731244404686, 36.656887161270994)
In the Python console enter:
a = FreeCADGui.Selection.getSelection()[0].Shape.Area a
Result: 106.4468
Assuming there is a feature in the Tree view with the label Face001
=Face001.Shape.Area
Assume the document is named: Unnamed Assume the objects label in the Treeview is: Face001
In the Python console enter:
Gui.Selection.addSelection('Unnamed','Face001')
Result:
The first selection object is Face001.
m = FreeCADGui.Selection.getSelection()[0].Shape
Assume the document is named: Unnamed Assume the objects label in the Treeview is: Face001
In the Python console enter:
Gui.Selection.addSelection('Unnamed','Face001')
m = FreeCADGui.Selection.getSelection()[0].Shape
ar=m.Area
App.ActiveDocument.Spreadsheet.set("A2", str(ar))
Result:
After recompute, cell A2 of the spreadsheet is the area of Face001.
In the Python console enter:
FreeCAD.ActiveDocument.Spreadsheet.getContents('A2')
A2 is the cell in question, this can be replaced with the alias of the cell as well.
FreeCAD.ActiveDocument.Spreadsheet.get('A2')
A2 is the cell in question, this can be replaced with the alias of the cell as well.
- If the solid is in a container, drag it out into the tree
- Use one of the following to move the solid to the origin
- Use KicadSteup workbench Reset origin
(All of the above can be found in Addon manager.)
Now, the solid can be dragged into a Body and not revert to it's original location in space.