I posted this in another forum, but it was suggested by product support that I post it this forum as well, so here goes.....
****************************************
Hey all:
I'm just getting started on a project that is probably above my current capabilities.... I need to draw a pin with a simple groove in it repeated several hundred times along the length of the pin in an *irregular* pattern. The locations of the grooves are given in an Excel file.
So I'm thinking that I can draw the round pin and create an iFeature for the groove easy enough. But then I'll need to generate the code to come in an insert the iFeature at the locations specified in the spreadsheet. I haven't yet coded any automated iFeature placements yet.
Is an iFeature the right way to go, or should I just draw the groove once and use code to create many patterns of the same feature?
Can someone give me a hand? Here is a ZIP file that has:
IPT file for the basic pin, with the first groove in it
XLSX File for the repeating data. Note that this dummy data happens to be "regular" and the real data isn't.
IDE File for the iFeature (if that's the best route)
Thanks for looking at this!
Hi tdswanson,
I'm not going to write the code for you but I can give you pointers...
I think you spotted the two most logic appraoches: using iFeatures or creating the feature "from scratch" using API. The big limitation of iFeatures is that once inserted, you won't be able to access the underlying base features used to compose the iFeature (to get properties or modify it). So it depends what you want to do after you inserted all your features.
You can easily find examples on how to insert iFeatures from API, simply take a look at the API Help Files or on our programming blogs:
Public Sub PlaceiFeature() ' Get the part document and component definition of the active document. On Error Resume Next Dim oPartDoc As PartDocument Set oPartDoc = ThisApplication.ActiveDocument If Err Then MsgBox "A part must be active." Exit Sub End If Dim oPartDef As PartComponentDefinition Set oPartDef = oPartDoc.ComponentDefinition ' Get the selected face to use as input for the iFeature. Dim oFace As Face Set oFace = oPartDoc.SelectSet.Item(1) If Err Then MsgBox "A planar face must be selected." Exit Sub End If On Error GoTo 0 If oFace.SurfaceType kPlaneSurface Then MsgBox "A planar face must be selected." Exit Sub End If Dim oFeatures As PartFeatures Set oFeatures = oPartDef.Features ' Create an iFeatureDefinition object. Dim oiFeatureDef As iFeatureDefinition Set oiFeatureDef = oFeatures.iFeatures.CreateiFeatureDefinition( _ "C:\Program Files\Autodesk\Inventor 2010\Catalog\Slots\End_mill_curved.ide") ' Set the input. Dim oInput As iFeatureInput For Each oInput In oiFeatureDef.iFeatureInputs Dim oParamInput As iFeatureParameterInput Select Case oInput.Name Case "Sketch Plane" Dim oPlaneInput As iFeatureSketchPlaneInput Set oPlaneInput = oInput oPlaneInput.PlaneInput = oFace Case "Diameter" Set oParamInput = oInput oParamInput.Expression = "1 in" Case "Depth" Set oParamInput = oInput oParamInput.Expression = "0.5 in" End Select Next ' Create the iFeature. Dim oiFeature As iFeature Set oiFeature = oFeatures.iFeatures.Add(oiFeatureDef) End Sub
http://adndevblog.typepad.com/manufacturing/2012/07/position-of-ifeature.html
Concerning creating the feature from scratch using API, this may require more knowledge of the API. If you are a beginner, here are couple of places you can start:
http://www.autodesk.com/developinventor
http://modthemachine.typepad.com/
http://adndevblog.typepad.com/manufacturing/
https://github.com/ADN-DevTech/Inventor-Training-Material
Regards,
Philippe.
An other way i thought of is create a sketch block of your groove and use this sketchblock and his insertpoint to create the features.
Rob