- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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
(Not an Autodesk Employee)
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
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 Returninto:
'get the bend to unfold
Dim oBendFace As Face = oCM.Pick(SelectionFilterEnum.kPartFaceCylindricalFilter, "Select Face Of Bend")
If IsNothing(oBendFace) Then ReturnThis way you get to select only bends.