This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import FreeCAD,OpenSCADFeatures | |
for obj in FreeCAD.ActiveDocument.Objects: | |
if obj.TypeId == "Part::FeaturePython" and hasattr(obj,'Proxy') and isinstance(obj.Proxy,OpenSCADFeatures.CGALFeature) \ | |
and len(obj.Children) == 2: | |
print [(child.TypeId,child.PropertiesList) for child in obj.Children] | |
if obj.Children[0].TypeId in ['Part::Cylinder','Part::Sphere']: | |
OpenSCADFeatures.OffsetShape(obj,obj.Children[1],float(obj.Children[0].Radius)) | |
obj.touch() | |
elif obj.Children[1].TypeId in ['Part::Cylinder','Part::Sphere']: | |
OpenSCADFeatures.OffsetShape(obj,obj.Children[0],float(obj.Children[1].Radius)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import FreeCAD | |
def segments2points(segments,degree): | |
pts=segments[0].getPoles()[0:1] | |
for seg in segments: | |
if seg.Degree < degree: | |
seg.Increase(degree) | |
pts.extend(seg.getPoles()[1:]) | |
return pts | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
"""usage: diffblame.py START..END [path]""" | |
import os,sys,subprocess | |
gitpath = subprocess.Popen(["git", "rev-parse","--show-toplevel"],\ | |
stdout=subprocess.PIPE).communicate()[0].strip() | |
diff = subprocess.Popen(["git", "diff","-U0"]+sys.argv[1:],\ | |
stdout=subprocess.PIPE).communicate()[0] | |
for l in diff.splitlines(): | |
if l=='': |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def gettimeszonestg(tz,dt1=None): | |
if tz is None: | |
return 'J' | |
else: | |
utco=tz.utcoffset(dt1) | |
if utco.days>=0: | |
tzg = 'ZABCDEFGHIKLM'[utco.seconds//3600] | |
else: | |
tzg = 'ZNOPQRSTUVWXY'[(-utco).seconds//3600] | |
if utco.seconds % 3600 == 1800: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#/usr/bin/env python | |
import sqlite3 | |
conn=sqlite3.connect('memento.sqlite') | |
cr=conn.cursor() | |
calcslist=cr.execute("SELECT * FROM `entry`").fetchall() | |
calcsdict=dict((entry[0].lower(),entry) for entry in calcslist) | |
conn.close() | |
if __name__ = '__main__': | |
import sys |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import FreeCAD | |
import importCSG | |
#import prototype | |
importmod=importCSG | |
dirpath='' | |
def comparewithstl(filename,obj,doc): | |
# import MeshPart | |
import Mesh | |
import OpenSCADUtils |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
token_type='Bearer' | |
access_token='' | |
baseurl='https://api.thingiverse.com/' | |
meurl='https://api.thingiverse.com/users/me' | |
import urllib2, base64 | |
import json | |
def isfiletype(name,suffixes=('fcstd','scad','brep','brp')): | |
return any([name.lower().endswith(suffix) for suffix in suffixes]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
#with information from http://paulbourke.net/dataformats/spacemouse/ | |
smkeys=('1','2','3','4','5','6','7','8', '*','L','R','?') | |
nibble2sm=('0','A','B','3','D','5','6','G','H','9',':','K','<','M','N','?') | |
sm2nibble=dict(zip(nibble2sm,range(16))) | |
sm2nibble2=lambda x:ord(x) & 0xf | |
binary=False | |
def sm2coord(cstr): |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import sqlite3,datetime,sys | |
def buildactdict(c): | |
c.execute('SELECT id,name from categories') | |
catdict=dict(((cat[0], cat[1]) for cat in c.fetchall())) | |
c.execute('SELECT id,name,category_id from activities') | |
actdict=dict(((act[0], '%s@%s' % (act[1],catdict.get(act[2]))) \ | |
for act in c.fetchall())) | |
return actdict | |
def findunfinished(c): |