Skip to content

Instantly share code, notes, and snippets.

@thehans
thehans / Protractor.py
Created December 1, 2011 04:06
Protractor script for FreeCAD, measures angle between two edges
from FreeCAD import Base
import math
class Protractor:
"""Reports the angle between two edges.
Select the edges and the result will be shown in Report View"""
def __init__(self):
self.firstEdge = None
Gui.Selection.addObserver(self)
FreeCAD.Console.PrintMessage("Select any 2 edges\n")
@thehans
thehans / MeasureCircle.py
Created November 30, 2011 05:34
A FreeCAD script for the purpose of inspecting the radius and center of circles in 3D models
from FreeCAD import Base
class MeasureCircle:
"""This class will report the computed radius and center of a circle or arc given 3 vertices.
A line is drawn from the first vertex to the center of the circle, which may be used for future measurements.
Just select the vertices and the result will be shown in Report View
Edges may also be selected and count as two vertices.
If two edges are selected one of the vertices in the second edge is not used in the calculation"""
def __init__(self):
self.points = []
@sparr
sparr / T-Slot Nut.py
Created November 28, 2011 01:44
Parametric Printable T-Slot Nut
from __future__ import division # allows floating point division from integers
from FreeCAD import Base
import sys
import math
try:
path = App.ConfigGet('UserHomePath') + '/FreeCad/Mod'
i = sys.path.index(path)
except:
sys.path.append(path)
@thehans
thehans / Extrusions.py
Created November 26, 2011 23:23
Parametric Aluminum Extrusion Module
from math import sqrt
from FreeCAD import Base
#Main class for general extrusion related methods
class ExtrusionProfile():
def __init__(self, profile):
self.profile = profile
def makeExtrusion(self, p1, p2, rotateAngle=0):
"""Generates an extrusion which connects between two points,
@thehans
thehans / ProjectEnclosure.py
Created November 13, 2011 05:23
FreeCAD script for generating parametric project enclosures
from __future__ import division # allows floating point division from integers
from FreeCAD import Base
import Part
import math
# Run this macro to create a generic project enclosure box
# You can change all the parameters by selecting the object in the tree view and tweaking values in the "Data" tab
# Possible additions/improvements
# counterbore bridging .4mm
@DamianZaremba
DamianZaremba / retrieve.py
Created September 3, 2011 16:54
Quick py hack to scrape table data from wikipedia (ISO codes right now)
#!/usr/bin/env python
import urllib
import sys
import json
from mwlib import parser
from mwlib.refine import compat
if __name__ == "__main__":
params = urllib.urlencode({
"format": "json",
@sixtenbe
sixtenbe / analytic_wfm.py
Last active May 1, 2024 02:29 — forked from endolith/peakdet.m
Peak detection in Python
#!/usr/bin/python2
# Copyright (C) 2016 Sixten Bergman
# License WTFPL
#
# This program is free software. It comes without any warranty, to the extent
# permitted by applicable law.
# You can redistribute it and/or modify it under the terms of the Do What The
# Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See
@crmne
crmne / md5crypt.py
Created August 15, 2010 10:44
UNIX and Apache compatible MD5 password encryption
#!/usr/bin/env python
# Based on FreeBSD src/lib/libcrypt/crypt.c 1.2
# http://www.freebsd.org/cgi/cvsweb.cgi/~checkout~/src/lib/libcrypt/crypt.c?rev=1.2&content-type=text/plain
# Original license:
# * "THE BEER-WARE LICENSE" (Revision 42):
# * <phk@login.dknet.dk> wrote this file. As long as you retain this notice you
# * can do whatever you want with this stuff. If we meet some day, and you think
# * this stuff is worth it, you can buy me a beer in return. Poul-Henning Kamp
@endolith
endolith / peakdet.m
Last active February 14, 2024 21:27
Peak detection in Python [Eli Billauer]
function [maxtab, mintab]=peakdet(v, delta, x)
%PEAKDET Detect peaks in a vector
% [MAXTAB, MINTAB] = PEAKDET(V, DELTA) finds the local
% maxima and minima ("peaks") in the vector V.
% MAXTAB and MINTAB consists of two columns. Column 1
% contains indices in V, and column 2 the found values.
%
% With [MAXTAB, MINTAB] = PEAKDET(V, DELTA, X) the indices
% in MAXTAB and MINTAB are replaced with the corresponding
% X-values.