Community
Inventor Forum
Welcome to Autodesk’s Inventor Forums. Share your knowledge, ask questions, and explore popular Inventor topics.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

IV2015 - Repeat an iFeature with Data from Excel?

7 REPLIES 7
SOLVED
Reply
Message 1 of 8
tdswanson
549 Views, 7 Replies

IV2015 - Repeat an iFeature with Data from Excel?

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 groove in it repeated several hundred times along the length of the pin.  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.  Can someone give me a hand?  

 

I'm going to start making up some dummy files now, as the actual details are proprietary.

 

Thanks!

Tags (3)
7 REPLIES 7
Message 2 of 8
tdswanson
in reply to: tdswanson

OK, 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.

 

As I think about it now, would it be simpler to not use an iFeature and just use a loop to create multiple "single placement patterns" of the original feature?

 

Thanks for looking at this!

Tags (3)
Message 3 of 8
bob_holland
in reply to: tdswanson

tdswanson,

 

By regular, are you meaning uniform spacing?

If you have a uniform spacing you can use a rectangular array.

If it is non uniform, then the only thing that is coming to mind would probably be iLogic custom code to create a work plane for your sketch plane.

 

Curtis Waguespack, 

 

What do you think?

 

Thank you.


Bob Holland
Autodesk Product Support
Message 4 of 8
tdswanson
in reply to: bob_holland

Bob - Yes, I should have been more clear about this.  The spacing for the grooves is totally irregular.  The location of each groove is given in an Excel file.

 

I considered using an iFeature and/or using multiple patterns, but my experience using iLogic to pull from an external data source is pretty limited.  Could you point me towards any example code for patterns and/or external data usage?

 

Thanks for looking at this!

Message 5 of 8
bob_holland
in reply to: tdswanson

Tadd,

 

I think that the best place to ask that question would be the Inventor Customization Forum:

http://forums.autodesk.com/t5/Inventor-Customization/bd-p/120

 

I know that iLogic is one of the major subject topics on this forum.

Curtis Waguespack usually has code snipits that he make available:

http://inventortrenches.blogspot.com/

 

Here is a link on how to have iLogic access an Excel file:

http://inventortrenches.blogspot.com/2014/06/ilogic-titleblock-project-data-from.html

 

Good Luck.

 


Bob Holland
Autodesk Product Support
Message 6 of 8


@bob.holland wrote:
... If it is non uniform, then the only thing that is coming to mind would probably be iLogic custom code to create a work plane for your sketch plane.

 

Curtis Waguespack, 

 

What do you think?



I just stumbled on this thread. I won't get back to it for a couple of days at best, but if I do I'll see what I can come up with.

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

Message 7 of 8

Curtis:  I'd greatly appreciate any advice you'd have to offer.  Thanks!

Message 8 of 8

Hi tdswanson,

 

Here is what I came up with the help of this link. See the attached zip file containing an *ipt, *.ide, and a modified version of your *.xlsx. This iLogic rule prompts the user to select a spreadsheet, and then uses the values found in the spreadsheet to place an iFeature at offsets from the end (origin point).

 

Have a look and post back if something in the code or files doesn't make sense to you.

 

Creating a Basic iLogic Rule

http://inventortrenches.blogspot.com/2012/01/creating-basic-ilogic-rule-with-event.html

Working with external iLogic rules

http://autodeskmfg.typepad.com/blog/2012/01/working-with-external-ilogic-rules.html

 

I hope this helps.
Best of luck to you in all of your Inventor pursuits,
Curtis
http://inventortrenches.blogspot.com

 

 

 

Before and after, an irregular "pattern" of iFeatures created with iLogic and Excel.

Autodesk Inventor iLogic iFeatue Excel.png

 

 

 

 

ilogic code:

 

 'Browse for the Excel file
Dim oFileDlg As inventor.FileDialog = Nothing
InventorVb.Application.CreateFileDialog(oFileDlg)
oFileDlg.Filter = "Excel Files (*.xls;*.xlsx)|*.xls;*.xlsx"
oFileDlg.DialogTitle = "Select a Project Information Excel File"
oFileDlg.InitialDirectory = ThisDoc.Path
oFileDlg.CancelError = True
On Error Resume Next
oFileDlg.ShowOpen()
If Err.Number <> 0 Then
'exit if file not selected
Return
ElseIf oFileDlg.FileName <> "" Then
myXLS  = oFileDlg.FileName
End If

'look at sheet1 of the spreadsheet
GoExcel.Open(myXLS, "Sheet1")

Dim _InventorApp As Inventor.Application
_InventorApp = Runtime.InteropServices.Marshal. _
GetActiveObject("Inventor.Application")

' Set a reference to part file
'Dim oDoc As PartDocument
oDoc = ThisApplication.ActiveDocument

' Set a reference to the part component definition.
Dim oCompDef As PartComponentDefinition
oCompDef = oDoc.ComponentDefinition

Dim oTG As TransientGeometry
oTG = _InventorApp.TransientGeometry

'get the XZ work plane.
Dim xzPlane As Inventor.WorkPlane
xyPlane= oCompDef.WorkPlanes.Item(2)

'reference the part features collection  
Dim oFeatures As PartFeatures
oFeatures = oCompDef.Features
'reference the ifeatures collection      
Dim oiFeatComps As iFeatureComponents
oiFeatComps = oCompDef.ReferenceComponents. _
iFeatureComponents

'define row 3 of the Excel sheet as the
'first row  to look at
i = 3
Do until i > 12 'where row 11 is the last row    
'get the iFeature path from the XLS file
IDE_Path = GoExcel.CellValue("B1")
'create an iFeatureDefinition object.
Dim oiFeatDef As iFeatureDefinition
oiFeatDef = oFeatures.iFeatures.CreateiFeatureDefinition(IDE_Path)
 
' Set the iFeature input.
Dim oiFeatInput As iFeatureInput
Dim oParamInput As iFeatureParameterInput
    For Each oiFeatInput In oiFeatDef.iFeatureInputs            
            Select Case oiFeatInput.Prompt
        Case "Please Select the Sketch Plane"
        Dim oPlaneInput As iFeatureSketchPlaneInput
                        oPlaneInput = oiFeatInput
                        oPlaneInput.PlaneInput = xyPlane
                         'read the value of the XLS
                             Dim myCell  As String
                         myCell = GoExcel.CellValue("C" & i)
                             oPlaneInput.SetPosition(oTG.CreatePoint _
                             (0, 0, myCell ),oTG.CreateVector(1,0, 0), 0)
        Case "Please Enter the Depth"
                    oParamInput = oiFeatInput
                    oParamInput.Expression = "1 cm"
                Case "Please Enter the Diameter"
                    oParamInput = oiFeatInput
                    oParamInput.Expression = "10 cm"
            End Select
        Next
i = i +1    
'Create the iFeature(s)
oiFeatComps.Add(oiFeatDef)
Loop

 

 

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

Post to forums  

Autodesk Design & Make Report