You can add "drive" to a sketch and read position of every vertex, with a simple script. To show things as simple as possible, I made an example with 3 lines: This script will move angle constraint from 10 deg to 40 deg with 1 deg step, and print position of Vertex3:NewJoker wrote: ↑Fri May 20, 2022 2:05 pm
Yes, the sketcher with its constraints, DOF handling and mouse dragging can be very useful for simple geometric analysis of a mechanism but won't provide you the data needed in most cases - positions, velocities and accelerations (not to even mention forces and moments) of points and links belonging to the mechanism throughout its whole range of motion under applied velocity, for example.
That's possible with proper sketches in commercial software: https://www.youtube.com/watch?v=pBczBrM7uq0
Code: Select all
import FreeCAD as App, FreeCADGui as Gui, Part, time
from PySide2 import QtGui,QtCore
class Animation(object):
def __init__(self):
App.Console.PrintMessage('init')
App.ActiveDocument.recompute()
self.timer = QtCore.QTimer()
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.my_update)
self.timer.start(500) #500ms for step, adjust to performance of the PC
self.an = 10
self.end = 40
def my_update(self):
self.an = self.an + 1
App.ActiveDocument.getObjectsByLabel("Sketch")[0].setDatum(6,App.Units.Quantity(str(self.an)+' deg')) #angle Constraint7 (6+1, because Sketcher starts counting from 1 not 0)
App.ActiveDocument.recompute()
p1 = App.ActiveDocument.getObjectsByLabel("Sketch")[0].Shape.Vertexes[2].Point #Sketch.Vertex3
print(str(self.an), str(p1))
if self.an > self.end:
self.stop()
def stop(self):
self.timer.stop()
animation = Animation()
Code: Select all
...
18:14:40 21 Vector (-24.33471798228596, 37.3432170597076, 0.0)
18:14:41 22 Vector (-24.984263737107035, 37.08735418248287, 0.0)
18:14:41 23 Vector (-25.629245140037973, 36.820194137900906, 0.0)
...
Also there is another more fancy tool: Assembly3 skeleton sketch https://github.com/realthunder/FreeCAD_ ... ton-Sketch
It works in 3D, and has dedicated tool for tracing vertices.