Inventor Ilogic : Select bends with the pick function in PartDocument.

Inventor Ilogic : Select bends with the pick function in PartDocument.

vpeuvion
Advocate Advocate
407 Views
5 Replies
Message 1 of 6

Inventor Ilogic : Select bends with the pick function in PartDocument.

vpeuvion
Advocate
Advocate

Hello.

Is there a way to select a bend of a part like when using the unbend function with the pick function in PartDocument.
I can't find it in the Selection Filter Enumerator list.
I would like to be able to select bends with the pick function.
Does somebody have an idea?
Thanks. Vincent.

vpeuvion_0-1662988038551.png

 

0 Likes
Accepted solutions (1)
408 Views
5 Replies
Replies (5)
Message 2 of 6

WCrihfield
Mentor
Mentor

Hi @vpeuvion.  It is true that the SelectionFilterEnum does not contain a variation specifically for a Bend object or a BendFeature object.  The closest variation is the kPartFeatureFilter option.  What do you intend to do with the bend, once selected?  You may just have to use a secondary filter to avoid getting the wrong Type, or just loop through all bends, instead of using Pick function.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 6

vpeuvion
Advocate
Advocate

Hi @WCrihfield . Thank you for your reply.

Here's a simplified example of what I'm trying to do.

In this example, I select the reference face, the part is fully unfolded and then the part is refolded.

I wish I could select just one bend for refolding. The oBends objectCollection would only contain the selected bend.

Do I have to select a face that belongs to the bend and from there find the FlatBendResult?

Sub main()
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oSMCD As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
	Dim oSMF As SheetMetalFeatures = oSMCD.Features

	Dim oBends As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	
	Dim oFace As Face
	oFace = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kAllPlanarEntities,"Sélectionner la face de référence")
	oSMF.UnfoldFeatures.Add(oFace)

	MessageBox.Show("refold")
	For i = 1 To oSMCD.FlatPattern.FlatBendResults.Count
		oBends.Add(oSMCD.FlatPattern.FlatBendResults.Item(i).Bend)
	Next
	oSMF.RefoldFeatures.Add(oFace,oBends)
	
End Sub

 

 

0 Likes
Message 4 of 6

WCrihfield
Mentor
Mentor
Accepted solution

Hi @vpeuvion.  I think I have worked out a way that you can use.  Check out the example below, and see if that works for you.

Sub Main
	Dim oPartDoc As PartDocument = ThisApplication.ActiveDocument
	Dim oSMCD As SheetMetalComponentDefinition = oPartDoc.ComponentDefinition
	Dim oBendsEnum As BendsEnumerator = oSMCD.Bends
	Dim oSMF As SheetMetalFeatures = oSMCD.Features
	Dim oCM As CommandManager = ThisApplication.CommandManager
	
	'get stationary face
	Dim oFace As Face = oCM.Pick(SelectionFilterEnum.kPartFaceFilter,"Sélectionner la face de référence")
	If IsNothing(oFace) Then Return
		
	'get the bend to unfold
	Dim oBendFace As Face = oCM.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Face Of Bend")
	If IsNothing(oBendFace) Then Return
	Dim oBend As Bend
	Try
		'you can get a specific Bend by specifying either Index # or Face object belonging to a Bend
		oBend = oBendsEnum.Item(oBendFace)
	Catch
		MsgBox("Selected Face did not belong to a Bend.", vbExcamation, "")
		Return
	End Try

	'add the Bend to our oBends collection
	Dim oBends As Inventor.ObjectCollection = ThisApplication.TransientObjects.CreateObjectCollection
	oBends.Add(oBend)
	
	'create the UnfoldFeatrue for just that one Bend
	Dim oUnFoldFeat As UnfoldFeature
	If oBend.IsFlat = False Then
		'MsgBox("Bend is not flat, so we are able to unfold it.",,"")
		oUnFoldFeat = oSMF.UnfoldFeatures.Add(oFace, oBends)
	Else
		'MsgBox("Bend is already flat, so we are NOT able to unfold it.",,"")
	End If
	oPartDoc.Update
	
	MsgBox("Now to refold the bend.",,"")
	're-set contents of oBends using UnfoldFeature we created above
	oBends.Clear
	For Each oB In oUnFoldFeat.Bends
		oBends.Add(oB)
	Next
	oSMF.RefoldFeatures.Add(oFace, oBends)
End Sub

If this solved your problem, or answered your question, please click ACCEPT SOLUTION .
Or, if this helped you, please click (LIKE or KUDOS) 👍.

 

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 5 of 6

vpeuvion
Advocate
Advocate

Hi @WCrihfield. Thanks a lot. This will really help me move forward.

0 Likes
Message 6 of 6

TechInventor20
Advocate
Advocate

You could also change this rule:

	'get the bend to unfold
	Dim oBendFace As Face = oCM.Pick(SelectionFilterEnum.kPartFaceFilter, "Select Face Of Bend")
	If IsNothing(oBendFace) Then Return

into:

	'get the bend to unfold
	Dim oBendFace As Face = oCM.Pick(SelectionFilterEnum.kPartFaceCylindricalFilter, "Select Face Of Bend")
	If IsNothing(oBendFace) Then Return

This way you get to select only bends.