Assembly extrusion in iLogic

Assembly extrusion in iLogic

Anonymous
Not applicable
1,790 Views
4 Replies
Message 1 of 5

Assembly extrusion in iLogic

Anonymous
Not applicable

Hi,

 

I am using a pattern and wanting to remove some portion of the very last part of the pattern using extrude. Depending on the height, one of two parts are sometimes added through iLogic to the last section of the pattern and may also require cutting. the problem is, once they are removed for a different height, they are no longer participants in the extrude, so when they're added, the extrude doesn't cut them. Please see attached model, the extrusion cuts from work plane 2. I'd appreciate any help with this as it's become a bit of a sticking point. Using Inventor 2019.

Thanks in advance.

Niz

0 Likes
1,791 Views
4 Replies
Replies (4)
Message 2 of 5

johnsonshiue
Community Manager
Community Manager

Hi! It should be doable if I understand it correctly. There might be API access to adding a participant to an existing assembly feature. Or, you can delete the extrusion feature (keep the sketch) and recreate a new extrusion. Then the new occurrences will be included.

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 3 of 5

Anonymous
Not applicable

Hi,

 

Thanks for your response, however, that doesn't seem to resolve it because once the part is removed for a different size with iLogic, and then added again later, it is no longer a participant in the extrsion command... unless I'm doing something fundamentally wrong? Can you expand on API at all please?

 

thanks

 

Niz

0 Likes
Message 4 of 5

AlexFielder
Advisor
Advisor

Hi @Anonymous 

This page proved quite useful:

http://help.autodesk.com/view/INVNTOR/2019/ENU/?guid=GUID-35F2F555-48A8-438E-952F-7EF60DA1ADAE

 

And from that I have built this relatively simple "AssemblyCreateExtrusion" rule:

imports System.Linq
Sub Main()
	Dim CutFeatureName As String = "DemoAssemblyCutFeature"
	If TypeOf ThisApplication.ActiveDocument Is AssemblyDocument Then
		Dim AssyDoc As AssemblyDocument = ThisApplication.ActiveDocument
		Dim AssyDef As AssemblyComponentDefinition = AssyDoc.ComponentDefinition
		If Parameter("TotalWidth") >= 1500 Then
			DeleteCutFeature(AssyDef, CutFeatureName)
			MessageBox.Show("No cut required")
		Else
			If Parameter("FinalPanel") = "003" Then
				'check if 003 is inserted
				For Each occ As ComponentOccurrence In AssyDef.Occurrences
					Logger.Debug(occ.Name)
					If occ.Name.Contains("004") Then
						Component.Replace(occ.Name, "CutMe003.ipt", True)
					End If
				Next
			Else
				For Each occ As ComponentOccurrence In AssyDef.Occurrences
					Logger.Debug(occ.Name)
					If occ.Name.Contains("003") Then
						Component.Replace(occ.Name, "CutMe004.ipt", True)
					End If
				Next
			End If
			DeleteCutFeature(AssyDef, CutFeatureName)
			CreateAssemblyCut(AssyDef, CutFeatureName)
		End If
	Else
		MessageBox.Show("Not using an Assembly, Exiting!")
		Exit Sub
	End If
	iLogicVb.UpdateWhenDone = True
End Sub

Sub DeleteCutFeature(ByVal AssyDef As AssemblyComponentDefinition, FeatureName As String)
	Dim FeatureToDelete As ExtrudeFeature = (From extFeat As ExtrudeFeature In AssyDef.features.extrudefeatures
												Where extFeat.Name = FeatureName
												Select extFeat).FirstOrDefault()
	If Not FeatureToDelete Is Nothing Then
		FeatureToDelete.Delete(True, False)
		Logger.Debug("Deleted: " & FeatureName)
	End If
End Sub

Sub CreateAssemblyCut(ByVal AssyDef As AssemblyComponentDefinition, FeatureName As String)
	Dim cutSketch As PlanarSketch = (From sk As PlanarSketch In AssyDef.Sketches
										Where sk.name.tolower.contains("cut")
										Select sk).FirstOrDefault()
	If Not cutSketch Is Nothing Then
		Dim cutProfile As Profile = cutSketch.Profiles.AddForSolid
		Dim extrudeDef As ExtrudeDefinition = AssyDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(cutProfile, PartFeatureOperationEnum.kCutOperation)
		Dim cutPlane1 As WorkPlane = (From wp As WorkPlane In AssyDef.WorkPlanes
										Where wp.name.contains("1")
										Select wp).FirstOrDefault()
		Dim cutPlane2 As WorkPlane = (From wp As WorkPlane In AssyDef.WorkPlanes
										Where wp.name.contains("2")
										Select wp).FirstOrDefault()
		If Not cutPlane1 Is Nothing And Not cutPlane2 Is Nothing Then
			extrudeDef.SetFromToExtent(cutPlane1, True, cutPlane2, True) ' the true statements here might adversely affect things?
			Dim extrudeCut As ExtrudeFeature = AssyDef.Features.ExtrudeFeatures.Add(extrudeDef)
			For Each occ As ComponentOccurrence In AssyDef.Occurrences
				extrudeCut.AddParticipant(occ)
			Next
			extrudeCut.Name = FeatureName
			Logger.Debug("Created: " & FeatureName)
		Else
			MessageBox.Show("couldn't find workplanes containing 1 & 2 in their names")
		End If
	Else
		MessageBox.Show("We couldn't find the right sketch! Exiting.")
		Exit Sub
	End If
End Sub

which works in conjunction with the attached assembly (and part files). I've currently got an iTrigger on Parameter change that calls the above, but this shows the basic steps to create an extrusion in an assembly and "reattach" participants to the newly created extruded-cut-between-workplanes.

 

I also created a form within the assembly to show it in action. Move the slider & the workplanes will move automatically. For some reason the occurrence replacement needs a click of the AssemblyCreateExtrusion button before it'll do anything, which is odd because it too triggers a parameter change. (Perhaps I'll post this as a separate thread for the Autodesk bods to look at!?)

Message 5 of 5

Anonymous
Not applicable

Hi @AlexFielder 

 

Thank you for the detailed response. I am actually trying to cut along the length of the very last extrusion, be that one from the pattern or one that is added through ilogic rules. But there's some really useful information there that I can apply to what I'm trying to achieve. Thanks for the link, I shall go through it and hopefully come to a resolution. Thank you for your help, much appreciated.

 

Niz

0 Likes