Skip to content

Instantly share code, notes, and snippets.

@5263
5263 / blender-nurbs-selfcontained.py
Last active March 20, 2023 12:07
NURBS export for Blender and import for FreeCAD
#!/usr/bin/env python
freecadfunctions="""#!/usr/env/bin python
#python 2
import FreeCAD,Part
def pointstopoles1D(points):
return zip(*[(FreeCAD.Vector(point[0:3]),point[3]) for point in points])
def pointstopoles(points,cu):
poles=[]
@5263
5263 / decode_post_datamtrix.py
Created September 10, 2011 19:45
Decodes Informations from Deutsche Post Datamatrix Codes
#!/usr/bin/env python
import sys
import datetime
frankierart={
0x01:'Stampit 2003',
0x02:'0x02???',
0x03:'Frankit',
0x05:'Filiale',
0x07:'Frankierservice Infopost/Infobrief',
0x08:'Premiumadress',
@5263
5263 / parsegitweb3.py
Last active April 24, 2021 16:33
gitwebparser
#!/usr/bin/env python3
import bs4
import requests
sa = requests.Session()
sa.verify = False # workaround
# sa.auth = BearerAuth()
sa.timeout = 10
@5263
5263 / gist:3041500
Created July 3, 2012 18:13
FreeCAD interpolate surface
import FreeCAD
f1=open("surface.dat")
coords=[]
miny=1
for line in f1.readlines():
sline=line.strip()
if sline and not sline.startswith('#'):
ycoord=len(coords)
lcoords=[]
for xcoord, num in enumerate(sline.split()):
@5263
5263 / checkoutandload.FCMacro
Last active October 26, 2020 19:28
FreeCAD files git repo
#!/usr/bin/env python
import zip2git
from PySide import QtGui
# 1. Choose repository (directiory)
repodir = QtGui.QFileDialog.getExistingDirectory(QtGui.qApp.activeWindow())
if repodir:
# ToDO: 2. List branches in a list and let the user choose one
# ToDo: 3. List commits in a list and let the user choose one
# ToDo: 4. Check if it would overwrite a file. And if the file is
# part of the repo. Ask the user for cofirmation
@5263
5263 / ncevn.py
Created February 24, 2012 13:51
Parser for netcologne itimized bills
#!/usr/bin/env python
# -*- coding: utf-8 -*-
"""
Netcologne itemized bill paraser
the csv file should be in the same directory and named nc-*
"""
knownprefix = {
#internatinal
'+30':'Griechenland',
@5263
5263 / ultimo.py
Created June 14, 2018 18:18
Last day of previous months
import datetime,calendar
def ultimo(num=3,today=None):
"""return a list of datetime.date with the last day of num previous months"""
if today is None:
today = datetime.date.today()
return [datetime.date(y,m,calendar.monthrange(y,m)[1]) for \
m,y in (((today.month - i -1) % 12+1, today.year + \
((today.month - i -1) // 12)) for i in range(num+1,0,-1))]
@5263
5263 / testimport.py
Created January 15, 2013 17:30
Automaticly import and check OpenSCAD files into FreeCAD
import FreeCAD
import importCSG
#import prototype
importmod=importCSG
dirpath=''
def comparewithstl(filename,obj,doc):
# import MeshPart
import Mesh
import OpenSCADUtils
@5263
5263 / exrsdoc.py
Last active August 5, 2016 10:57
parser for the rdsoc file format
#!/usr/bin/env python
import zipfile
tempdirlin='/home/user/sattemp'
tempdirwine='D:\\'
converterbin="/windows/Programme/Program Files (x86)/DesignSpark/DesignSpark Mechanical 1.0/sabSatConverter.exe"
# add freecad libdir to path
import sys
sys.path.insert(0,'/usr/local/freecad/lib')
@5263
5263 / piscator.py
Last active December 17, 2015 17:49
Import ft designer (*.ftm) files into FreeCAD
import os
if open.__module__ == '__builtin__':
pythonopen = open # to distinguish python built-in open function from the one declared here
ftdpath='C:/Program Files (x86)/fischertechnik designer'
partnamelang='NAME' #german
#partnamelang='ENG' #english