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 / Create-and-Modify-Global-Parameters.py
Created October 14, 2025 10:34
Create and Modify Global Parameters
#https://help.alibre.com/articles/#!alibre-help-v28/create-and-modify-global-parameters
# create a new global parameters set
Params = GlobalParameters('Test')
# add a distance parameter in millimeters
Params.AddParameter('Width', ParameterTypes.Distance, 4.56)
# save and close, replace with your own path
Params.Save(r'C:\Users\<username>\Downloads\temp')
Params.Close()
#https://help.alibre.com/articles/#!alibre-help-v28/copy-sketch
MyPart = Part('MyPart')
Sketch1 = MyPart.AddSketch('Sketch1', MyPart.GetPlane('XY-Plane'))
Sketch1.AddLines([0, 10, 0, 0, 10, 0, 10, 10], False)
Sketch1.AddArcCenterStartAngle(5, 10, 10, 10, 180, False)
Sketch2 = MyPart.AddSketch('Sketch2', MyPart.GetPlane('YZ-Plane'))
Sketch2.CopyFrom(Sketch1)
@stephensmitchell
stephensmitchell / Cap-Screw-ISO-4762-Bolts.py
Created October 14, 2025 10:34
Cap Screw ISO 4762 Bolts
#https://help.alibre.com/articles/#!alibre-help-v28/cap-screw-iso-4762-bolts
# Creates a metric socket cap screw using ISO 4762
# See: http://practicalmaintenance.wordpress.com/2009/01/30/socket-head-cap-screws-article-13/
# Size of screw
Diameter = 3.0
Length = 30.0
# Measurements table containing H, F, E, T, C from web page
@stephensmitchell
stephensmitchell / Calculating-Length-of-Curves.py
Created October 14, 2025 10:34
Calculating Length of Curves
#https://help.alibre.com/articles/#!alibre-help-v28/calculating-length-of-curves
import sympy
from sympy import *
x = Symbol('x')
formula = 2 * x**2
x_minimum = 5.0
x_maximum = 10.0
#https://help.alibre.com/articles/#!alibre-help-v28/bolt-creator
MyPart = Part('My Part')
XYPlane = MyPart.GetPlane('XY-Plane')
HeadSketch = MyPart.AddSketch('Head', XYPlane)
HeadSketch.AddCircle(0, 0, 10, False)
BoltHead = MyPart.AddExtrudeBoss('Bolt Head', HeadSketch, 5, False)
HeadBottomPlane = MyPart.AddPlane('Head Bottom', XYPlane, 5)
@stephensmitchell
stephensmitchell / Assembly-Constraints.py
Created October 14, 2025 10:34
Assembly Constraints
#https://help.alibre.com/articles/#!alibre-help-v28/assembly-constraints
# create a new empty assembly
Asm = Assembly("Test");
# add a part at the origin, replace path with your own
NewPart1 = Asm.AddPart(r'C:\Users\<username>\Desktop\PartA.AD_PRT', 0, 0, 0)
# duplicate the part
NewPart2 = Asm.DuplicatePart(NewPart1.Name, 0, 0, 0)
# anchor the original copy
Asm.AnchorPart(NewPart1.Name);
@stephensmitchell
stephensmitchell / Alibre-Export-Script.py
Created October 12, 2025 11:40
AlibreX and Alibre Script API export script with STEP AP242 for IronPython (Alibre Script addon) access
"""
Alibre Export Script
"""
import clr
import sys
from System import Environment, IO
try:
clr.AddReference('AlibreX')
@stephensmitchell
stephensmitchell / AlibreOOConnect.cpp
Created December 19, 2024 02:16
AlibreOOConnect snippet
#pragma once
#include "frmconfiguration.h"
#include "frmparameter.h"
#include <ctype.h>
namespace AlibreOOConnect {
using namespace System;
using namespace System::ComponentModel;
using namespace System::Collections;
@stephensmitchell
stephensmitchell / Export Part Views as DXF.py
Created February 13, 2024 23:46
getalibrepath-function-and-alibrescript
from __future__ import division # This fixes division with integers. For example the 1 / 2 = 0.5 instead of 0
import os # for working with file paths
import clr
import _winreg
from AlibreX import ADUnits, ADDrawingViewType, ADDetailingOption, ADViewOrientation, IAD2DPoint, IADTransformation
Win = Windows()
def InputChanged(Index, Value):
https://help.alibre.com/articles/#!alibre-help-v27/wrap Pro
https://help.alibre.com/articles/#!alibre-help-v27/workspace-preferences-working-with-redlines Pro
https://help.alibre.com/articles/#!alibre-help-v27/workspace-preferences-menu-structure-toolbars Pro
https://help.alibre.com/articles/#!alibre-help-v27/workspace-preferences-menu-structure-custom-toolbars Pro
https://help.alibre.com/articles/#!alibre-help-v27/workspace-preferences-grid-snapping-to-the-grid Pro
https://help.alibre.com/articles/#!alibre-help-v27/workspace-preferences-grid-showing-or-hiding-the-grid Pro
https://help.alibre.com/articles/#!alibre-help-v27/workspace-preferences-grid-setting-the-grid Pro
https://help.alibre.com/articles/#!alibre-help-v27/workspace-preferences-about-split-views Pro
https://help.alibre.com/articles/#!alibre-help-v27/using-menus Pro
https://help.alibre.com/articles/#!alibre-help-v27/thread-data Pro