Macro Shake Sketch/en

Description
Shake a sketch in order to discover its unconstrained parts. Enter edit mode for a sketch and launch the macro. The macro will add a random noise on all sketch points. The sketch is then solved, constrained parts will retain their position, free parts will move.

But be careful working on a copy of your file because the macro "dismantles all" to display and you may start over.

Install
Visible in Addon manager, but install is broken. For now only option is to manually install, but you have to take the code from "view source" from this wiki. The full code is there, but it does not render on the wiki.

Script
ToolBar Icon

Macro Shake_Sketch.py

QMessageBox.Cancel, QMessageBox.Ok)       shake_it = reply == QMessageBox.Ok        if not shake_it:            toggle_constraints(sketch, to_virtual)

if shake_it: nbr_moves = 0 for i in range(sketch.GeometryCount): did_move = move_points(sketch, i, sigma) if did_move: nbr_moves += 1

msg = 'Did {} moves. Sketch has a total of {} geometry entities.\n\n' msg = msg.format(nbr_moves, sketch.GeometryCount) open_verts = sketch.OpenVertices if open_verts: if len(open_verts) == 1: ov, form = 'one', 'vertex' else: ov, form = len(open_verts), 'vertices' msg += 'Sketch has {} open {}.'.format(ov, form) msg += ('\nA sketch with open vertices'               ' cannot be used to create a solid.') else: msg += 'Sketch is free from open vertices.'

msg += ('\n\nMenu: "Sketch/Validate Sketch..." can be used\n'           'for additional info about sketch status.') _ = QMessageBox.information(None, title, msg) toggle_constraints(sketch, to_virtual) print('Macro finished.')