Message 1 of 6
iFeature: How to change affected bodies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report
Hello there!
I am trying to place an iFeature on a body selected with
Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select a planar face")
It is being placed, but for some reason not affecting the body of which i selected oFace
but it seems like it is cutting the first solid in the part hierarchy (There are multiple solids in the .ipt)
I have tried to change which SurfaceBodies are being affected with the following
Dim objects = ThisApplication.TransientObjects.CreateObjectCollection objects.Add(oFace.SurfaceBody)
' Create the iFeature.
Dim oiFeature As iFeature
oiFeature = oFeatures.iFeatures.Add(oiFeatureDef) oiFeature.SetAffectedBodies(objects)
This changed nothing, then i tried to update the document
Dim oPartDoc As PartDocument oPartDoc = ThisApplication.ActiveDocument
oPartDoc.Update()
And as you guessed, nothing...
I really don't know what to try next, and hope one of you could help me out
Thanks in advance
(Here is the full iLogic Rule, )
Public Sub Main() Dim oPartDoc As PartDocument oPartDoc = ThisApplication.ActiveDocument Dim oPartDef As PartComponentDefinition oPartDef = oPartDoc.ComponentDefinition ' Get the selected face to use as input for the iFeature. Dim oFace As Face = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartFacePlanarFilter, "Select a planar face") selectPointOne = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeMidpointFilter, "Vælg Midtpunkt 1") pointOne = oPartDef.WorkPoints.AddByMidPoint(selectPointOne)
selectPointTwo = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeMidpointFilter, "Vælg Midtpunkt 1")
pointTwo = oPartDef.WorkPoints.AddByMidPoint(selectPointTwo)
Dim oFeatures As PartFeatures
oFeatures = oPartDef.Features
' Create an iFeatureDefinition object.
Dim oiFeatureDef As iFeatureDefinition
oiFeatureDef = oFeatures.iFeatures.CreateiFeatureDefinition( _
"C:\Path\iFeature.ide")
' Set the input.
Dim oInput As iFeatureInput
For Each oInput In oiFeatureDef.iFeatureInputs
Dim oParamInput As iFeatureParameterInput
Select Case oInput.Name
Case "Face"
Dim oPlaneInput As iFeatureSketchPlaneInput
oPlaneInput = oInput
oPlaneInput.PlaneInput = oFace
Case "Point1"
Dim oPlaneInput As iFeatureEntityInput
oPlaneInput = oInput
oPlaneInput.Entity = pointOne Case "Point2"
Dim oPlaneInput As iFeatureEntityInput
oPlaneInput = oInput
oPlaneInput.Entity = pointTwo
End Select
Next
Dim objects = ThisApplication.TransientObjects.CreateObjectCollection
objects.Add(oFace.SurfaceBody)
' Create the iFeature.
Dim oiFeature As iFeature
oiFeature = oFeatures.iFeatures.Add(oiFeatureDef)
oiFeature.SetAffectedBodies(objects)
oPartDoc.Update()
End Sub
Used this as my guide:
- https://help.autodesk.com/view/INVNTOR/2020/ENU/?guid=GUID-8E822596-71C5-4C93-B935-7A6F04C7DE10