Cut a solid by RevolveFeature

Cut a solid by RevolveFeature

bruscaginmatteo
Participant Participant
130 Views
6 Replies
Message 1 of 7

Cut a solid by RevolveFeature

bruscaginmatteo
Participant
Participant
Hi, how can I choose the solid to cut with RevolveFeature?
This is my code:
Dim revolveFeatRemove As RevolveFeature = DefinizioneParte.Features.RevolveFeatures.AddByAngle(oProfile01, oWorkAx, oElbowAngle, PartFeatureExtentDirectionEnum.kNegativeExtentDirection, PartFeatureOperationEnum.kCutOperation)
Thanks in advance

 

 


Matteo

 

0 Likes
131 Views
6 Replies
Replies (6)
Message 2 of 7

marcin_otręba
Advisor
Advisor

did you try to set affected bodies? :

Inventor 2025 Help | RevolveFeature.SetAffectedBodies Method | Autodesk

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes
Message 3 of 7

bruscaginmatteo
Participant
Participant

Hi,  Have You a small example? 

0 Likes
Message 4 of 7

J_Pfeifer_
Advocate
Advocate

-<See below conversation>-

Here is a code example of doing exactly what you're looking for. SweepFeature.SetAffectedBodies(MainFittingCol). The main fitting col is a surface body collection. In this case, that collection holds all the surface bodies that make up the fitting.  If I were to pause or stop the program before the set affected line. It will cut the revolve through the main or first surface body object automatically. 

 

0 Likes
Message 5 of 7

bruscaginmatteo
Participant
Participant


Dim oFeatures As PartFeatures
oFeatures = DefinizioneParte.Features

 

Dim objects As ObjectCollection = oInvApp.TransientObjects.CreateObjectCollection
' objects.Add(oFeatures.Item(11).SurfaceBodies)

 

For Each MyPart As PartFeature In oFeatures
objects.Add(MyPart)

Next

 

Dim revolveFeatRemove2 As RevolveFeature

revolveFeatRemove2 = DefinizioneParte.Features.RevolveFeatures.AddByAngle(oProfile01,oWorkAx,oElbowAngle,PartFeatureExtentDirectionEnum.kNegativeExtentDirection,PartFeatureOperationEnum.kCutOperation)


revolveFeatRemove2.SetAffectedBodies(objects) 

 

What is my error? are not the object correct?

 

0 Likes
Message 6 of 7

J_Pfeifer_
Advocate
Advocate

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?

 

0 Likes
Message 7 of 7

marcin_otręba
Advisor
Advisor

@bruscaginmatteo why you add partfeatures instead of bodies to collection?

 

here is example of working code:

Dim oInvApp As Inventor.Application=ThisApplication
Dim Parte As PartDocument = ThisDoc.Document
Dim DefinizioneParte As PartComponentDefinition=Parte.ComponentDefinition
Dim oFeatures As PartFeatures
oFeatures = DefinizioneParte.Features
Dim objects As ObjectCollection = oInvApp.TransientObjects.CreateObjectCollection

For Each body As SurfaceBody  In DefinizioneParte.SurfaceBodies
objects.Add(body)
Next

 Dim oProfile01 As Profile = oInvApp.CommandManager.Pick(SelectionFilterEnum.kSketchProfileFilter,"pick profile to revolve")
 Dim oWorkAx As WorkAxis = oInvApp.CommandManager.Pick(SelectionFilterEnum.kWorkAxisFilter,"pick axis to revolve")
 Dim oElbowAngle As Double =1

Dim revolveFeatRemove2 As RevolveFeature
revolveFeatRemove2 = DefinizioneParte.Features.RevolveFeatures.AddByAngle(oProfile01,oWorkAx,oElbowAngle,PartFeatureExtentDirectionEnum.kNegativeExtentDirection,PartFeatureOperationEnum.kCutOperation)
revolveFeatRemove2.SetAffectedBodies(objects ) 

 

Hi, maybe you want to check my apps:


DrawingTools   View&ColoringTools   MRUFolders

0 Likes