This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #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') | |