cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Fix ilogic Shell feature, or open definition to include .SetAffectedSolids!

Fix ilogic Shell feature, or open definition to include .SetAffectedSolids!

I'm in the process of converting some code from one template to another. I came across my typical issue with the shell feature when used. This is the 3rd or 4th time I've made a work around, or issued the commands in an order to avoid the issue. In doing so, with the combination of the attached link. I think I can confirm the issue. 

 

When you setup a ShellDefinition, you have faces, size, and the shell direction as input options. None of this carries the solid body implication. This means, when the program gets to the point where it attempts to apply the ShellFeature. It attempts to apply this to the first solid within the model browser. If it errors at this point, it will cancel the program, typically with an unspecified error. 

 

The reason this has significant is depending on the direction input it could fail or succeed without notifying the users as to why, tons of logging to find this problem. This also applies/goes hand in hand with the thickness of a shell. Sometimes you can reduce the thickness to avoid the error, changing the thickness back. In my case, as shown below. I set the shell direction, then changed it after the affected bodies have been targeted. 

 

I suggest we move the application of the affected solids to the definition object. Or allow the direction to be set on an empty part. 

 

Dim CutBodiesCol As ObjectCollection = oTO.CreateObjectCollection 
		
		'Create the loft feature that then gets controled by the previous values. 
		Dim LoftExtDef As LoftDefinition = oCompDef.Features.LoftFeatures.CreateLoftDefinition(LoftCol, kNewBodyOperation)
		
		Dim LoftExt As LoftFeature = oCompDef.Features.LoftFeatures.Add(LoftExtDef)
			LoftExt.Name = "Conical Loft: " & Fitting_Index
		
		
				Dim oFeature As LoftFeature = Nothing
			For Each LoftFeature As LoftFeature In oCompDef.Features.LoftFeatures
				If LoftFeature.Name.Contains("Conical Loft: " & Fitting_Index) Then
							oFeature = LoftFeature
							Logger.Info("CutBodies body num: " & CutBodiesCol.Count)
				End If 
			Next 
			
		If oFeature Is Nothing Then 
			MessageBox.Show("Loft Feature not found")
		End If 
			
		For Each body As SurfaceBody In oFeature.SurfaceBodies
					CutBodiesCol.Add(body) 
		Next
				
			Logger.Info("CutBodies body num: " & CutBodiesCol.Count & " Collection item type: " & CutBodiesCol.Type)
		
		'Create face collection to grab the two sized face's calculatable from their diameters. 
		Dim LoftFaceCol As FaceCollection = oTO.CreateFaceCollection
		
		Dim LoftFace1 As Face = LoftExt.Faces.Item(1) 'Face area: 930.76 or larger circle
		Dim LoftFace2 As Face = LoftExt.Faces.Item(2) 'Face area: 222.39 or smaller circle
		Dim LoftFace3 As Face = LoftExt.Faces.Item(3) 'Face area: 1416.74 or cone face object

			LoftFaceCol.Add(LoftFace1)
			LoftFaceCol.Add(LoftFace2)
			
		Logger.Info("Loft face 1 area: " & LoftFace1.Evaluator.Area)
		Logger.Info("Loft face 2 area: " & LoftFace2.Evaluator.Area)
		Logger.Info("Loft face collection items: " & LoftFaceCol.Count)
		
	oDoc.Update
		
		'Create shell definition and feature based off the previous solids and faces
		Dim LoftShellDef As ShellDefinition = oCompDef.Features.ShellFeatures.CreateShellDefinition(LoftFaceCol, .125 * 2.54, ShellDirectionEnum.kOutsideShellDirection)
		
	
		Dim LoftShell As ShellFeature = oCompDef.Features.ShellFeatures.Add(LoftShellDef)	
			LoftShell.SetAffectedBodies(CutBodiesCol)
			LoftShell.Name = "Conical shell feature: " & Fitting_Index
			
		
		oDoc.Update
		
			'Inside the slopped bottom template, this must switch back and forth. This is due to inventor appling the shell to the first solid before it's able to be applied to the correct targetted solid. 
			'then update the shell direction to adjust the correct placement. 
			LoftShell.Definition.Direction = ShellDirectionEnum.kInsideShellDirection
	
		oDoc.Update

 

