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
#https://help.alibre.com/articles/#!alibre-help-v28/slice-a-part
# open part, replace with your own path
P = Part(r'C:\Users\Brian\Desktop\ScriptDir', 'New2')
# get bounding box of part - eight points, one for each corner
# of the bounding box
Bounds = P.GetBoundingBox()
# get the plane that the part will be sliced on
#https://help.alibre.com/articles/#!alibre-help-v28/servo-cam
majorwidth = 13.763
minorwidth = 6.260
height = 7.000
slotwidth = 3.000
baseheight = 2.000
servoheight = 4.000
servoinside = 4.200
@stephensmitchell
stephensmitchell / Scaling-a-Sketch.py
Created October 14, 2025 10:35
Scaling a Sketch
#https://help.alibre.com/articles/#!alibre-help-v28/scaling-a-sketch
Units.Current = UnitTypes.Inches
TestRoom = Part('TEST ROOM Scaled', False)
OriginalSketch = TestRoom.GetSketch('Sketch<1>')
# currently 8.25' wide, need it to be 4.125'
ScaleFactor = 4.125 / 8.25 * 100.0
@stephensmitchell
stephensmitchell / Reference-Geometry.py
Created October 14, 2025 10:35
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 / Rectangular-hollow-formed-profiles.py
Created October 14, 2025 10:35
Rectangular hollow formed profiles
#https://help.alibre.com/articles/#!alibre-help-v28/rectangular-hollow-formed-profiles
# Rectangular hollow hot and cold formed profiles according to BS/EN-10210-2:1997 and BS/EN-10219:1997
# Measurements table H,B,T,ro,ri from here http://www.roymech.co.uk/Useful_Tables/Sections/RHS_cf.html
from collections import OrderedDict
PData = 0
@stephensmitchell
stephensmitchell / Reading-from-a-Spreadsheet.py
Created October 14, 2025 10:35
Reading from a Spreadsheet
#https://help.alibre.com/articles/#!alibre-help-v28/reading-from-a-spreadsheet
from openpyxl import load_workbook
# open a workbook, replace with your own path
wb = load_workbook(filename = 'C:\\Users\\<username>\\Downloads\\Book1.xlsx')
# get access to the sheet
Sheet1 = wb['Sheet1']
@stephensmitchell
stephensmitchell / Profile-and-Sweep-Path.py
Created October 14, 2025 10:35
Profile and Sweep Path
#https://help.alibre.com/articles/#!alibre-help-v28/profile-and-sweep-path
# create the part and get the yz plane
MyPart = Part('Test')
YZPlane = MyPart.GetPlane('YZ-Plane')
# create the route for the pipe
PipeRoute = MyPart.Add3DSketch('Pipe Route')
PipeRoute.AddBspline([0, 0, 0, 5, 0, 0, 10, 5, 5, 15, 10, 5, 15, 15, 15])
@stephensmitchell
stephensmitchell / Polygon-Incircle.py
Created October 14, 2025 10:35
Polygon Incircle
#https://help.alibre.com/articles/#!alibre-help-v28/polygon-incircle
import math
# diameter of circle that fits inside polygon
Diameter = 100
# number of sides
Sides = 6
# calculate exterior diameter of polygon
@stephensmitchell
stephensmitchell / Pocket-Hole-Creator.py
Created October 14, 2025 10:35
Pocket Hole Creator
#https://help.alibre.com/articles/#!alibre-help-v28/pocket-hole-creator
# Pocket Hole Creator
# (c) Alibre, LLC 2019, All Rights Reserved
# Version 1.00
from __future__ import division
from math import *
# compares two points [X1, Y1, Z1] and [X2, Y2, Z2]
@stephensmitchell
stephensmitchell / Parameters-with-Units.py
Created October 14, 2025 10:35
Parameters with Units
#https://help.alibre.com/articles/#!alibre-help-v28/parameters-with-units
# this script uses inches for it's units
Units.Current = UnitTypes.Inches
MyPart = Part('Foo')
# create parameter using current script units
LengthParam = MyPart.AddParameter('Length', ParameterTypes.Distance, 123.4)
# parameter value reads back in current script units