Im super sorry friend, barely functioning on like 3 hours of sleep. In looking back on this and copying the message 3 times due to it not posting. I coppied the wrong code for you to look at. This should have been more close to the below code.
Dim BackTrimCol As ObjectCollection = oTO.CreateObjectCollection
Dim BackTrimSketch As PlanarSketch
Dim BackProfile As Profile
Dim BackStartPoint As SketchPoint, BackRectPoint As SketchPoint, Rect2StartPoint As SketchPoint, Rect2EndPoint As SketchPoint
Dim Rectangle2 As SketchEntitiesEnumerator
Dim Rect2Line1 As SketchLine, Rect2Line3 As SketchLine
Dim BackStartDis As DimensionConstraint, Rect2Line1Con As DimensionConstraint, CenterControlA As DimensionConstraint, Rect2Line3con As DimensionConstraint, CenterControlB As DimensionConstraint
Dim BackRevolveTrim as RevolveFeature
BackTrimSketch = oCompDef.Sketches.Add(oUCS.YZPlane)
BackTrimSketch.Name = FittingNameInput & " upper trim sketch "
BackStartPoint = BackTrimSketch.AddByProjectingEntity(Proj_Point)
BackRectPoint = BackTrimSketch.SketchPoints.Add(oTG.CreatePoint2d(BackStartPoint.Geometry.X, BackStartPoint.Geometry.Y - 1))
BackTrimSketch.GeometricConstraints.AddVerticalAlign(BackStartPoint, BackRectPoint)
BackStartDis = BackTrimSketch.DimensionConstraints.AddTwoPointDistance(BackRectPoint, BackStartPoint, Inventor.DimensionOrientationEnum.kAlignedDim, oTG.CreatePoint2d(10, 10))
BackStartDis.Parameter.Expression = FittingNameInput & "_Fitting_Proj" & "*2 " & "+tank_id+sidewall_th*2"
oDoc.Update
Rect2StartPoint = BackTrimSketch.SketchPoints.Add(oTG.CreatePoint2d(BackRectPoint.Geometry.X - 5, BackRectPoint.Geometry.Y - 5))
Rect2EndPoint = BackTrimSketch.SketchPoints.Add(oTG.CreatePoint2d(BackRectPoint.Geometry.X + 5, BackRectPoint.Geometry.Y + 5))
Rectangle2 = BackTrimSketch.SketchLines.AddAsTwoPointRectangle(Rect2StartPoint, Rect2EndPoint)
Rect2Line1 = Rectangle2.Item(2)
Rect2Line3 = Rectangle2.Item(3)
Rect2Line1Con = BackTrimSketch.DimensionConstraints.AddTwoPointDistance(Rect2Line1.StartSketchPoint, Rect2Line1.EndSketchPoint, Inventor.DimensionOrientationEnum.kVerticalDim, oTG.CreatePoint2d(3, 3))
Rect2Line1Con.Parameter.Expression = "(6+sidewall_th+3)*2+12"
CenterControlA = BackTrimSketch.DimensionConstraints.AddTwoPointDistance(BackRectPoint, Rect2EndPoint, Inventor.DimensionOrientationEnum.kVerticalDim, oTG.CreatePoint2d(-6, -6))
CenterControlA.Parameter.Expression = "(6+sidewall_th)+3"
Rect2Line3con= BackTrimSketch.DimensionConstraints.AddTwoPointDistance(Rect2Line3.StartSketchPoint, Rect2Line3.EndSketchPoint, Inventor.DimensionOrientationEnum.kHorizontalDim, oTG.CreatePoint2d(-3, -3))
Rect2Line3Con.Parameter.Value = 48 * 2.54
CenterControlB = BackTrimSketch.DimensionConstraints.AddTwoPointDistance(BackRectPoint, Rect2StartPoint, Inventor.DimensionOrientationEnum.kHorizontalDim, oTG.CreatePoint2d(6, 6))
CenterControlB.Parameter.Value = 24 * 2.54
BackProfile = BackTrimSketch.Profiles.AddForSolid
oDoc.Update
'The below is calculating the area to cut away from the outside
Dim Ratio As Double = (oUserParams.Item(FittingNameInput & "_Flange_Size").Value / 2) / (tank_id / 2)
Dim ThetaRad As Double = 2 * Math.Asin(Ratio)
Dim ThetaDeg As Double = ThetaRad * (180 / Math.PI)
Dim AdjustedAngle As Double = 360 - ThetaDeg
Dim AdjustedRad As Double = AdjustedAngle * Math.PI /180
BackRevolveTrim = oCompDef.Features.RevolveFeatures.AddByAngle(BackProfile, oUCS.YAxis, AdjustedRad, Inventor.PartFeatureExtentDirectionEnum.kSymmetricExtentDirection, Inventor.PartFeatureOperationEnum.kCutOperation)
BackRevolveTrim.Name = FittingNameInput & " Upper trim revolution "
BackRevolveTrim.SetAffectedBodies(TrimCol)
If InputAngle = 0 Then
BackRevolveTrim.Suppressed = True
RevolveTrim.Suppressed = False
Else
'Logger.Info("Inside the revolve trim suppression")
RevolveTrim.Suppressed = False 'This should be turning on based on the input we have entered.
BackRevolveTrim.Suppressed = False
End If
To answer you're question as a reply. It could be a couple of things going on as I cannot see the full code you're working with. You could have the wrong index for the surface bodies, could be the wrong axis or object. That's why I described the function at creation to you. It can take trial and error due to it not being applicable at creation, but works after setting the bodies. Something else of note, as I've gotten myself into trouble doing so. Try not to name things exactly what they are, sometimes they can be misintrupreted. Your objects, should be something with a defining letter or otherwise like iObjects. For example, I love to do (Dim Heightparam as parameter = something), Inventor doesn't like this and prefers I specify its an inventor parameter (Dim HeightParam as inventor.parameter). seems to fix my issue.
What is the error you're getting exactly, are you failing to create the definition or failing to change it to the new surface body collection?