Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added .bsx Star Grain importer #211

Open
wants to merge 1 commit into
base: staging
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion uilib/converters/burnsimImporter.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import xml.etree.ElementTree as ET

import motorlib
from numpy import pi, cos

from ..converter import Importer

Expand All @@ -9,14 +10,14 @@
'1': motorlib.grains.BatesGrain,
'2': motorlib.grains.DGrain,
'3': motorlib.grains.MoonBurner,
'4': motorlib.grains.StarGrain,
'5': motorlib.grains.CGrain,
'6': motorlib.grains.XCore,
'7': motorlib.grains.Finocyl
}

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

elif grainType == '3': # Moonburner specific properties
motor.grains[-1].setProperty('coreOffset', inToM(child.attrib['CoreOffset']))

elif grainType == '4': #Star Grain:
numPoints = int(child.attrib['Points'])
minorRadius = float(child.attrib['MinorWidth'])/2
majorRadius = float(child.attrib['MajorWidth'])/2
base_length = minorRadius * (2-(2*cos((2*pi)/numPoints)))**.5
point_height = majorRadius - (minorRadius*cos(pi/numPoints))
motor.grains[-1].setProperty('numPoints', numPoints)
motor.grains[-1].setProperty('pointLength', inToM(point_height))
motor.grains[-1].setProperty('pointWidth', inToM(base_length))

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