#Create Parameterized Phython Scripting in SpaceClaim to Generate Camshaft Profiles #By Pat Tessaro, P.E. #Ozen Engineering #12-18-24 import math # Camshaft lobe base circle diameter (in inches) CamBaseCircleDiameterInches = 1.5 # Camshaft lobe Center hole circle diameter (in inches) CamCenterHoleDiameterInches = 1.0 # Camshaft Lobe Duration (in Crankshaft Degrees) CamLobeDurationDegrees=280 # Camshaft Maximum Lift (in inches) CamMaxLiftInches=0.400 # Camshaft lobe Width (in inches) LobeWidthInches = 1.0 CamLobeDurationRadians=CamLobeDurationDegrees*math.pi/180/2.0 CalcAngleRadians = (90.0 - CamLobeDurationDegrees/4.0)*math.pi/180.0 if CalcAngleRadians == 0.0: NoseCircleInches = CamBaseCircleDiameterInches else: CamGeometryMaxLiftInches=abs((CamBaseCircleDiameterInches/2.0)*(1 - 1/math.sin(CalcAngleRadians))) if CamMaxLiftInches>=CamGeometryMaxLiftInches: CamMaxLiftInches=CamGeometryMaxLiftInches NoseCircleInches=0.0 else: NoseCircleInches = ((CamMaxLiftInches)/(1 - 1/math.sin(CalcAngleRadians)) + CamBaseCircleDiameterInches/2.0)*2.0 NoseCircleMM=NoseCircleInches*25.4 BaseCircleMM=CamBaseCircleDiameterInches*25.4 CenterHoleMM=CamCenterHoleDiameterInches*25.4 LobeWidthMM=LobeWidthInches*25.4 CamMaxLiftMM=CamMaxLiftInches*25.4 NoseCircleCenterMM = ((BaseCircleMM - NoseCircleMM)/2.0 + CamMaxLiftMM) # Set Sketch Plane sectionPlane = Plane.PlaneXY result = ViewHelper.SetSketchPlane(sectionPlane, None) # EndBlock # Sketch Center Base Circle BaseCircleOrigin = Point2D.Create(MM(0), MM(0)) result = SketchCircle.Create(origin, MM(CenterHoleMM/2.0)) # EndBlock # Create Base Circle Sweep Arc BaseCircleArcStart = Point2D.Create(MM(BaseCircleMM/2.0*math.cos(CalcAngleRadians)), MM(BaseCircleMM/2.0*math.sin(CalcAngleRadians))) BaseCircleArcEnd = Point2D.Create(MM(-BaseCircleMM/2.0*math.cos(CalcAngleRadians)), MM(BaseCircleMM/2.0*math.sin(CalcAngleRadians))) senseClockWise = True result = SketchArc.CreateSweepArc(BaseCircleOrigin , BaseCircleArcStart, BaseCircleArcEnd, senseClockWise) # EndBlock # Create Nose Circle Sweep Arc if NoseCircleMM==0: NoseCircleArcStart = Point2D.Create(MM(0.0), MM(NoseCircleCenterMM + NoseCircleMM/2.0)) NoseCircleArcEnd = NoseCircleArcStart else: NoseCircleOrigin = Point2D.Create(MM(0), MM(NoseCircleCenterMM)) NoseCircleArcStart = Point2D.Create(MM(NoseCircleMM/2.0*math.cos(CalcAngleRadians)), MM(NoseCircleCenterMM + NoseCircleMM/2.0*math.sin(CalcAngleRadians))) NoseCircleArcEnd = Point2D.Create(MM(-NoseCircleMM/2.0*math.cos(CalcAngleRadians)), MM(NoseCircleCenterMM + NoseCircleMM/2.0*math.sin(CalcAngleRadians))) senseClockWise = False result = SketchArc.CreateSweepArc(NoseCircleOrigin , NoseCircleArcStart, NoseCircleArcEnd, senseClockWise) # EndBlock # Sketch Line result = SketchLine.Create(NoseCircleArcStart, BaseCircleArcStart) # EndBlock # Sketch Line result = SketchLine.Create(NoseCircleArcEnd, BaseCircleArcEnd) # EndBlock # Solidify Sketch mode = InteractionMode.Solid result = ViewHelper.SetViewMode(mode, None) # EndBlock # Extrude 1 Face selection = FaceSelection.Create(GetRootPart().Bodies[0].Faces[0]) options = ExtrudeFaceOptions() options.KeepMirror = True options.KeepLayoutSurfaces = False options.KeepCompositeFaceRelationships = True options.PullSymmetric = False options.OffsetMode = OffsetMode.IgnoreRelationships options.Copy = False options.ForceDoAsExtrude = False options.ExtrudeType = ExtrudeType.Add result = ExtrudeFaces.Execute(selection, MM(LobeWidthMM), options) # EndBlock