#### stepalibre

##### Alibre Super User

Stay tuned.

### Introducing GPTs

You can now create custom versions of ChatGPT that combine instructions, extra knowledge, and any combination of skills.

openai.com

You should upgrade or use an alternative browser.

- Thread starter stepalibre
- Start date

Stay tuned.

You can now create custom versions of ChatGPT that combine instructions, extra knowledge, and any combination of skills.

openai.com

First script generated by ChatGPT that worked without needing cleanup:

The prompt/input was [ make a base plate with 4 holes ].

Follow this work here for example scripts and other resources:

###
GitHub - Testbed-for-Alibre-Design/AlibreScript-Code-Assistant: AlibreScript Code Assistant GPT

Python:

```
from AlibreScript import *
def create_base_plate_with_holes():
# Initialize a part session
part = CurrentPart()
# Define dimensions for the base plate and holes
plate_length = 100.0 # Length of the base plate
plate_width = 50.0 # Width of the base plate
plate_thickness = 5.0 # Thickness of the base plate
hole_diameter = 5.0 # Diameter of the holes
hole_offset = 10.0 # Offset of the holes from the edges
# Create a base plate
base_sketch = part.AddSketch('BasePlateSketch', part.XYPlane)
base_sketch.AddRectangle(-plate_width / 2, -plate_length / 2, plate_width / 2, plate_length / 2, False)
part.AddExtrudeBoss('BasePlate', base_sketch, plate_thickness, False, part.EndCondition.ToDepth, None, 0, part.DirectionType.Normal, None, 0, False)
# Create holes
for x in [-plate_width / 2 + hole_offset, plate_width / 2 - hole_offset]:
for y in [-plate_length / 2 + hole_offset, plate_length / 2 - hole_offset]:
hole_sketch = part.AddSketch('HoleSketch', part.XYPlane)
hole_sketch.AddCircle(x, y, hole_diameter / 2, False)
part.AddExtrudeCut('ThroughHole', hole_sketch, 0, False, part.EndCondition.ThroughAll, None, 0, part.DirectionType.Normal, None, 0, False)
# Save the part
#part.Save()
# Run the function to create a simple base plate with four holes
create_base_plate_with_holes()
```

Follow this work here for example scripts and other resources:

AlibreScript Code Assistant GPT. Contribute to Testbed-for-Alibre-Design/AlibreScript-Code-Assistant development by creating an account on GitHub.

github.com

Last edited:

I did many tests, and the beta is buggy. I think this is the actual chat. I manually deleted the formatted strings and commented out part.Save()

I added input/prompt instructions in the GPT for formatted strings and related things to exclude. You can also tell ChatGPT to remove them during a conversation.

I added input/prompt instructions in the GPT for formatted strings and related things to exclude. You can also tell ChatGPT to remove them during a conversation.

Last edited:

[ EDIT ]

Here are some examples testing the GPT's ability to generate Alibre Script API code only, without verifying 3D model output or code correctness.

**how to add a chamfer to an edge?**

**basic hex head bolt code**

**give me an example using this method with dummy data:**

Method->AddSweepBoss(String Name, Sketch ProfileSketch, ISweepPath PathSketch, Boolean IsRigid, EndCondition EndCondition, ISketchSurface EndPlane, Double EndOffset, Double DraftAngle, Boolean OutwardDraft)

**10 pipe flange model**

**complete hex head nut code**

Here are some examples testing the GPT's ability to generate Alibre Script API code only, without verifying 3D model output or code correctness.

Python:

```
import math
from AlibreScript import *
# Initialize the part session
part = CurrentPart()
# Assuming you have a part with an edge to chamfer.
# The edge can be obtained in various ways, depending on the context.
# Here's a generic way to get an edge, replace this with your specific method.
edges = part.GetEdges()
edge_to_chamfer = edges[0] # Assuming you want to chamfer the first edge in the list
# Define chamfer parameters
distance1 = 1 # The first chamfer distance
distance2 = 1 # The second chamfer distance (for unequal chamfer, otherwise set same as distance1)
# Add chamfer to the selected edge
part.AddChamfer("ChamferName", edge_to_chamfer, distance1, distance2, False)
# Regenerate the part to update the view
part.Regenerate()
```

Python:

