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 / Modify-an-Existing-Part.py
Created October 14, 2025 10:35
Modify an Existing Part
#https://help.alibre.com/articles/#!alibre-help-v28/modify-an-existing-part
# demonstrates opening an existing part and adding a 3d sketch to it
# load P:\work\TestPart.AD_PRT
MyPart = Part(r'C:\Users\<username>\Desktop\ScriptDir', 'New')
# create a 3D sketch
Route = MyPart.Add3DSketch('Route')
Route.AddBspline([0, 0, 0, 5, 0, 0, 10, 5, 5, 15, 10, 5, 15, 15, 15])
#https://help.alibre.com/articles/#!alibre-help-v28/mobius-strip
# creates a mobius strip with a configurable number of rotations
Mobius = Part('Mobius')
# dimensions of mobius strip
Diameter = 100.0
Width = 20.0
Height = 5.0
@stephensmitchell
stephensmitchell / Midplane-Extrusion.py
Created October 14, 2025 10:35
Midplane Extrusion
#https://help.alibre.com/articles/#!alibre-help-v28/midplane-extrusion
# create the part and then a sketch containing a circle
P = Part('Test')
S = P.AddSketch('Shape', P.GetPlane('XY-Plane'))
S.AddCircle(0, 0, 9, False)
# how far we will extrude from mid-plane
ExtrudeLength = 10
@stephensmitchell
stephensmitchell / Lofting-with-a-Guide-Curve.py
Created October 14, 2025 10:35
Lofting with a Guide Curve
#https://help.alibre.com/articles/#!alibre-help-v28/lofting-with-a-guide-curve
# create part
P = Part('foo')
# create sketch for bottom of loft
Bottom = P.AddSketch('Bottom', P.GetPlane('XY-Plane'))
Bottom.AddRectangle(0, 0, 10, 10, False)
# create sketch for top of loft
@stephensmitchell
stephensmitchell / List-All-Parts-in-an-Assembly-and-Sub-Assemblies.py
Created October 14, 2025 10:35
List All Parts in an Assembly and Sub Assemblies
#https://help.alibre.com/articles/#!alibre-help-v28/list-all-parts-in-an-assembly-and-sub-assemblies
# list all the parts in an assembly and it's sub-assemblies
def ListPartsinAssembly(Assem):
for P in Assem.Parts:
print '%s in %s' % (P, Assem)
for SA in Assem.SubAssemblies:
ListPartsinAssembly(SA)
#https://help.alibre.com/articles/#!alibre-help-v28/joint-creator
# Joint Creator
# (c) Alibre, LLC 2019, All Rights Reserved
# Version 1.00
from __future__ import division
from math import *
# gets locaton of edge in a part coordinate system
@stephensmitchell
stephensmitchell / Importing-Files.py
Created October 14, 2025 10:35
Importing Files
#https://help.alibre.com/articles/#!alibre-help-v28/importing-files
# replace paths used with your own
# import a step file
MyPart1 = Part(r'c:\mycadfiles\Corner.stp', Part.FileTypes.STEP)
# import an IGES file
MyPart3 = Part(r'c:\mycadfiles\wave washer.igs', Part.FileTypes.IGES)
@stephensmitchell
stephensmitchell / Import-points-from-a-CSV-file-rotate-them-and-connect-into-a-polyline.py
Created October 14, 2025 10:35
Import points from a CSV file rotate them and connect into a polyline
#https://help.alibre.com/articles/#!alibre-help-v28/import-points-from-a-csv-file-rotate-them-and-connect-into-a-polyline
# imports a set of 2D points from a csv file, rotates them and then
# adds them to a 2D sketch with lines connecting the points
# specify which libraries we are going to use
import csv
import math
# configuration
#https://help.alibre.com/articles/#!alibre-help-v28/helical-spring
import sys
import math
# create dialog window
Win = Windows()
Options = []
Options.append(['Angle Increment', WindowsInputTypes.Real, 0.05])
Options.append(['Loop Scale', WindowsInputTypes.Real, 0.8])
@stephensmitchell
stephensmitchell / Getting-User-Input.py
Created October 14, 2025 10:35
Getting User Input
#https://help.alibre.com/articles/#!alibre-help-v28/getting-user-input
# Demonstrates requesting values from the user then creating a part
# with those values
print 'Input width in mm and press Enter'
Width = float(Read())
if Width < 0.1:
sys.exit('Width must be at least 0.1 mm')