The above code is a work around when dealing with the directional problem. 

	'This object collection below will hold the solids for cutting inside the rule later
		Dim CutBodiesCol As ObjectCollection = oTO.CreateObjectCollection 
		
		'Create the loft feature that then gets controled by the previous values. 
		Dim LoftExtDef As LoftDefinition = oCompDef.Features.LoftFeatures.CreateLoftDefinition(LoftCol, kNewBodyOperation)
		
		Dim LoftExt As LoftFeature = oCompDef.Features.LoftFeatures.Add(LoftExtDef)
			LoftExt.Name = "Conical Loft: " & Fitting_Index
		
		
				Dim oFeature As LoftFeature = Nothing
			For Each LoftFeature As LoftFeature In oCompDef.Features.LoftFeatures
				If LoftFeature.Name.Contains("Conical Loft: " & Fitting_Index) Then
							oFeature = LoftFeature
							Logger.Info("CutBodies body num: " & CutBodiesCol.Count)
				End If 
			Next 
			
		If oFeature Is Nothing Then 
			MessageBox.Show("Loft Feature not found")
		End If 
			
		For Each body As SurfaceBody In oFeature.SurfaceBodies
					CutBodiesCol.Add(body) 
		Next
				
			Logger.Info("CutBodies body num: " & CutBodiesCol.Count & " Collection item type: " & CutBodiesCol.Type)
		
		'Create face collection to grab the two sized face's calculatable from their diameters. 
		Dim LoftFaceCol As FaceCollection = oTO.CreateFaceCollection
		
		Dim LoftFace1 As Face = LoftExt.Faces.Item(1) 'Face area: 930.76 or larger circle
		Dim LoftFace2 As Face = LoftExt.Faces.Item(2) 'Face area: 222.39 or smaller circle
		Dim LoftFace3 As Face = LoftExt.Faces.Item(3) 'Face area: 1416.74 or cone face object

			LoftFaceCol.Add(LoftFace1)
			LoftFaceCol.Add(LoftFace2)
			
		Logger.Info("Loft face 1 area: " & LoftFace1.Evaluator.Area)
		Logger.Info("Loft face 2 area: " & LoftFace2.Evaluator.Area)
		Logger.Info("Loft face collection items: " & LoftFaceCol.Count)
		
	oDoc.Update
		
		'Create shell definition and feature based off the previous solids and faces
		Dim LoftShellDef As ShellDefinition = oCompDef.Features.ShellFeatures.CreateShellDefinition(LoftFaceCol, .125 * 2.54, ShellDirectionEnum.kOutsideShellDirection)
		
	
		Dim LoftShell As ShellFeature = Nothing
			
		
		LoftShell.SetAffectedBodies(CutBodiesCol) 'This is what I mean by being able to apply these settings to an empty object. Set the target before the creation using the definition. 
		'This method fails due to inventor not having an object to reference to apply the setting. 
				
				
		LoftShell = oCompDef.Features.ShellFeatures.Add(LoftShellDef)	
			
		LoftShell.Name = "Conical shell feature: " & Fitting_Index
			
		
		oDoc.Update
		
			'Inside the slopped bottom template, this must switch back and forth. This is due to inventor appling the shell to the first solid before it's able to be applied to the correct solid. 
			'It then tries to create the dimension to the inside on that solid. This is where it can error before changing its target. To fix this, we must force the fitting to the correct dimensions. 
			'then update the shell direction to adjust the correct placement. 
			LoftShell.Definition.Direction = ShellDirectionEnum.kInsideShellDirection
	
		oDoc.Update

The above code show, how I interpret the use of applying affected solids to an object before its creation. This errors due to an object not being loaded to apply. 

 

Then finally below is the link to the main thread I've been routing back to when encountering this problem:

https://forums.autodesk.com/t5/inventor-programming-ilogic/new-shell-command/td-p/9914870

 

It sounds like I was not the first to find the intricacies of using this feature. 

 

Can't find what you're looking for? Ask the community or share your knowledge.

Submit Idea