The iFeatureSketchPlaneInput object supports the SetPosition method which allows you to define several things that control the placement position of the iFeature; the placement point, a vector that defines the axis that will be used as zero, and the rotation angle relative to the defined axis. This provides functionality similar to what you see when you interactively place an iFeature and have the opportunity to move and rotate it on the selected face.
Following code snippet explains the usage of the SetPosition method. To test the first one ensure the path to Cone_Rounded.ide is correct for your installation. This example places the iFeature on the start face of the first extrusion.
Public Sub PlaceiFeature() Dim _InventorApp As Inventor.Application = Runtime.InteropServices.Marshal.GetActiveObject("Inventor.Application") Dim oCompDef As PartComponentDefinition oCompDef = _InventorApp.ActiveDocument.ComponentDefinition Dim oTG As TransientGeometry oTG = _InventorApp.TransientGeometry ' Arbitrarily get the start face of the first extrusion. Dim oFace As Face oFace = oCompDef.Features.ExtrudeFeatures.Item(1). StartFaces.Item(1) Dim oiFeatComps As iFeatureComponents oiFeatComps = oCompDef.ReferenceComponents.iFeatureComponents ' Create the definition object for the specified ide file. Dim oiFeatDef As iFeatureDefinition oiFeatDef = oiFeatComps.CreateDefinition( _ "C:UsersPublicDocumentsAutodeskInventor 2012" & _ "Geometric ShapesCone_Rounded.ide") ' Set the iFeature input values. Dim oiFeatInput As iFeatureInput Dim oParamInput As iFeatureParameterInput For Each oiFeatInput In oiFeatDef.iFeatureInputs Select Case oiFeatInput.Prompt Case "Pick a planar face or work plane" Dim oPlaneInput As iFeatureSketchPlaneInput oPlaneInput = oiFeatInput oPlaneInput.PlaneInput = oFace Call oPlaneInput.SetPosition( oTG.CreatePoint(0, 0, 0), oTG.CreateVector(1, 0, 0), 0) Case "Enter Diameter" oParamInput = oiFeatInput oParamInput.Expression = ".75 in" Case "Height at theoretical sharp point" oParamInput = oiFeatInput oParamInput.Expression = ".6 in" Case "Enter Radius" oParamInput = oiFeatInput oParamInput.Expression = ".1 in" End Select Next 'Create the iFeature. oiFeatComps.Add(oiFeatDef) End Sub
However, remember that interactively or through the API you’re not able to precisely position an iFeature. If you need to precisely position it then you need to define the iFeature such that it is dependent on outside geometry for it’s position. For example, if you need to place an iFeature precisely at a certain location then you could make the original sketch of the iFeature dependent on a point (WorkPoint, or Vertex for example). When placing the iFeature you’ll then need to identify similar existing geometry to allow their relationships to be created.
A common misconception is to think that an iFeature is similar to an AutoCAD block. When placing a block you specify the placement point and can also specify an angle which allows you to precisely position the block. iFeature’s do not have an origin so specifying a placement point makes not sense since there isn’t a defined point in the iFeature to align to the point. An iFeature is really just a group of features and their corresponding sketches. A feature has certain dependencies. For example when you create an extrude feature the feature is dependent on a sketch for its shape and this sketch is dependent on a face or work plane for it’s position. The sketch may also have dimension or geometry constraints to geometry outside the sketch to define the position of sketch geometry. An iFeature is essentially a feature with the objects the iFeature is dependent on missing. When you place an iFeature you must identify these missing dependencies and then Inventor is able to create the feature(s) in the iFeature. By creating an iFeature that is dependent on a single point (usually a work point) for its position and possibly a line for its orientation, you can supply this input during placement to precisely control the position of the iFeature.

Leave a Reply