Skip to content

Commit e9c0104

Browse files
committed
Added .bsx Star Grain importer
OpenMotor now supports Star Grains from Burn Sim.
1 parent e5fb420 commit e9c0104

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

uilib/converters/burnsimImporter.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import xml.etree.ElementTree as ET
22

33
import motorlib
4+
from numpy import pi, cos
45

56
from ..converter import Importer
67

@@ -9,14 +10,14 @@
910
'1': motorlib.grains.BatesGrain,
1011
'2': motorlib.grains.DGrain,
1112
'3': motorlib.grains.MoonBurner,
13+
'4': motorlib.grains.StarGrain,
1214
'5': motorlib.grains.CGrain,
1315
'6': motorlib.grains.XCore,
1416
'7': motorlib.grains.Finocyl
1517
}
1618

1719
# BS type -> label for grains we know about but can't import
1820
UNSUPPORTED_GRAINS = {
19-
'4': 'Star',
2021
'8': 'Tablet',
2122
'9': 'Pie Segment'
2223
}
@@ -93,6 +94,16 @@ def doConversion(self, path):
9394

9495
elif grainType == '3': # Moonburner specific properties
9596
motor.grains[-1].setProperty('coreOffset', inToM(child.attrib['CoreOffset']))
97+
98+
elif grainType == '4': #Star Grain:
99+
numPoints = int(child.attrib['Points'])
100+
minorRadius = float(child.attrib['MinorWidth'])/2
101+
majorRadius = float(child.attrib['MajorWidth'])/2
102+
base_length = minorRadius * (2-(2*cos((2*pi)/numPoints)))**.5
103+
point_height = majorRadius - (minorRadius*cos(pi/numPoints))
104+
motor.grains[-1].setProperty('numPoints', numPoints)
105+
motor.grains[-1].setProperty('pointLength', inToM(point_height))
106+
motor.grains[-1].setProperty('pointWidth', inToM(base_length))
96107

97108
elif grainType == '5': # C grain specific properties
98109
motor.grains[-1].setProperty('slotWidth', inToM(child.attrib['SlotWidth']))

0 commit comments

Comments
 (0)