Skip to content

Instantly share code, notes, and snippets.

View jimfoltz's full-sized avatar

Jim Foltz jimfoltz

View GitHub Profile
UI.menu("Extensions").add_item("Print Model Size") {
JF::ModelSize.main
}
module JF
module ModelSize
def self.main
bb = Sketchup.active_model.bounds
# 8.times {|c|
@jimfoltz
jimfoltz / parentize-dc.rb
Created November 1, 2015 12:04
parentize-dc.rb
# Replaces references to a parent Coponent in a DC
# with the "Parent!" reference.
module JF
module Parentize
private
DICT = "dynamic_attributes".freeze
@jimfoltz
jimfoltz / amf-ex.rb
Last active November 15, 2015 10:58
amf-ex.rb
#UI.menu.add_item("Export AMF") {
#JF::AMF.export
#}
require 'rexml/document'
module JF
module AMF
module Exporter
@jimfoltz
jimfoltz / 3ds2obj.rb
Created October 17, 2013 08:23
Command line quickie to convert binary .3ds files and output ascii .obj file. Materials are ignored.
v_tot = 1
vqty = 0
file = ARGV.shift
f = File.new(file, "rb")
while ! f.eof?
cid = f.read(2).unpack('s')[0]
len = f.read(4).unpack('i')[0]
@jimfoltz
jimfoltz / extract_png.rb
Created November 8, 2013 23:14
Ruby snippet to extract the thumbnail .png enbeded in a .skp (SketchUp) file.
# with a lot of help from Adam on comp.lang.ruby
def extract_chunk(input, output)
lenword = input.read(4)
length = lenword.unpack('N')[0]
type = input.read(4)
data = length>0 ? input.read(length) : ""
crc = input.read(4)
return nil if length<0 || !(('A'..'z')===type[0,1])
#return nil if validate_crc(type+data, crc)
@jimfoltz
jimfoltz / infix2postfix.rb
Last active January 3, 2016 13:59
infix to postfix
require "awesome_print"
exp = "1 + 2 * 3"
exp = "9 + 24 / (7 - 3)"
exp = "3 * atan(2/3)"
exp = "(12.3mm - 1')*52 - 473 mm/(4 + 2^3)"
def prec(op)
case op
@jimfoltz
jimfoltz / sketchup-ruby-api-sidebar.html
Created April 3, 2016 13:17
SketchUp Ruby API Sidebar for Firefox
<!DOCTYPE html>
<html>
<head>
<title> SketchUp Ruby API</title>
<style>
body {
font-family: monospace;
font-size: 12px;
}
@jimfoltz
jimfoltz / su.ahk
Created October 6, 2018 23:05
Launch SketchUp from Command Line & Auto-click Splash Screen
#NoEnv ; Recommended for performance and compatibility with future AutoHotkey releases.
; #Warn ; Enable warnings to assist with detecting common errors.
SendMode Input ; Recommended for new scripts due to its superior speed and reliability.
;SetWorkingDir %A_ScriptDir% ; Ensures a consistent starting directory.
Versions := {}
Versions[17] := "C:\Program Files\SketchUp\SketchUp 2017\Sketchup.exe"
Versions[16] := "C:\Program Files\SketchUp\SketchUp 2016\Sketchup.exe"
#SingleInstance Force
;DetectHiddenWindows, On
ToolbarRow1 =
(
Fuzzy Finder
Shape Bender
Keyframe
Solid
Extension
@jimfoltz
jimfoltz / a2s.cpp
Last active July 4, 2022 07:51
convert mesh files to .skp using assimp library
#include <SketchUpAPI/SketchUp.h>
#include <iostream>
#include <assimp/Importer.hpp>
#include <assimp/scene.h>
#include <assimp/postprocess.h>
#include <assimp/DefaultLogger.hpp>
#include "output_sketchup_error.h"