|
1 | 1 | import xml.etree.ElementTree as ET
|
2 | 2 |
|
3 | 3 | import motorlib
|
| 4 | +from numpy import pi, cos |
4 | 5 |
|
5 | 6 | from ..converter import Importer
|
6 | 7 |
|
|
9 | 10 | '1': motorlib.grains.BatesGrain,
|
10 | 11 | '2': motorlib.grains.DGrain,
|
11 | 12 | '3': motorlib.grains.MoonBurner,
|
| 13 | + '4': motorlib.grains.StarGrain, |
12 | 14 | '5': motorlib.grains.CGrain,
|
13 | 15 | '6': motorlib.grains.XCore,
|
14 | 16 | '7': motorlib.grains.Finocyl
|
15 | 17 | }
|
16 | 18 |
|
17 | 19 | # BS type -> label for grains we know about but can't import
|
18 | 20 | UNSUPPORTED_GRAINS = {
|
19 |
| - '4': 'Star', |
20 | 21 | '8': 'Tablet',
|
21 | 22 | '9': 'Pie Segment'
|
22 | 23 | }
|
@@ -93,6 +94,16 @@ def doConversion(self, path):
|
93 | 94 |
|
94 | 95 | elif grainType == '3': # Moonburner specific properties
|
95 | 96 | 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)) |
96 | 107 |
|
97 | 108 | elif grainType == '5': # C grain specific properties
|
98 | 109 | motor.grains[-1].setProperty('slotWidth', inToM(child.attrib['SlotWidth']))
|
|
0 commit comments