Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Feature with an Irregular Pattern from Excel... Use iFeature, iLogic, VBA?

2 REPLIES 2
Reply
Message 1 of 3
tdswanson
265 Views, 2 Replies

Feature with an Irregular Pattern from Excel... Use iFeature, iLogic, VBA?

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!

2 REPLIES 2
Message 2 of 3

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.

 

 

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

Message 3 of 3
VdVeek
in reply to: philippe.leefsma

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

Autodesk Inventor 2015 Certified Professional & Autodesk Inventor 2012 Certified Professional.

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report