```
import math
from AlibreScript import *
# Initialize the part session
part = CurrentPart()
# Define the dimensions of the bolt
hex_head_diameter = 10 # Diameter of the hex head
hex_head_height = 5 # Height of the hex head
shaft_diameter = 5 # Diameter of the shaft
shaft_length = 20 # Length of the shaft
# Create a hexagon sketch for the bolt head
hex_sketch = part.AddSketch("HexHeadSketch", part.XYPlane)
for i in range(6):
angle1 = math.radians(60 * i)
angle2 = math.radians(60 * (i + 1))
x1 = hex_head_diameter / 2 * math.cos(angle1)
y1 = hex_head_diameter / 2 * math.sin(angle1)
x2 = hex_head_diameter / 2 * math.cos(angle2)
y2 = hex_head_diameter / 2 * math.sin(angle2)
hex_sketch.AddLine([x1, y1], [x2, y2], False)
# Extrude the hex head
hex_head = part.AddExtrudeBoss("HexHead", hex_sketch, hex_head_height, False)
# Create a circle sketch for the shaft
shaft_sketch = part.AddSketch("ShaftSketch", part.XYPlane)
shaft_sketch.AddCircle(0, 0, shaft_diameter / 2, False)
# Extrude the shaft
shaft = part.AddExtrudeBoss("Shaft", shaft_sketch, shaft_length, False)
# Regenerate the part to update the view
part.Regenerate()
```

Method->AddSweepBoss(String Name, Sketch ProfileSketch, ISweepPath PathSketch, Boolean IsRigid, EndCondition EndCondition, ISketchSurface EndPlane, Double EndOffset, Double DraftAngle, Boolean OutwardDraft)

Python:

```
import math
from AlibreScript import *
# Initialize the part session
part = CurrentPart()
# Fetch the standard planes
xy_plane = part.GetPlane("XY-Plane")
zx_plane = part.GetPlane("ZX-Plane")
# Create a profile sketch on the XY plane
profile_sketch = part.AddSketch("ProfileSketch", xy_plane)
# Add a circle to the profile sketch as the sweep profile
profile_sketch.AddCircle(0, 0, 2, False) # Center at (0,0), Radius = 2
# Create a path sketch on the ZX plane
path_sketch = part.AddSketch("PathSketch", zx_plane)
# Add a line to the path sketch as the sweep path
path_sketch.AddLine([0, 0], [10, 10], False) # Line from (0,0) to (10,10)
# Define parameters for the sweep boss
is_rigid = False
end_condition = part.EndCondition.EntirePath # Using EntirePath as the end condition
end_plane = None
end_offset = 0
draft_angle = 0 # No draft angle
outward_draft = False # No outward draft
# Add the sweep boss feature
part.AddSweepBoss("SweepBossFeature", profile_sketch, path_sketch, is_rigid, end_condition, end_plane, end_offset, draft_angle, outward_draft)
# Regenerate the part to update the view
part.Regenerate()
```

Python:

```
import math
from AlibreScript import *
# Initialize the part session
part = CurrentPart()
# Flange dimensions (in mm)
flangeDiameter = 565 # Flange outer diameter
flangeThickness = 30 # Flange thickness
pipeDiameter = 254 # 10 inches converted to mm for pipe
boltHoleDiameter = 40 # Bolt hole diameter
boltCircleDiameter = 175 # Bolt circle diameter
numberOfBoltHoles = 12
# Create main flange disc
flangeSketch = part.AddSketch('FlangeBase', part.XYPlane)
flangeSketch.StartEditing()
flangeSketch.AddCircle(0, 0, flangeDiameter / 2, False) # Center at (0,0)
flangeSketch.StopEditing()
flange = part.AddExtrudeBoss('FlangeDisc', flangeSketch, flangeThickness, False)
# Create bolt holes
for i in range(numberOfBoltHoles):
angle = 2 * math.pi * i / numberOfBoltHoles
x = boltCircleDiameter / 2 * math.cos(angle)
y = boltCircleDiameter / 2 * math.sin(angle)
boltHoleSketch = part.AddSketch('BoltHole', part.XYPlane)
boltHoleSketch.StartEditing()
boltHoleSketch.AddCircle(x, y, boltHoleDiameter / 2, False)
boltHoleSketch.StopEditing()
part.AddExtrudeCut('BoltHoleCut', boltHoleSketch, flangeThickness, False)
# Create center pipe hole
centerHoleSketch = part.AddSketch('CenterPipeHole', part.XYPlane)
centerHoleSketch.StartEditing()
centerHoleSketch.AddCircle(0, 0, pipeDiameter / 2, False)
centerHoleSketch.StopEditing()
part.AddExtrudeCut('CenterHoleCut', centerHoleSketch, flangeThickness, False)
print("10-inch pipe flange model created.")
```

