Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
set -e
# Steam Deck UNOFFCIAL Tilt Five install script
# Save to a directory with the tiltfive_driver_1.4.1_amd64.unpacked_debs.tar.xz archive
# chmod +x steamdeck-install.sh
# sudo sh ./steamdeck-install.sh
# Adjust paths if necessary
TILTFIVE_HOME_DIR="/var/opt/tiltfive"
import FreeCADGui as Gui
import FreeCAD as App
import Part
def pick_ray(start_vec, dir_vec):
Gui.Selection.clearSelection()
if App.ActiveDocument.getObject('Line_dir'):
App.ActiveDocument.removeObject('Line_dir')
if App.ActiveDocument.getObject('Line_ray'):
App.ActiveDocument.removeObject('Line_ray')
@kwahoo2
kwahoo2 / framebuffer_test.py
Last active November 27, 2024 18:48 — forked from vug/framebuffer_test.py
Trying Frame buffer objects in PyOpenGL
import numpy as np
from OpenGL.GL import *
WINDOW_LIBRARY = 'GLFW' # GLFW or GLUT
TRY_FRAMEBUFFER = True
GENERATE_TEXTURE_ID_PROBLEM = False # Follow this global variable to see the error in texture ID generation
SIDE = 800 # window size
@kwahoo2
kwahoo2 / soenvfc.py
Last active October 28, 2024 17:15
SoEnvironment usage in FreeCAD scene
# SoEnvironment usage in FreeCAD scene
# https://www.coin3d.org/coin/classSoEnvironment.html
# https://forum.freecad.org/viewtopic.php?p=785643#p785643
from pivy.coin import SoEnvironment
se = SoEnvironment() # create a new node
sg = Gui.ActiveDocument.ActiveView.getSceneGraph()
sg.insertChild(se, 1) # add the node at the beginning of our scene
se.ambientIntensity.getValue() # read value for current ambient light eg.: 0.2
se.ambientIntensity.setValue(0.8) # set a new value for ambient light, can be higher than 1 too, since it is multiplied by AmbientColor property of a material
@kwahoo2
kwahoo2 / gamepad-navigation.py
Created October 20, 2024 21:42
Python script for navigating FreeCAD view with a gamepad
# move FreeCAD camera with a gamepad
import ctypes
import time
from sdl2 import *
from pivy.coin import SbVec3f, SbRotation
from PySide import QtCore
from math import pi
import FreeCAD as App, FreeCADGui as Gui, time
from PySide2 import QtGui,QtCore
class Animation(object):
def __init__(self):
App.Console.PrintMessage("init \n")
App.ActiveDocument.recompute()
self.timer = QtCore.QTimer()
QtCore.QObject.connect(self.timer, QtCore.SIGNAL("timeout()"), self.my_update)
self.timer.start(100) #100ms for step, adjust to performance of the PC
import FreeCAD as App, FreeCADGui as Gui, Part, time
from PySide2 import QtGui,QtCore
from pivy import coin
import math
class CustomArrow(object):
def __init__(self):
self.cyl_height = 6
cyl_radius = 3
@kwahoo2
kwahoo2 / sdl-example-coin-test.py
Created August 23, 2023 21:18
Paste in FreeCAD console to get OpenXR viewer
# based on gl_example.py https://github.com/cmbruns/pyopenxr_examples
import ctypes
import logging
from threading import Thread
import sdl2
import platform
from OpenGL import GL
# This script creates a simple Qt Widget, renders it to a Coin3D texture (SoTexture2), and creates a cube (SoCube) with that texture.
# It also simulates (def simulate_picking(self)) a 3D ray that intersects with Coin3D render of the QWidget. If the point of intersection is on the "Hello World" button widget, then QMouseEvent (pressed and relesed) is triggered and button activation is animated.
from OpenGL import GL
from PySide2.QtWidgets import QOpenGLWidget, QApplication
from PySide2.QtCore import Qt, QTimer, Signal, Slot
from PySide2.QtGui import QOpenGLContext
from PySide2.QtGui import qGray, qRed, qGreen, qBlue, qAlpha
from pivy.coin import SoFrustumCamera
# This script creates ABENICS (half of) cross gear in FreeCAD
import FreeCAD as App
import Part
import InvoluteGearFeature
doc = App.ActiveDocument
mod = 2.0 # gear tooth module
monopole_teeth = 12 # number of teeth
cross_teeth = monopole_teeth * 2
height = 20 # height of the monopole gear