Skip to content

Instantly share code, notes, and snippets.

Avatar

Yorik van Havre yorikvanhavre

View GitHub Profile
@yorikvanhavre
yorikvanhavre / webgl.py
Created Apr 2, 2012
A FreeCAD webGL maker
View webgl.py
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 Apr 4, 2012
get a tangent vector from an edge in FreeCAD
View tangent.py
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 Apr 9, 2012
call pyqt4 stuff from javascript
View pyjs.py
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 Apr 9, 2012
sftp settings for wordpress
View wp-config-sftp.php
/* 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 Apr 13, 2012
A typical, simple SVG example
View example.svg
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 Apr 25, 2012
ssh config for sourceforge
View config
# 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 Apr 30, 2012
CMakeLists.txt for tumbler ffmpeg plugin
View CMakeLists.txt
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
diff between master and first msocorcim branch
View msocorcim.diff
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());
View ifcopenshell export tests
# 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 Dec 14, 2015
FreeCAD - use Sketcher datums from python
View sketcherdatum
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)
You can’t perform that action at this time.