Skip to content

Instantly share code, notes, and snippets.

View stephensmitchell's full-sized avatar
💭
NNODESS

Stephen S. Mitchell stephensmitchell

💭
NNODESS
  • NNODESS
  • Earth
View GitHub Profile
@stephensmitchell
stephensmitchell / Geodesic-Dome-Reference-Geometry.py
Created October 14, 2025 10:35
Geodesic Dome Reference Geometry
#https://help.alibre.com/articles/#!alibre-help-v28/geodesic-dome-reference-geometry
# tessellates a sphere into triangles and generates a reference point at each vertex
# adapted from
# http://musingsofninjarat.wordpress.com/spheres-through-triangle-tessellation/
from math import *
A = 0.525731112119133606
B = 0.850650808352039932
#https://help.alibre.com/articles/#!alibre-help-v28/gear-example
Units.Current = UnitTypes.Millimeters
PressureAngle = 20
Thickness = 3
MercuryDiameter = 32
# replace with your own path
OutputFolder = 'C:\Users\username\Desktop\ScriptDir/'
SizeFile = open(OutputFolder + 'EarthGearSizes.txt', 'w')
@stephensmitchell
stephensmitchell / Everyone-Loves-a-Slinky.py
Created October 14, 2025 10:35
Everyone Loves a Slinky
#https://help.alibre.com/articles/#!alibre-help-v28/everyone-loves-a-slinky
# Everyone Loves a Slinky
# Adapted from:
# http://forum.alibre.com/viewtopic.php?f=9&t=5752&p=30750&hilit=Spring#p30750
import sys
import math
# create dialog window
@stephensmitchell
stephensmitchell / Drop-Down-Lists.py
Created October 14, 2025 10:34
Drop Down Lists
#https://help.alibre.com/articles/#!alibre-help-v28/drop-down-lists
import glob
import os
import re
# default diameter to show
DefaultDiameter = 'M6'
# called when an input changes in the dialog window
@stephensmitchell
stephensmitchell / Default-Reference-Geometry.py
Created October 14, 2025 10:34
Default Reference Geometry
#https://help.alibre.com/articles/#!alibre-help-v28/default-reference-geometry
# create a new part
P = Part("Test")
# access reference geometry
print P.XYPlane
print P.YZPlane
print P.ZXPlane
print P.XAxis
@stephensmitchell
stephensmitchell / Custom-Values-and-Settings-Window.py
Created October 14, 2025 10:34
Custom Values and Settings Window
#https://help.alibre.com/articles/#!alibre-help-v28/custom-values-and-settings-window
# create windows object
Win = Windows()
# construct list of items for the window
Options = []
# ask user for text
Options.append(['Name of the item', WindowsInputTypes.String, 'Baz'])
# ask user for a floating point (real) value
@stephensmitchell
stephensmitchell / Creating-and-Manipulating-Assemblies.py
Created October 14, 2025 10:34
Creating and Manipulating Assemblies
#https://help.alibre.com/articles/#!alibre-help-v28/creating-and-manipulating-assemblies
# create a new empty assembly
Asm = Assembly("Test");
# add an existing part, located at the origin, replace path with your own
NewPart1 = Asm.AddPart(r'C:\Users\Brian\Desktop\PartA.AD_PRT', 0, 0, 0, 0, 0, 0, True)
# duplicate the part, translate it to x = 5, y = 10, z = 15 and rotate it x 30 deg, y 40 deg, z 50 deg
NewPart2 = Asm.DuplicatePart(NewPart1, 5, 10, 15, 30, 40, 50, True)
# duplicate the part, rotate it x 30 deg, y 40 deg, z 50 deg and translate it x = 5, y = 10, z = 15
@stephensmitchell
stephensmitchell / Creating-a-Cylinder-Between-Two-Points.py
Created October 14, 2025 10:34
Creating a Cylinder Between Two Points
#https://help.alibre.com/articles/#!alibre-help-v28/creating-a-cylinder-between-two-points
# creates a cylinder between two arbitrary points
from math import sqrt
# ends of cylinder are centered on these points
cyl_p1 = [1, 5, 2]
cyl_p2 = [10, 14, 8]
@stephensmitchell
stephensmitchell / Creating-a-3D-Sketch-with-a-Spline-and-an-Arc.py
Created October 14, 2025 10:34
Creating a 3D Sketch with a Spline and an Arc
#https://help.alibre.com/articles/#!alibre-help-v28/creating-a-3d-sketch-with-a-spline-and-an-arc
Units.Current = UnitTypes.Inches
P = Part('My Part')
# create 3d spline from a set of interpolation points
Path = P.Add3DSketch('Path')
Points = [0.6, -0.6625, 0.0]
Points.extend([0.6, -0.6625, -0.2175])
@stephensmitchell
stephensmitchell / Create-Reference-Planes-Axes-and-Points.py
Created October 14, 2025 10:34
Create Reference Planes Axes and Points
#https://help.alibre.com/articles/#!alibre-help-v28/create-reference-planes-axes-and-points
# demonstrates creating reference geometry
# create a new part and get the xy plane
MyPart = Part('My Part')
XYPlane = MyPart.GetPlane('XY-Plane')
# create planes 100mm above and below the xy plane
TopPlane = MyPart.AddPlane('Top Plane', XYPlane, 100.0)