Skip to content

Instantly share code, notes, and snippets.

View yorikvanhavre's full-sized avatar

Yorik van Havre yorikvanhavre

View GitHub Profile
@yorikvanhavre
yorikvanhavre / fetch.py
Created June 2, 2016 18:09
sample fetch script for freecad
class plugin:
author = "xyz"
type = "macro"
description = "this plugin does this"
baseurl = "http://github.com/mymacro"
infourl = "http://github.com/mymacro/README.md"
class Fetch:
def __init__():
@yorikvanhavre
yorikvanhavre / openfoam_obj_exporter.py
Created January 24, 2016 15:21
An openFOAM-tailored OBJ exporter for FreeCAD
#***************************************************************************
#* *
#* Copyright (c) 2015 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
def normalizeAngle(angle,amin=-180,amax=180):
"normalizes the given angle"
if angle > amax:
return normalizeAngle(angle-amax)
elif angle < amin:
return normalizeAngle(angle+amin)
else:
return angle
@yorikvanhavre
yorikvanhavre / html-thumbnailer
Created August 17, 2013 01:58
html thumbnailer
cutycapt --url=file:///home/yorik/Site/index.html --out=/tmp/tmpthumb.jpg && convert /tmp/tmpthumb.jpg -thumbnail 150x180^ -gravity NorthWest -extent 150x180 thumb.jpg
#***************************************************************************
#* *
#* Copyright (c) 2013 *
#* Yorik van Havre <yorik@uncreated.net> *
#* *
#* This program is free software; you can redistribute it and/or modify *
#* it under the terms of the GNU Lesser General Public License (LGPL) *
#* as published by the Free Software Foundation; either version 2 of *
#* the License, or (at your option) any later version. *
#* for detail see the LICENCE text file. *
@yorikvanhavre
yorikvanhavre / pivy-texture-scaling
Created July 8, 2013 22:41
How to scale a texture with pivy. Last method (using a SoTextureCoordinatePlane) allows to give a scale independently of the size of the object
Python 2.7.5+ (default, Jun 2 2013, 13:28:26)
[GCC 4.7.3] on linux2
Type 'help', 'copyright', 'credits' or 'license' for more information.
>>> App.setActiveDocument("Unnamed")
>>> App.ActiveDocument=App.getDocument("Unnamed")
>>> Gui.ActiveDocument=Gui.getDocument("Unnamed")
>>> import Draft
>>> pl = FreeCAD.Placement()
>>> pl.Rotation.Q = (0.0,-0.0,-0.0,1.0)
>>> pl.Base = FreeCAD.Vector(-1.33731794357,0.644989609718,0.0)
@yorikvanhavre
yorikvanhavre / info object
Last active December 16, 2015 17:09
very simple info-carrying object
# custom object definition
class MyCustomObject():
def __init__(self,obj):
obj.addProperty("App::PropertyStringList","CustomProps","Base", "A placeholder for custom properties")
obj.Proxy = self
def execute(self,obj):
pass
# create one in the current doc
myobj = FreeCAD.ActiveDocument.addObject("App::FeaturePython","MyObject")
@yorikvanhavre
yorikvanhavre / ace_editor_threejs.html
Created April 12, 2013 03:34
Dan Falck showed me this
<!DOCTYPE html>
<html lang="en">
<head>
<title>ACE in Action</title>
<style type="text/css" media="screen">
#b3 {
position: absolute;
top: 5%;
right: 0;
@yorikvanhavre
yorikvanhavre / py2to3-test.diff
Created April 10, 2013 23:40
a first test to convert a module from py2 to py3, contains a couple of solutions
diff --git a/src/3rdParty/Pivy-0.5/coin_wrap.cpp b/src/3rdParty/Pivy-0.5/coin_wrap.cpp
index ee304d6..fe1c8d7 100644
--- a/src/3rdParty/Pivy-0.5/coin_wrap.cpp
+++ b/src/3rdParty/Pivy-0.5/coin_wrap.cpp
@@ -1,3 +1,4 @@
+
/* ----------------------------------------------------------------------------
* This file was automatically generated by SWIG (http://www.swig.org).
* Version 1.3.36
@@ -880,7 +881,11 @@ SWIG_Python_AddErrorMsg(const char* mesg)
@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)