Python:

```
import math
from AlibreScript import *
# Initialize the part session
part = CurrentPart()
# Nut dimensions (in mm)
threadDiameter = 10 # M10 thread
pitch = 1.5 # Typical pitch for M10
acrossFlats = 17 # Width across flats for M10
thickness = 8 # Nut thickness for M10
cornerRadius = 1 # Corner radius
# Number of sides for the hexagon
numSides = 6
# Create the base hexagonal profile
hexSketch = part.AddSketch('HexBase', part.XYPlane)
hexSketch.StartEditing()
# Calculate vertices for the hexagon
vertices = []
for i in range(numSides + 1): # +1 to close the hexagon
angle = 2 * math.pi * i / numSides
x = acrossFlats / (2 * math.cos(math.pi / numSides)) * math.cos(angle)
y = acrossFlats / (2 * math.cos(math.pi / numSides)) * math.sin(angle)
vertices.append([x, y])
# Add lines to create the hexagon
for i in range(numSides):
startX, startY = vertices[i]
endX, endY = vertices[i + 1]
hexSketch.AddLine(startX, startY, endX, endY, False) # Adding line using coordinates
hexSketch.StopEditing()
# Extrude the hexagon to form the nut body
nutBody = part.AddExtrudeBoss('NutBody', hexSketch, thickness, False)
# Create internal thread hole
threadHoleSketch = part.AddSketch('ThreadHole', part.XYPlane)
threadHoleSketch.StartEditing()
threadHoleSketch.AddCircle(0, 0, threadDiameter / 2, False)
threadHoleSketch.StopEditing()
part.AddExtrudeCut('ThreadHoleCut', threadHoleSketch, thickness, False)
print("M10 hex nut model created.")
```

Last edited:

Most importantly the top of each script with any math it should include

`from __future__ import division`

to fix integer division in ironpython 2.7 or for example 5/2 will equal 2 instead of 2.5In the first one

`hole_sketch.AddCircle(x, y, hole_diameter / 2, False)`

should be `hole_sketch.AddCircle(x, y, hole_diameter, False)`

as the AddCircle expects a diameter not a radius.Basic hex head bolt code has the same AddCircle and division problem and also since both extrusions are going the same direction from the same face the bolt shaft ends up being too short.

AddSweepBoss has same AddCircle issues. I think I found a bug in AlibreScript when testing a draft angle - it converts it to radians when it should not (or maybe twice?).

10 pipe flange model has the same AddCircle and division problems and bogus flange data - boltCircleDiameter can not be smaller than pipeDiameter or the bolt holes all get cut off.

I'd suggest adding all holes to one sketch and doing a single extrude cut to keep the feature history shorter. Hopefully Alibre will add the ability to add patterns using API / AlibreScript soon.

The M10 hex nut has the same AddCircle and division problems. The pitch and cornerRadius variables are not used.

I'd also suggest also including

`Units.Current = UnitTypes.Millimeters`

or

`Units.Current = UnitTypes.Centimeters`

or

`Units.Current = UnitTypes.Inches`

so users can easily see a default and where to change it.

The goal right now is to get it to **output the correct API**, not design and logic correctness. All I'm focusing on right now is making sure It generates the right code from Alibre Script API. In other words I want the code to run, not checking for anything else. This is step 1. I have no rules regrading coding style, best practices, program logic or any details.

I give it an input/prompt and it is now able to generate real Alibre Script API code. The next step would be structure and rules to control the order of the code. I only gave the input you see there. I didn't give any other instructions I prompted it with "**complete hex head nut code". **And it generated that code, more information could be given in the conversation or in the GPT. I give it a wide range of input/prompt lengths, more or less descriptive and specific with details to test whether it would still provide good Alibre Script API code. In general GPTs only need a single sentence or a few words to understand what you're asking.

Your comments can be added as rules. If you or anyone see more in the other examples let me know. Make a list of rules for Alibre Script coding if you have time it would help.

I've only spent a few days on this and the beta is painfully slow. I hope it'll get faster soon. I don't know how long the beta will last.

I give it an input/prompt and it is now able to generate real Alibre Script API code. The next step would be structure and rules to control the order of the code. I only gave the input you see there. I didn't give any other instructions I prompted it with "

Your comments can be added as rules. If you or anyone see more in the other examples let me know. Make a list of rules for Alibre Script coding if you have time it would help.

