def getDistance(self): "Get distance between point and nearest intersection or bottom point along line." self.pointMinusBottomY = self.alongAway.point.y - self.alongAway.minimumY self.diagonalDistance = self.pointMinusBottomY * self.diagonalRatio if self.alongAway.pointIndex == None: return self.getDistanceToBottom() rotatedLoop = euclidean.getPointsRoundZAxis( self.intersectionYMirror, euclidean.getComplexPath( self.alongAway.loop ) ) rotatedPointComplex = rotatedLoop[ self.alongAway.pointIndex ] beginX = rotatedPointComplex.real endX = beginX + self.diagonalDistance + self.diagonalDistance xIntersectionIndexList = [] for pointIndex in self.alongAway.awayIndexes: beginComplex = rotatedLoop[ pointIndex ] endComplex = rotatedLoop[ (pointIndex + 1) % len( rotatedLoop ) ] xIntersection = euclidean.getXIntersectionIfExists( beginComplex, endComplex, rotatedPointComplex.imag ) if xIntersection != None: if xIntersection >= beginX and xIntersection < endX: xIntersectionIndexList.append( euclidean.XIntersectionIndex( pointIndex, xIntersection ) ) self.closestXDistance = 987654321.0 self.closestXIntersectionIndex = None for xIntersectionIndex in xIntersectionIndexList: xDistance = abs( xIntersectionIndex.x - beginX ) if xDistance < self.closestXDistance: self.closestXIntersectionIndex = xIntersectionIndex self.closestXDistance = xDistance if self.closestXIntersectionIndex != None: return self.closestXDistance return self.getDistanceToBottom()
def getManipulatedPaths(close, loop, prefix, sideLength, xmlElement): "Get path with overhangs removed or filled in." if len(loop) < 4: return [loop] loopComplex = euclidean.getComplexPath(loop) return euclidean.getVector3Paths([euclidean.getLoopConvex(loopComplex)], loop[0].z)
def getDistance(self): "Get distance between point and closest intersection or bottom point along line." self.pointMinusBottomY = self.alongAway.point.y - self.alongAway.minimumY self.diagonalDistance = self.pointMinusBottomY * self.diagonalRatio if self.alongAway.pointIndex == None: return self.getDistanceToBottom() rotatedLoop = euclidean.getRotatedComplexes( self.intersectionYMirror, euclidean.getComplexPath(self.alongAway.loop)) rotatedPointComplex = rotatedLoop[self.alongAway.pointIndex] beginX = rotatedPointComplex.real endX = beginX + self.diagonalDistance + self.diagonalDistance xIntersectionIndexList = [] for pointIndex in self.alongAway.awayIndexes: beginComplex = rotatedLoop[pointIndex] endComplex = rotatedLoop[(pointIndex + 1) % len(rotatedLoop)] xIntersection = euclidean.getXIntersectionIfExists( beginComplex, endComplex, rotatedPointComplex.imag) if xIntersection != None: if xIntersection >= beginX and xIntersection < endX: xIntersectionIndexList.append( euclidean.XIntersectionIndex(pointIndex, xIntersection)) self.closestXDistance = 987654321.0 self.closestXIntersectionIndex = None for xIntersectionIndex in xIntersectionIndexList: xDistance = abs(xIntersectionIndex.x - beginX) if xDistance < self.closestXDistance: self.closestXIntersectionIndex = xIntersectionIndex self.closestXDistance = xDistance if self.closestXIntersectionIndex != None: return self.closestXDistance return self.getDistanceToBottom()
def getInsetLoopsFromVector3Loop(loop, radius, thresholdRatio=0.9): 'Get the inset loops from vector3 loop, which might overlap.' if len(loop) < 2: return [loop] loopComplex = euclidean.getComplexPath(loop) loopComplexes = getInsetLoopsFromLoop(loopComplex, radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get path with outline." if len(loop) < 2: return [loop] derivation = OutlineDerivation(elementNode, prefix, sideLength) loopComplex = euclidean.getComplexPath(loop) if derivation.isClosed: loopComplexes = intercircle.getAroundsFromLoop(loopComplex, derivation.radius) else: loopComplexes = intercircle.getAroundsFromPath(loopComplex, derivation.radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def getManipulatedPaths(close, loop, prefix, sideLength, xmlElement): "Get path with overhangs removed or filled in." if len(loop) < 2: return [loop] isClosed = evaluate.getEvaluatedBooleanDefault(False, prefix + 'closed', xmlElement) radius = lineation.getStrokeRadiusByPrefix(prefix, xmlElement ) loopComplex = euclidean.getComplexPath(loop) if isClosed: loopComplexes = intercircle.getAroundsFromLoop(loopComplex, radius) else: loopComplexes = intercircle.getAroundsFromPath(loopComplex, radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get path with outline." if len(loop) < 2: return [loop] isClosed = evaluate.getEvaluatedBoolean(False, elementNode, prefix + 'closed') radius = lineation.getStrokeRadiusByPrefix(elementNode, prefix ) loopComplex = euclidean.getComplexPath(loop) if isClosed: loopComplexes = intercircle.getAroundsFromLoop(loopComplex, radius) else: loopComplexes = intercircle.getAroundsFromPath(loopComplex, radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get path with outline." if len(loop) < 2: return [loop] isClosed = evaluate.getEvaluatedBoolean(False, elementNode, prefix + 'closed') radius = lineation.getStrokeRadiusByPrefix(elementNode, prefix) loopComplex = euclidean.getComplexPath(loop) if isClosed: loopComplexes = intercircle.getAroundsFromLoop(loopComplex, radius) else: loopComplexes = intercircle.getAroundsFromPath(loopComplex, radius) return euclidean.getVector3Paths(loopComplexes, loop[0].z)
def processSVGElement(self, fileName): "Parse SVG element and store the layers." self.fileName = fileName paths = self.xmlElement.object.getPaths() if len(paths) < 1: return firstPath = paths[0] if len(firstPath) < 1: return rotatedLoopLayer = euclidean.RotatedLoopLayer(firstPath[0].z) self.rotatedLoopLayers.append(rotatedLoopLayer) for path in paths: rotatedLoopLayer.loops.append(euclidean.getComplexPath(path)) self.cornerMaximum = Vector3(-999999999.0, -999999999.0, -999999999.0) self.cornerMinimum = Vector3(999999999.0, 999999999.0, 999999999.0) svg_writer.setSVGCarvingCorners(self.cornerMaximum, self.cornerMinimum, self.layerThickness, self.rotatedLoopLayers)
def processSVGElement(self, fileName): 'Parse SVG element and store the layers.' self.fileName = fileName paths = self.xmlElement.object.getPaths() if len(paths) < 1: return firstPath = paths[0] if len(firstPath) < 1: return rotatedLoopLayer = euclidean.RotatedLoopLayer(firstPath[0].z) self.rotatedLoopLayers.append(rotatedLoopLayer) for path in paths: rotatedLoopLayer.loops.append(euclidean.getComplexPath(path)) self.cornerMaximum = Vector3(-999999999.0, -999999999.0, -999999999.0) self.cornerMinimum = Vector3(999999999.0, 999999999.0, 999999999.0) svg_writer.setSVGCarvingCorners(self.cornerMaximum, self.cornerMinimum, self.layerThickness, self.rotatedLoopLayers)
def processSVGElement(self, fileName): 'Parse SVG element and store the layers.' self.fileName = fileName paths = self.elementNode.xmlObject.getPaths() oldZ = None self.loopLayers = [] loopLayer = None for path in paths: if len(path) > 0: z = path[0].z if z != oldZ: loopLayer = euclidean.LoopLayer(z) self.loopLayers.append(loopLayer) oldZ = z loopLayer.loops.append(euclidean.getComplexPath(path)) if len(self.loopLayers) < 1: return self.cornerMaximum = Vector3(-987654321.0, -987654321.0, -987654321.0) self.cornerMinimum = Vector3(987654321.0, 987654321.0, 987654321.0) svg_writer.setSVGCarvingCorners(self.cornerMaximum, self.cornerMinimum, self.layerThickness, self.loopLayers)
def processSVGElement(self, fileName): """Parse SVG element and store the layers.""" self.fileName = fileName paths = self.xmlElement.xmlObject.getPaths() oldZ = None self.rotatedLoopLayers = [] rotatedLoopLayer = None for path in paths: if len(path) > 0: z = path[0].z if z != oldZ: rotatedLoopLayer = euclidean.RotatedLoopLayer(z) self.rotatedLoopLayers.append(rotatedLoopLayer) oldZ = z rotatedLoopLayer.loops.append(euclidean.getComplexPath(path)) if len(self.rotatedLoopLayers) < 1: return self.cornerMaximum = Vector3(-987654321.0, -987654321.0, -987654321.0) self.cornerMinimum = Vector3(987654321.0, 987654321.0, 987654321.0) svg_writer.setSVGCarvingCorners(self.cornerMaximum, self.cornerMinimum, self.extrusionHeight, self.rotatedLoopLayers)
def getManipulatedPaths(close, elementNode, loop, prefix, sideLength): "Get path with overhangs removed or filled in." if len(loop) < 4: return [loop] loopComplex = euclidean.getComplexPath(loop) return euclidean.getVector3Paths([euclidean.getLoopConvex(loopComplex)], loop[0].z)
def setToXMLElement(self, xmlElement): "Set to the xmlElement." self.clearanceOverWavelength = evaluate.getEvaluatedFloatDefault( self.clearanceOverWavelength, 'clearanceOverWavelength', xmlElement) self.collarWidthOverShaftRadius = evaluate.getEvaluatedFloatDefault( self.collarWidthOverShaftRadius, 'collarWidthOverShaftRadius', xmlElement) self.copyShallow = xmlElement.getCopyShallow() self.creationType = evaluate.getEvaluatedStringDefault(self.creationType, 'creationType', xmlElement) self.gearCollarThicknessOverThickness = evaluate.getEvaluatedFloatDefault( self.gearCollarThicknessOverThickness, 'gearCollarThicknessOverThickness', xmlElement) self.helixAngle = evaluate.getEvaluatedFloatDefault(self.helixAngle, 'helixAngle', xmlElement) self.helixType = evaluate.getEvaluatedStringDefault(self.helixType, 'helixType', xmlElement) self.keywayRadiusOverRadius = evaluate.getEvaluatedFloatDefault( self.keywayRadiusOverRadius, 'keywayRadiusOverRadius', xmlElement) self.lighteningHoleMarginOverRimWidth = evaluate.getEvaluatedFloatDefault( self.lighteningHoleMarginOverRimWidth, 'lighteningHoleMarginOverRimWidth', xmlElement) self.lighteningHoleMinimumRadius = evaluate.getEvaluatedFloatDefault( self.lighteningHoleMinimumRadius, 'lighteningHoleMinimumRadius', xmlElement) self.moveType = evaluate.getEvaluatedStringDefault(self.moveType, 'moveType', xmlElement) self.operatingAngle = evaluate.getEvaluatedFloatDefault(self.operatingAngle, 'operatingAngle', xmlElement) self.pinionCollarThicknessOverThickness = evaluate.getEvaluatedFloatDefault( self.pinionCollarThicknessOverThickness, 'pinionCollarThicknessOverThickness', xmlElement) self.pinionThickness = evaluate.getEvaluatedFloatDefault(self.pinionThickness, 'pinionThickness', xmlElement) self.pinionThickness = evaluate.getEvaluatedFloatDefault(self.pinionThickness, 'thickness', xmlElement) self.pitchRadius = evaluate.getEvaluatedFloatDefault(self.pitchRadius, 'pitchRadius', xmlElement) self.plateClearanceOverThickness = evaluate.getEvaluatedFloatDefault( self.plateClearanceOverThickness, 'plateClearanceOverThickness', xmlElement) self.plateThicknessOverThickness = evaluate.getEvaluatedFloatDefault( self.plateThicknessOverThickness, 'plateThicknessOverThickness', xmlElement) self.pressureAngle = evaluate.getEvaluatedFloatDefault(self.pressureAngle, 'pressureAngle', xmlElement) self.profileSurfaces = evaluate.getEvaluatedIntDefault(self.profileSurfaces, 'profileSurfaces', xmlElement) self.rackHoleRadiusOverWidth = evaluate.getEvaluatedFloatDefault( self.rackHoleRadiusOverWidth, 'rackHoleRadiusOverWidth', xmlElement) self.rackHoleBelowOverWidth = evaluate.getEvaluatedFloatDefault( self.rackHoleBelowOverWidth, 'rackHoleBelowOverWidth', xmlElement) self.rackHoleStep = evaluate.getEvaluatedFloatDefault( self.rackHoleStep, 'rackHoleStep', xmlElement) self.rackLengthOverRadius = evaluate.getEvaluatedFloatDefault(self.rackLengthOverRadius, 'rackLengthOverRadius', xmlElement) self.rackWidthOverThickness = evaluate.getEvaluatedFloatDefault( self.rackWidthOverThickness, 'rackWidthOverThickness', xmlElement) self.rimWidthOverRadius = evaluate.getEvaluatedFloatDefault(self.rimWidthOverRadius, 'rimWidthOverRadius', xmlElement) self.rootBevelOverClearance = evaluate.getEvaluatedFloatDefault( self.rootBevelOverClearance, 'rootBevelOverClearance', xmlElement) self.shaftDepthBottomOverRadius = evaluate.getEvaluatedFloatDefault( self.shaftDepthBottomOverRadius, 'shaftDepthBottomOverRadius', xmlElement) self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault( self.shaftDepthTopOverRadius, 'shaftDepthOverRadius', xmlElement) self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault( self.shaftDepthTopOverRadius, 'shaftDepthTopOverRadius', xmlElement) self.shaftRadiusOverPitchRadius = evaluate.getEvaluatedFloatDefault( self.shaftRadiusOverPitchRadius, 'shaftRadiusOverPitchRadius', xmlElement) self.shaftSides = evaluate.getEvaluatedIntDefault(self.shaftSides, 'shaftSides', xmlElement) self.teethPinion = evaluate.getEvaluatedIntDefault(self.teethPinion, 'teeth', xmlElement) self.teethPinion = evaluate.getEvaluatedIntDefault(self.teethPinion, 'teethPinion', xmlElement) self.teethGear = evaluate.getEvaluatedIntDefault(self.teethGear, 'teethGear', xmlElement) self.tipBevelOverClearance = evaluate.getEvaluatedFloatDefault(self.tipBevelOverClearance, 'tipBevelOverClearance', xmlElement) self.toothWidthMultiplier = evaluate.getEvaluatedFloatDefault(self.toothWidthMultiplier, 'toothWidthMultiplier', xmlElement) # Set absolute variables. self.wavelength = self.pitchRadius * 2.0 * math.pi / float(self.teethPinion) if self.clearance == None: self.clearance = self.wavelength * self.clearanceOverWavelength self.clearance = evaluate.getEvaluatedFloatDefault(self.clearance, 'clearance', xmlElement) if self.gearCollarThickness == None: self.gearCollarThickness = self.pinionThickness * self.gearCollarThicknessOverThickness self.gearCollarThickness = evaluate.getEvaluatedFloatDefault(self.gearCollarThickness, 'gearCollarThickness', xmlElement) if self.gearHolePaths == None: self.gearHolePaths = evaluate.getTransformedPathsByKey('gearHolePaths', xmlElement) if self.pinionCollarThickness == None: self.pinionCollarThickness = self.pinionThickness * self.pinionCollarThicknessOverThickness self.pinionCollarThickness = evaluate.getEvaluatedFloatDefault(self.pinionCollarThickness, 'pinionCollarThickness', xmlElement) if self.plateThickness == None: self.plateThickness = self.pinionThickness * self.plateThicknessOverThickness self.plateThickness = evaluate.getEvaluatedFloatDefault(self.plateThickness, 'plateThickness', xmlElement) if self.plateClearance == None: self.plateClearance = self.plateThickness * self.plateClearanceOverThickness self.plateClearance = evaluate.getEvaluatedFloatDefault(self.plateClearance, 'plateClearance', xmlElement) if self.rackLength == None: self.rackLength = self.pitchRadius * self.rackLengthOverRadius self.rackLength = evaluate.getEvaluatedFloatDefault(self.rackLength, 'rackLength', xmlElement) self.rackDemilength = 0.5 * self.rackLength if self.rackWidth == None: self.rackWidth = self.pinionThickness * self.rackWidthOverThickness self.rackWidth = evaluate.getEvaluatedFloatDefault(self.rackWidth, 'rackWidth', xmlElement) if self.rimWidth == None: self.rimWidth = self.pitchRadius * self.rimWidthOverRadius self.rimWidth = evaluate.getEvaluatedFloatDefault(self.rimWidth, 'rimWidth', xmlElement) if self.rootBevel == None: self.rootBevel = self.clearance * self.rootBevelOverClearance self.rootBevel = evaluate.getEvaluatedFloatDefault(self.rootBevel, 'rootBevel', xmlElement) if self.shaftRadius == None: self.shaftRadius = self.pitchRadius * self.shaftRadiusOverPitchRadius self.shaftRadius = evaluate.getEvaluatedFloatDefault(self.shaftRadius, 'shaftRadius', xmlElement) if self.collarWidth == None: self.collarWidth = self.shaftRadius * self.collarWidthOverShaftRadius self.collarWidth = evaluate.getEvaluatedFloatDefault(self.collarWidth, 'collarWidth', xmlElement) if self.keywayRadius == None: self.keywayRadius = self.shaftRadius * self.keywayRadiusOverRadius self.keywayRadius = lineation.getFloatByPrefixBeginEnd('keywayRadius', 'keywayDiameter', self.keywayRadius, xmlElement) if self.lighteningHoleMargin == None: self.lighteningHoleMargin = self.rimWidth * self.lighteningHoleMarginOverRimWidth self.lighteningHoleMargin = evaluate.getEvaluatedFloatDefault( self.lighteningHoleMargin, 'lighteningHoleMargin', xmlElement) if self.rackHoleBelow == None: self.rackHoleBelow = self.rackWidth * self.rackHoleBelowOverWidth self.rackHoleBelow = evaluate.getEvaluatedFloatDefault(self.rackHoleBelow, 'rackHoleBelow', xmlElement) if self.rackHoleRadius == None: self.rackHoleRadius = self.rackWidth * self.rackHoleRadiusOverWidth self.rackHoleRadius = lineation.getFloatByPrefixBeginEnd('rackHoleRadius', 'rackHoleDiameter', self.rackHoleRadius, xmlElement) if self.rackHoleStep == None: self.rackHoleStep = self.rackWidth * self.rackHoleStepOverWidth self.rackHoleStep = evaluate.getEvaluatedFloatDefault(self.rackHoleStep, 'rackHoleStep', xmlElement) if self.shaftDepthBottom == None: self.shaftDepthBottom = self.shaftRadius * self.shaftDepthBottomOverRadius self.shaftDepthBottom = evaluate.getEvaluatedFloatDefault(self.shaftDepthBottom, 'shaftDepthBottom', xmlElement) if self.shaftDepthTop == None: self.shaftDepthTop = self.shaftRadius * self.shaftDepthTopOverRadius self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepth', xmlElement) self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepthTop', xmlElement) if self.shaftPath == None: self.shaftPath = evaluate.getTransformedPathByKey('shaftPath', xmlElement) if len(self.shaftPath) < 3: self.shaftPath = shaft.getShaftPath(self.shaftDepthBottom, self.shaftDepthTop, self.shaftRadius, -self.shaftSides) if self.tipBevel == None: self.tipBevel = self.clearance * self.tipBevelOverClearance self.tipBevel = evaluate.getEvaluatedFloatDefault(self.tipBevel, 'tipBevel', xmlElement) # Set derived values. self.helixRadian = math.radians(self.helixAngle) if self.teethGear <= 0.0 and self.operatingAngle != 180.0: print('Warning, an operatingAngle other than 180 degrees can only work with a positive number of gear teeth.') print('Therefore the operatingAngle will be reset to 180 degrees.') self.operatingAngle = 180.0 self.tanHelix = math.tan(self.helixRadian) self.helixThickness = self.tanHelix * self.pinionThickness self.operatingRadian = math.radians(self.operatingAngle) self.pitchRadiusGear = self.pitchRadius * float(self.teethGear) / float(self.teethPinion) self.pressureRadian = math.radians(self.pressureAngle) self.cosPressure = math.cos(self.pressureRadian) self.sinPressure = math.sin(self.pressureRadian) self.tanPressure = math.tan(self.pressureRadian) self.halfWavelength = 0.5 * self.wavelength if self.helixPath == None: self.helixPath = euclidean.getComplexPath(evaluate.getTransformedPathByKey('helixPath', xmlElement)) if len(self.helixPath) < 1: self.helixPath = getHelixComplexPath(self, xmlElement) self.quarterWavelength = 0.25 * self.wavelength self.shaftRimRadius = self.shaftRadius + self.collarWidth self.toothProfileHalf = getToothProfileHalfCylinder(self, self.pitchRadius) self.toothProfileHalf = getWidthMultipliedPath(self.toothProfileHalf, self.toothWidthMultiplier) self.addendum = self.toothProfileHalf[-1].imag - self.pitchRadius self.dedendum = abs(self.toothProfileHalf[-1]) - self.pitchRadius + self.clearance self.pinionToothProfile = getToothProfileCylinderByProfile(self, self.pitchRadius, self.teethPinion, self.toothProfileHalf) self.xmlElement = xmlElement
def __init__(self, xmlElement): 'Set defaults.' self.clearanceOverWavelength = evaluate.getEvaluatedFloatDefault(0.1, 'clearanceOverWavelength', xmlElement) self.collarWidthOverShaftRadius = evaluate.getEvaluatedFloatDefault(1.0, 'collarWidthOverShaftRadius', xmlElement) self.copyShallow = xmlElement.getCopyShallow() self.creationType = evaluate.getEvaluatedStringDefault('both', 'creationType', xmlElement) self.creationTypeMenuRadioStrings = 'both first second'.split() self.gearCollarThicknessOverThickness = evaluate.getEvaluatedFloatDefault( 0.0, 'gearCollarThicknessOverThickness', xmlElement) self.helixAngle = evaluate.getEvaluatedFloatDefault(0.0, 'helixAngle', xmlElement) self.helixType = evaluate.getEvaluatedStringDefault('basic', 'helixType', xmlElement) self.helixTypeMenuRadioStrings = 'basic herringbone parabolic'.split() self.keywayRadiusOverRadius = evaluate.getEvaluatedFloatDefault(0.5, 'keywayRadiusOverRadius', xmlElement) self.lighteningHoleMarginOverRimWidth = evaluate.getEvaluatedFloatDefault( 1.0, 'lighteningHoleMarginOverRimWidth', xmlElement) self.lighteningHoleMinimumRadius = evaluate.getEvaluatedFloatDefault( 1.0, 'lighteningHoleMinimumRadius', xmlElement) self.moveType = evaluate.getEvaluatedStringDefault('separate', 'moveType', xmlElement) self.moveTypeMenuRadioStrings = 'mesh none separate vertical'.split() self.operatingAngle = evaluate.getEvaluatedFloatDefault(180.0, 'operatingAngle', xmlElement) self.pinionCollarThicknessOverThickness = evaluate.getEvaluatedFloatDefault( 0.0, 'pinionCollarThicknessOverThickness', xmlElement) self.pinionThickness = evaluate.getEvaluatedFloatDefault(10.0, 'pinionThickness', xmlElement) self.pinionThickness = evaluate.getEvaluatedFloatDefault(self.pinionThickness, 'thickness', xmlElement) self.plateClearanceOverThickness = evaluate.getEvaluatedFloatDefault(0.2, 'plateClearanceOverThickness', xmlElement) self.plateThicknessOverThickness = evaluate.getEvaluatedFloatDefault(0.5, 'plateThicknessOverThickness', xmlElement) self.pressureAngle = evaluate.getEvaluatedFloatDefault(20.0, 'pressureAngle', xmlElement) self.profileSurfaces = evaluate.getEvaluatedIntDefault(11, 'profileSurfaces', xmlElement) self.rackHoleRadiusOverWidth = evaluate.getEvaluatedFloatDefault(0.0, 'rackHoleRadiusOverWidth', xmlElement) self.rackHoleBelowOverWidth = evaluate.getEvaluatedFloatDefault(0.6, 'rackHoleBelowOverWidth', xmlElement) self.rackHoleStepOverWidth = evaluate.getEvaluatedFloatDefault(1.0, 'rackHoleStepOverWidth', xmlElement) self.rackLengthOverRadius = evaluate.getEvaluatedFloatDefault(math.pi + math.pi, 'rackLengthOverRadius', xmlElement) self.rackWidthOverThickness = evaluate.getEvaluatedFloatDefault(1.0, 'rackWidthOverThickness', xmlElement) self.rimWidthOverRadius = evaluate.getEvaluatedFloatDefault(0.2, 'rimWidthOverRadius', xmlElement) self.rootBevelOverClearance = evaluate.getEvaluatedFloatDefault(0.5, 'rootBevelOverClearance', xmlElement) self.shaftDepthBottomOverRadius = evaluate.getEvaluatedFloatDefault(0.0, 'shaftDepthBottomOverRadius', xmlElement) self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault(0.0, 'shaftDepthOverRadius', xmlElement) self.shaftDepthTopOverRadius = evaluate.getEvaluatedFloatDefault( self.shaftDepthTopOverRadius, 'shaftDepthTopOverRadius', xmlElement) self.shaftRadiusOverPitchRadius = evaluate.getEvaluatedFloatDefault(0.0, 'shaftRadiusOverPitchRadius', xmlElement) self.shaftSides = evaluate.getEvaluatedIntDefault(4, 'shaftSides', xmlElement) self.teethPinion = evaluate.getEvaluatedIntDefault(7, 'teeth', xmlElement) self.teethPinion = evaluate.getEvaluatedIntDefault(self.teethPinion, 'teethPinion', xmlElement) self.teethGear = evaluate.getEvaluatedIntDefault(17, 'teethGear', xmlElement) totalTeethOverPinionTeeth = float(self.teethGear + self.teethPinion) / float(self.teethPinion) self.centerDistance = evaluate.getEvaluatedFloatDefault(20.0 * totalTeethOverPinionTeeth, 'centerDistance', xmlElement) derivedPitchRadius = self.centerDistance / totalTeethOverPinionTeeth self.pitchRadius = evaluate.getEvaluatedFloatDefault(derivedPitchRadius, 'pitchRadius', xmlElement) self.tipBevelOverClearance = evaluate.getEvaluatedFloatDefault(0.1, 'tipBevelOverClearance', xmlElement) # tooth multiplied by 0.99999 to avoid an intersection self.toothWidthMultiplier = evaluate.getEvaluatedFloatDefault(0.99999, 'toothWidthMultiplier', xmlElement) # Set absolute variables. self.wavelength = self.pitchRadius * 2.0 * math.pi / float(self.teethPinion) self.clearance = self.wavelength * self.clearanceOverWavelength self.clearance = evaluate.getEvaluatedFloatDefault(self.clearance, 'clearance', xmlElement) self.gearCollarThickness = self.pinionThickness * self.gearCollarThicknessOverThickness self.gearCollarThickness = evaluate.getEvaluatedFloatDefault(self.gearCollarThickness, 'gearCollarThickness', xmlElement) self.gearHolePaths = evaluate.getTransformedPathsByKey([], 'gearHolePaths', xmlElement) self.pinionCollarThickness = self.pinionThickness * self.pinionCollarThicknessOverThickness self.pinionCollarThickness = evaluate.getEvaluatedFloatDefault(self.pinionCollarThickness, 'pinionCollarThickness', xmlElement) self.plateThickness = self.pinionThickness * self.plateThicknessOverThickness self.plateThickness = evaluate.getEvaluatedFloatDefault(self.plateThickness, 'plateThickness', xmlElement) self.plateClearance = self.plateThickness * self.plateClearanceOverThickness self.plateClearance = evaluate.getEvaluatedFloatDefault(self.plateClearance, 'plateClearance', xmlElement) self.rackLength = self.pitchRadius * self.rackLengthOverRadius self.rackLength = evaluate.getEvaluatedFloatDefault(self.rackLength, 'rackLength', xmlElement) self.rackDemilength = 0.5 * self.rackLength self.rackWidth = self.pinionThickness * self.rackWidthOverThickness self.rackWidth = evaluate.getEvaluatedFloatDefault(self.rackWidth, 'rackWidth', xmlElement) self.rimWidth = self.pitchRadius * self.rimWidthOverRadius self.rimWidth = evaluate.getEvaluatedFloatDefault(self.rimWidth, 'rimWidth', xmlElement) self.rootBevel = self.clearance * self.rootBevelOverClearance self.rootBevel = evaluate.getEvaluatedFloatDefault(self.rootBevel, 'rootBevel', xmlElement) self.shaftRadius = self.pitchRadius * self.shaftRadiusOverPitchRadius self.shaftRadius = evaluate.getEvaluatedFloatDefault(self.shaftRadius, 'shaftRadius', xmlElement) self.collarWidth = self.shaftRadius * self.collarWidthOverShaftRadius self.collarWidth = evaluate.getEvaluatedFloatDefault(self.collarWidth, 'collarWidth', xmlElement) self.keywayRadius = self.shaftRadius * self.keywayRadiusOverRadius self.keywayRadius = lineation.getFloatByPrefixBeginEnd('keywayRadius', 'keywayDiameter', self.keywayRadius, xmlElement) self.lighteningHoleMargin = self.rimWidth * self.lighteningHoleMarginOverRimWidth self.lighteningHoleMargin = evaluate.getEvaluatedFloatDefault( self.lighteningHoleMargin, 'lighteningHoleMargin', xmlElement) self.rackHoleBelow = self.rackWidth * self.rackHoleBelowOverWidth self.rackHoleBelow = evaluate.getEvaluatedFloatDefault(self.rackHoleBelow, 'rackHoleBelow', xmlElement) self.rackHoleRadius = self.rackWidth * self.rackHoleRadiusOverWidth self.rackHoleRadius = lineation.getFloatByPrefixBeginEnd('rackHoleRadius', 'rackHoleDiameter', self.rackHoleRadius, xmlElement) self.rackHoleStep = self.rackWidth * self.rackHoleStepOverWidth self.rackHoleStep = evaluate.getEvaluatedFloatDefault(self.rackHoleStep, 'rackHoleStep', xmlElement) self.shaftDepthBottom = self.shaftRadius * self.shaftDepthBottomOverRadius self.shaftDepthBottom = evaluate.getEvaluatedFloatDefault(self.shaftDepthBottom, 'shaftDepthBottom', xmlElement) self.shaftDepthTop = self.shaftRadius * self.shaftDepthTopOverRadius self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepth', xmlElement) self.shaftDepthTop = evaluate.getEvaluatedFloatDefault(self.shaftDepthTop, 'shaftDepthTop', xmlElement) self.shaftPath = evaluate.getTransformedPathByKey([], 'shaftPath', xmlElement) if len(self.shaftPath) < 3: self.shaftPath = shaft.getShaftPath(self.shaftDepthBottom, self.shaftDepthTop, self.shaftRadius, -self.shaftSides) self.tipBevel = self.clearance * self.tipBevelOverClearance self.tipBevel = evaluate.getEvaluatedFloatDefault(self.tipBevel, 'tipBevel', xmlElement) # Set derived values. self.helixRadian = math.radians(self.helixAngle) if self.teethGear <= 0.0 and self.operatingAngle != 180.0: print('Warning, an operatingAngle other than 180 degrees can only work with a positive number of gear teeth.') print('Therefore the operatingAngle will be reset to 180 degrees.') self.operatingAngle = 180.0 self.tanHelix = math.tan(self.helixRadian) self.helixThickness = self.tanHelix * self.pinionThickness self.operatingRadian = math.radians(self.operatingAngle) self.pitchRadiusGear = self.pitchRadius * float(self.teethGear) / float(self.teethPinion) self.pressureRadian = math.radians(self.pressureAngle) self.cosPressure = math.cos(self.pressureRadian) self.sinPressure = math.sin(self.pressureRadian) self.tanPressure = math.tan(self.pressureRadian) self.halfWavelength = 0.5 * self.wavelength self.helixPath = euclidean.getComplexPath(evaluate.getTransformedPathByKey([], 'helixPath', xmlElement)) if len(self.helixPath) < 1: self.helixPath = getHelixComplexPath(self, xmlElement) self.quarterWavelength = 0.25 * self.wavelength self.shaftRimRadius = self.shaftRadius + self.collarWidth self.toothProfileHalf = getToothProfileHalfCylinder(self, self.pitchRadius) self.toothProfileHalf = getWidthMultipliedPath(self.toothProfileHalf, self.toothWidthMultiplier) self.addendum = self.toothProfileHalf[-1].imag - self.pitchRadius self.dedendum = abs(self.toothProfileHalf[-1]) - self.pitchRadius + self.clearance self.pinionToothProfile = getToothProfileCylinderByProfile(self, self.pitchRadius, self.teethPinion, self.toothProfileHalf) self.xmlElement = xmlElement