Skip to content

Instantly share code, notes, and snippets.

View yorikvanhavre's full-sized avatar

Yorik van Havre yorikvanhavre

View GitHub Profile
@yorikvanhavre
yorikvanhavre / webgl.py
Created April 2, 2012 18:51
A FreeCAD webGL maker
import FreeCAD,WebGui
SCALE = 10 # global scale modifier
template = """<!DOCTYPE HTML>
<html lang="en">
<head>
<title>FreeCAD webGL viewer</title>
<meta charset="utf-8">
<style type="text/css">
@yorikvanhavre
yorikvanhavre / tangent.py
Created April 4, 2012 03:29
get a tangent vector from an edge in FreeCAD
def getTangent(edge):
"Returns a tangent vector from an edge in FreeCAD"
if isinstance(edge.Curve,Part.Line):
vec = edge.Vertexes[-1].Point.sub(edge.Vertexes[0].Point)
elif isinstance(edge.Curve,Part.Circle):
v1 = edge.Vertexes[-1].sub(edge.Curve.Center)
v2 = edge.Curve.Axis
vec = v1.cross(v2)
else:
print "not supported"
@yorikvanhavre
yorikvanhavre / pyjs.py
Created April 9, 2012 00:30
call pyqt4 stuff from javascript
import sys
from PyQt4 import QtCore, QtGui, QtWebKit
import WebGui
"""Html snippet."""
html = """
<html><body>
<center>
<script language="JavaScript">
document.write('<p>Python ' + pyObj.pyVersion + '</p>')
@yorikvanhavre
yorikvanhavre / wp-config-sftp.php
Created April 9, 2012 18:33
sftp settings for wordpress
/* put this in your wp-config.php */
define('FS_METHOD', 'ssh2');
define('FTP_USER', 'UNAME'); // Change UNAME to your CPanel Username
define('FTP_PASS', 'PWORD'); // Change PWORD to your CPanel Password
define('FTP_HOST', '67.210.247.245:50685');
@yorikvanhavre
yorikvanhavre / example.svg
Created April 13, 2012 22:31
A typical, simple SVG example
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@yorikvanhavre
yorikvanhavre / config
Created April 25, 2012 01:08
ssh config for sourceforge
# Sourceforge
Host *.sf.net
User yorik
IdentityFile ~/.ssh/keys/sf_key_new
Host *.sourceforge.net
User yorik
IdentityFile ~/.ssh/keys/sf_key_new
@yorikvanhavre
yorikvanhavre / CMakeLists.txt
Created April 30, 2012 00:17
CMakeLists.txt for tumbler ffmpeg plugin
cmake_minimum_required ( VERSION 2.6 )
project ( tumbler-ffmpeg-thumbnailer )
INCLUDE( FindPkgConfig )
FIND_PACKAGE( GTK2 REQUIRED )
ADD_DEFINITIONS("`pkg-config --cflags --libs gtk+-2.0`")
ADD_DEFINITIONS("`pkg-config --cflags --libs tumbler-1`")
pkg_check_modules(PKG REQUIRED libgsf-1)
pkg_check_modules(FFMPEG_THUMBNAILER libffmpegthumbnailer)
@yorikvanhavre
yorikvanhavre / msocorcim.diff
Created May 11, 2012 12:47
diff between master and first msocorcim branch
diff --git a/src/App/PropertyFile.cpp b/src/App/PropertyFile.cpp
index 13599c8..70b0f7e 100644
--- a/src/App/PropertyFile.cpp
+++ b/src/App/PropertyFile.cpp
@@ -296,7 +296,7 @@ void PropertyFileIncluded::Restore(Base::XMLReader &reader)
void PropertyFileIncluded::SaveDocFile (Base::Writer &writer) const
{
- Base::ifstream from(Base::FileInfo(_cValue.c_str()));
+ std::ifstream from(_cValue.c_str());
# creates an empty file
f=IfcImport.open("")
# this writes the file to disc, in this case a minimal header
f.write("/home/yorik/test1.ifc")
# adding entities
pnt = IfcImport.Entity("ifccartesianpoint")
f.add(pnt)
@yorikvanhavre
yorikvanhavre / sketcherdatum
Last active December 14, 2015 11:08
FreeCAD - use Sketcher datums from python
from pivy import coin
import SketcherGui
coin.SoType.fromName("SoDatumLabel")
l=coin.SoType.fromName("SoDatumLabel").createInstance()
l.Type
l.string.setValue("Yorik")
sg=Gui.ActiveDocument.ActiveView.getSceneGraph()
sg.addChild(l)
l.datumtype.getValue()
l.datumtype.setValue(2)