I've only spent a few days on this and the beta is painfully slow. I hope it'll get faster soon. I don't know how long the beta will last.

Last edited:

I will add this to my updates when I revisit it next year. Any more comments and thoughts would be appreciated.

Most importantly the top of each script with any math it should include`from __future__ import division`

to fix integer division in ironpython 2.7 or for example 5/2 will equal 2 instead of 2.5

In the first one`hole_sketch.AddCircle(x, y, hole_diameter / 2, False)`

should be`hole_sketch.AddCircle(x, y, hole_diameter, False)`

as the AddCircle expects a diameter not a radius.

Basic hex head bolt code has the same AddCircle and division problem and also since both extrusions are going the same direction from the same face the bolt shaft ends up being too short.

AddSweepBoss has same AddCircle issues. I think I found a bug in AlibreScript when testing a draft angle - it converts it to radians when it should not (or maybe twice?).

10 pipe flange model has the same AddCircle and division problems and bogus flange data - boltCircleDiameter can not be smaller than pipeDiameter or the bolt holes all get cut off.

I'd suggest adding all holes to one sketch and doing a single extrude cut to keep the feature history shorter. Hopefully Alibre will add the ability to add patterns using API / AlibreScript soon.

The M10 hex nut has the same AddCircle and division problems. The pitch and cornerRadius variables are not used.

I'd also suggest also including`Units.Current = UnitTypes.Millimeters`

or`Units.Current = UnitTypes.Centimeters`

or`Units.Current = UnitTypes.Inches`

so users can easily see a default and where to change it.

Because the slow process of adding and updating inputs, updating the instructions, and finally trying out the GPT, I focused on API correctness. Instead of testing the code in Alibre Design for every script generated and thinking about Alibre scripting, I used various techniques, mostly experimenting with Custom GPTs and the capabilities for the first time. Focusing on getting the GPT to output Alibre Script was a logically first step. After the first successful generation (make a base plate with four holes), I realized it was possible. I also used ChatGPT and I had successful results by guiding it with more reference code.

I used Alibre Script stub files to help check the output in VS Code which made the process of debugging the GPT easier. What I've shared here is just a very small sample and I believe it will only improve alongside the AI tech.

Also prompting/input can be improved, instead of prompting - make a base plate with four holes**:**

how to make a 5" x 20" base plate 0.5" thick with 1.0" dia holes 1.5" from edge 4 places [ this is ChatGPT not the Alibre Script custom GPT but the Idea is the same ]

This conversation could then be used to make the Alibre Script code in the custom GPT.

In your conversation you could focus on the hole pattern, then the base plate construction and so forth. This approach takes more time but can be more accurate. You can also describe in very technical detail what you want the AI to do. You could also have the AI handle a part you don't want to do, and then you can finish the rest.

I'm not suggesting that everything being generated by any AI is accurate as is or can be used without knowledge or expertise. Like everything online we should check primary sources and verify output for accuracy.

I used Alibre Script stub files to help check the output in VS Code which made the process of debugging the GPT easier. What I've shared here is just a very small sample and I believe it will only improve alongside the AI tech.

Also prompting/input can be improved, instead of prompting - make a base plate with four holes

how to make a 5" x 20" base plate 0.5" thick with 1.0" dia holes 1.5" from edge 4 places [ this is ChatGPT not the Alibre Script custom GPT but the Idea is the same ]

This conversation could then be used to make the Alibre Script code in the custom GPT.

In your conversation you could focus on the hole pattern, then the base plate construction and so forth. This approach takes more time but can be more accurate. You can also describe in very technical detail what you want the AI to do. You could also have the AI handle a part you don't want to do, and then you can finish the rest.

I'm not suggesting that everything being generated by any AI is accurate as is or can be used without knowledge or expertise. Like everything online we should check primary sources and verify output for accuracy.

Last edited:

I'm researching the Assistants API now here is a good comparison:

This is without any fine-tuning or instructions it is the default GPT with the Alibre Script API data. I'll be adding API data for AlibreX, Dynamo, Rhino/Grasshopper V7/8, SolidWorks 2014, Solid Edge 2024 and devDept Eyeshot V10. This is only an early step to understand what's possible with GPTs and CAD APIs. The difference between GPTChat and AlibreScript Code Assistant is GPTChat is meant to replace ChatGPT for CAD APIs. I'll start with Alibre Design and then add more APIs and instructions specific to how API information should be structued, keywords and actions.

