Skip to content

Instantly share code, notes, and snippets.

View juanpaexpedite's full-sized avatar
:octocat:
I may be slow to respond.

juanpaexpedite

:octocat:
I may be slow to respond.
View GitHub Profile
@juanpaexpedite
juanpaexpedite / techdraw_wb_font_dimensions.FCMacro
Created August 13, 2023 08:10
Change Font Size in FreeCAD TechDraw Workbench Dimensions
# List all objects
# -*- coding: utf-8 -*-
import FreeCAD,Draft
# List all objects of the document
doc = FreeCAD.ActiveDocument
objs = FreeCAD.ActiveDocument.Objects
def clearConsole():
from PySide import QtGui
@juanpaexpedite
juanpaexpedite / list_Part_.FCMacro
Created July 29, 2023 19:36
List FreeCad objects wit 'Part_'
# List all objects
# -*- coding: utf-8 -*-
import FreeCAD,Draft
# List all objects of the document
doc = FreeCAD.ActiveDocument
objs = FreeCAD.ActiveDocument.Objects
#App.Console.PrintMessage(str(objs) + "\n")
#App.Console.PrintMessage(str(len(FreeCAD.ActiveDocument.Objects)) + " Objects" + "\n")
def clearConsole():
from PySide import QtGui
import timeit
import matplotlib.pyplot as plt
import winreg
# Obtener la lista de fuentes disponibles en el Registro de Windows
fonts_key = winreg.OpenKey(winreg.HKEY_LOCAL_MACHINE, r"SOFTWARE\Microsoft\Windows NT\CurrentVersion\Fonts", 0, winreg.KEY_READ)
font_names = [winreg.EnumValue(fonts_key, i)[0] for i in range(winreg.QueryInfoKey(fonts_key)[1])]
#Pause here to wait for loading if not I have an error finding fonts
code = """
@juanpaexpedite
juanpaexpedite / testdictionaries.cs
Last active August 29, 2021 07:26
Testing Dictionaries in C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace TestDictionary
{
/*
Test for 100 iterations
(byte Min, byte Value, byte Max,byte speed, bool Increasing) TextSize;
(byte Min, byte Value , byte Max, byte speed, bool Increasing) Red;
(byte Min, byte Value, byte Max, byte speed, bool Increasing) Green;
(byte Min, byte Value, byte Max, byte speed, bool Increasing) Blue;
Random dice = new Random();
SKPaint textpaint;
private void Init()
{
TextSize = (10, 128, 200,1, true);
Red = (0, (byte)dice.Next(0, 128), 200, (byte)dice.Next(0, 5), true);
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
@juanpaexpedite
juanpaexpedite / ListDictionaryConverter.cs
Created January 19, 2019 20:01
This class converts a list serialized into a Dictionary and when you serialize back goes to a List again
public class ListDictionaryConverter<T> : JsonConverter where T : Entity
{
public override bool CanConvert(Type objectType)
{
return (objectType == typeof(object));
}
public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
{
Dictionary<string, T> result;
@juanpaexpedite
juanpaexpedite / Settings.gd
Created May 7, 2018 09:00
GodotEngine 3.0 Settings
extends Node
enum {NON_EXISTING, LOAD_SUCCESS, LOAD_ERROR_COULDNT_OPEN}
const SAVE_PATH = "user://config.cfg"
var _config_file = ConfigFile.new()
func _ready():
var result = load_settings()
if result == NON_EXISTING:
SetDefault()
@juanpaexpedite
juanpaexpedite / WPFConverterBinding2_2.xaml
Created November 3, 2017 19:51
WPFConverterBinding2_2
<!--Remember to RaisePropertyChanged the ZIndex when Size Changes in the Model-->
<!-- And the viewmodel is defined like the following:
<Application.Resources>
<vm:PackViewModel x:Key="PackViewModel"/>
...
-->
<Grid Opacity="0.7" SnapsToDevicePixels="False" x:Name="ObjectZIndex" Visibility="{Binding IsZIndexSelector, Converter={StaticResource BoolVisibilityConverter}}" VerticalAlignment="Top" HorizontalAlignment="Left" Background="Transparent" Width="{Binding ElementName=BackPanel, Path=ActualWidth}" Height="1" RenderTransformOrigin="0,0">
<Grid.Resources>
@juanpaexpedite
juanpaexpedite / WPFConverterBinding1_2.cs
Created November 3, 2017 19:49
WPF Converter with binding 1/2
public class ZIndexConverter : DependencyObject, IValueConverter
{
public string Size
{
get { return (string)GetValue(SizeProperty); }
set { SetValue(SizeProperty, value); }
}
public static readonly DependencyProperty SizeProperty =
DependencyProperty.Register(nameof(Size), typeof(string), typeof(ZIndexConverter), new PropertyMetadata("0,0",OnSizeChanged));