Here's a link to the GPT:

https://chat.openai.com/g/g-Bj9pwBKrd-gptchat - An API coding assistant for Alibre Design, Dynamo, Rhino/Grasshopper, SolidWorks, Solid Edge, and devDept Eyeshot.

Original:

Python:

```
#https://help.alibre.com/articles/#!alibre-help-v23/triangle
# Create triangle with angles 90, 15, 75
import math
# set up parameters
Theta = 15.0
Adjacent = 100.0
# calculate side
Opposite = Adjacent * math.tan(math.radians(Theta))
# generate three vertices of triangle
P1_X = 0
P1_Y = 0
P2_X = Adjacent
P2_Y = 0
P3_X = Adjacent
P3_Y = Opposite
# create part and sketch
P = Part('Foo')
S = P.AddSketch('Shape', P.GetPlane('XY-Plane'))
# draw it
S.AddLine(P1_X, P1_Y, P2_X, P2_Y, False)
S.AddLine(P2_X, P2_Y, P3_X, P3_Y, False)
S.AddLine(P3_X, P3_Y, P1_X, P1_Y, False)
```

Python:

```
import math
def create_right_triangle(theta, adjacent_length, part_name, sketch_name, plane_name):
# Calculate the length of the opposite side using trigonometry
opposite_length = adjacent_length * math.tan(math.radians(theta))
# Define the vertices of the triangle
p1 = (0, 0)
p2 = (adjacent_length, 0)
p3 = (adjacent_length, opposite_length)
# Create a new part and a sketch on the specified plane
part = Part(part_name)
sketch = part.AddSketch(sketch_name, part.GetPlane(plane_name))
# Draw the triangle using lines between the vertices
sketch.AddLine(p1[0], p1[1], p2[0], p2[1], False)
sketch.AddLine(p2[0], p2[1], p3[0], p3[1], False)
sketch.AddLine(p3[0], p3[1], p1[0], p1[1], False)
# Set up parameters for the triangle
theta = 15.0 # Angle in degrees
adjacent_length = 100.0 # Length of the adjacent side
# Create the triangle
create_right_triangle(theta, adjacent_length, 'TrianglePart', 'TriangleSketch', 'XY-Plane')
```

Again not a coding assistant but code can be generated from existing code.

I think this is the original AlibreScript GPT based on the name:

Yes this is the original. The generated image match my first post. I'll return to GPTs later I'm focusing on my Testbed addon. The purpose of this thread is to share as I learn about GPTs and AI. Trying to make it work in CAD somehow.

Yes this is the original. The generated image match my first post. I'll return to GPTs later I'm focusing on my Testbed addon. The purpose of this thread is to share as I learn about GPTs and AI. Trying to make it work in CAD somehow.

Last edited:

There are SolidWorks, Rhino, Solid Edge, and other CAD related GPTs in the store.

3D Helix:

Version 1:

Python:

```
import sys
import math
Win = Windows()
Options = []
Options.append(['Radius', WindowsInputTypes.Real, 10.0])
Options.append(['Pitch', WindowsInputTypes.Real, 5.0])
Options.append(['Turns', WindowsInputTypes.Integer, 10])
Options.append(['Angle Increment', WindowsInputTypes.Real, 0.1])
Values = Win.OptionsDialog('Helix Parameters', Options)
if Values == None:
sys.exit('User cancelled')
Radius = Values[0]
Pitch = Values[1]
Turns = Values[2]
AngleIncrement = Values[3]
print('Radius = %f' % Radius)
print('Pitch = %f' % Pitch)
print('Turns = %d' % Turns)
print('Angle Increment = %f' % AngleIncrement)
Points = []
Angle = 0.0
HeightIncrement = Pitch / (2 * math.pi / AngleIncrement)
for Pass in range(int(Turns * (2 * math.pi / AngleIncrement))):
X = Radius * math.cos(Angle)
Y = Radius * math.sin(Angle)
Z = Pass * HeightIncrement
Points.extend([X, Y, Z])
Angle += AngleIncrement
Helix = CurrentPart()
Path = Helix.Add3DSketch('Path')
Path.AddBspline(Points)
```

Version 2:

Python:

```
import sys
import math
Win = Windows()
Options = []
Options.append(['Angle Increment', WindowsInputTypes.Real, 0.05])
Options.append(['Radius', WindowsInputTypes.Real, 1.0])
Options.append(['Height Increment', WindowsInputTypes.Real, 0.1])
Options.append(['Turns', WindowsInputTypes.Integer, 20])
Values = Win.OptionsDialog('Helix Parameters', Options)
if Values is None:
sys.exit('User cancelled')
AngleIncrement = Values[0]
Radius = Values[1]
HeightIncrement = Values[2]
Turns = Values[3]
print('Angle Increment = %f' % AngleIncrement)
print('Radius = %f' % Radius)
print('Height Increment = %f' % HeightIncrement)
print('Turns = %d' % Turns)
Points = []
Angle = 0.0
Height = 0.0
TotalAngle = 2 * math.pi * Turns
while Angle <= TotalAngle:
X = Radius * math.cos(Angle)
Y = Radius * math.sin(Angle)
Z = Height
Points.extend([X, Y, Z])
Angle += AngleIncrement
Height += HeightIncrement
HelixPart = Part('Helix')
Path = HelixPart.Add3DSketch('Path')
Path.AddBspline(Points)
```

Version 3:

Python:

```
import sys
import math
Win = Windows()
Options = []
Options.append(['Angle Increment', WindowsInputTypes.Real, 0.05])
Options.append(['Radius', WindowsInputTypes.Real, 1.0])
Options.append(['Height Increment', WindowsInputTypes.Real, 0.1])
Options.append(['Turns', WindowsInputTypes.Integer, 20])
Values = Win.OptionsDialog('Helix Parameters', Options)
if Values is None:
sys.exit('User cancelled')
AngleIncrement = Values[0]
Radius = Values[1]
HeightIncrement = Values[2]
Turns = Values[3]
Points = []
Angle = 0.0
Height = 0.0
TotalAngle = 2 * math.pi * Turns
while Angle <= TotalAngle:
X = Radius * math.cos(Angle)
Y = Radius * math.sin(Angle)
Z = Height
Points.extend([X, Y, Z])
Angle += AngleIncrement
Height += HeightIncrement * AngleIncrement / (2 * math.pi)
HelixPart = Part('Helix')
Path = HelixPart.Add3DSketch('Path')
Path.AddBspline(Points)
```

Python:

```
import sys
import math
Win = Windows()
Options = []
Options.append(['Radius', WindowsInputTypes.Real, 10.0])
Options.append(['Pitch', WindowsInputTypes.Real, 5.0])
Options.append(['Total Turns', WindowsInputTypes.Integer, 10])
Options.append(['Angle Increment', WindowsInputTypes.Real, 0.1])
Options.append(['Segment Angle', WindowsInputTypes.Integer, 30]) # Option for segment angle
Values = Win.OptionsDialog('Helix Parameters', Options)
if Values is None:
sys.exit('User cancelled')
Radius = Values[0]
Pitch = Values[1]
TotalTurns = Values[2]
AngleIncrement = Values[3]
SegmentAngle = Values[4] # Angle for each segment
print('Radius = %f' % Radius)
print('Pitch = %f' % Pitch)
print('Total Turns = %d' % TotalTurns)
print('Angle Increment = %f' % AngleIncrement)
print('Segment Angle = %d' % SegmentAngle)
# Calculate the total number of segments based on total turns and segment angle
Segments = int((TotalTurns * 360) / SegmentAngle)
for Segment in range(Segments):
Points = []
# Calculate the start and end angles for the current segment in radians
StartAngle = Segment * SegmentAngle * (math.pi / 180.0)
EndAngle = StartAngle + (SegmentAngle * (math.pi / 180.0))
# Adjust the starting Z coordinate based on the segment's position in the overall helix
StartZ = Pitch * (StartAngle / (2 * math.pi))
Angle = StartAngle
while Angle < EndAngle:
X = Radius * math.cos(Angle)
Y = Radius * math.sin(Angle)
# Calculate Z using the adjusted start Z for the segment and the angle's progression
Z = StartZ + Pitch * ((Angle - StartAngle) / (2 * math.pi))
Points.extend([X, Y, Z])
Angle += AngleIncrement * (math.pi / 180.0) # Convert angle increment to radians for consistent progression
# Assuming CurrentPart() and Add3DSketch are part of your CAD API
Helix = CurrentPart()
PathName = 'Path_Segment_%d' % (Segment + 1)
Path = Helix.Add3DSketch(PathName)
Path.AddBspline(Points)
```

Alibre Script Examples, Demos, and Experiments. Contribute to Testbed-for-Alibre-Design/Alibre-Script development by creating an account on GitHub.

github.com