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: 

Repeatedly create exactly the same feature / AND dimensions

11 REPLIES 11
Reply
Message 1 of 12
bmerton
418 Views, 11 Replies

Repeatedly create exactly the same feature / AND dimensions

I need to create hundreds of rectangular or square cuts on a sheet metal surface with unique parameters for height, width, vertical position from the bottom axis of the face and horizontal position from the left axis of the face. I need these features to then be driven by iLogic rules, so they cannot be a pattern.

It doesn't seem possible to break up and dimension with patterns, and iFeatures still requires a lot of manual intervention. The solution is probably a macro as the operation is:
Create sketch on face
Draw any shape rectangle
Dimension height
Dimension width
Dimension vertical pos
Dimension horizontal pos
Save sketch
Cut sketch
Repeat

Any ideas?
11 REPLIES 11
Message 2 of 12
Anonymous
in reply to: bmerton

Is it the same number of cut outs each time, just in random positions, or does the number of cutouts vary?

 

Message 3 of 12
bmerton
in reply to: Anonymous

The number of cutouts and their hw and xy positions relative to the axis will be controlled by a form.  If the cut out is not required, then it will be suppressed (or not unsuppressed).

 

The idea is to create the maximum amount of possible cut-outs first on a face, and then let the form unsuppress, control the height and width of the cut outs and then position them relative to xy as and when needed.

 

That's why I want quickly to create, say, 100 square cutouts and 100 round ones. on one face.  Ideally, the name of the feature would also be automatically updated.

Message 4 of 12
andrewwhiteinc
in reply to: bmerton

There's a few entry options for this. Would you want to load the Width/Height/Xposition/Yposition from excel? Or are you looking for code from a form?

 

Let me know and I'll take a crack at it, I've done something similar for creates electrical backboards.

P. Andrew White, P.Eng
Manufacturing Engineering Manager
Silent-Aire Manufacturing
Message 5 of 12
rjay75
in reply to: bmerton

Are these cutout equally spaced. If so something similar can be done with parameters and ilogic. 

 

Take a look at the sheet metal part attached.

 

 

Message 6 of 12
bmerton
in reply to: andrewwhiteinc

Thanks Andrew.

 

These cutouts need to be controlled by a form.  The reason being that I want to get it up on Configurator so that I can give a customer access to creating his own sheet metal cutouts on an enclosure (six sided).

 

I don't know what instruments they will be mounting or where they need to place them.

 

This is a very clumsy workaround, but it's the only viable solution I have come up with.  It means creating all possible features on all six faces.

 

Configurator doesn't allow any excel add-ins, so this has to be done entirely with parameters, forms and iLogic.

Message 7 of 12
bmerton
in reply to: rjay75

Thanks Rodney but they are neither equally spaced, nor equally sized nor equally shaped nor equally all visible / suppressed.

 

I need to be able to control each of the parameters for each and every hole, which may be anywhere on the surface.

Message 8 of 12
andrewwhiteinc
in reply to: bmerton

I would recommend looking at VB to code this and the form, you would have alot more available in terms of functionality for what you are trying to achieve.

 

I've actually skipped iLogic and went straight into visual studio development for this reason.

 

Let me know if thats a route you want to look at and I'll write you the code you'll need.

P. Andrew White, P.Eng
Manufacturing Engineering Manager
Silent-Aire Manufacturing
Message 9 of 12
bmerton
in reply to: andrewwhiteinc

Andrew

I am okay with VB I think. A bit rusty but I would definitely like to
give it a try...thanks so much for your inputs!!

Ben
Message 10 of 12
andrewwhiteinc
in reply to: bmerton

Here's a program to get you started. There's little to no error caching on it but it works. Play around with it and you will be able to program what you are looking for. Re-post if you get stuck of course.

 

I created a form called frmTestCode in by project in Visual Studio Express 2010. I added 4 text boxes and a button: posX, posY, CutLength, CutWidth and btnCutRectangle respectively. Here's the code from the form:

 

 

Imports System.Runtime.InteropServices
Imports Inventor

Public Class frmTestCode


    Private Sub btnCutRectangle_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCutRectangle.Click
        Dim oINV As Inventor.Application = Marshal.GetActiveObject("Inventor.Application") 'have inventor open and use the marshall to connect with it (late binding)

        Dim oFace As Face = oINV.CommandManager.Pick(SelectionFilterEnum.kPartFaceFilter, "Select face to cut.") 'prompt user to select a face on the part to cut out
        If IsNothing(oFace) = True Then Exit Sub 'exit if the user does not select anything

        Dim oPart As PartDocument = oINV.ActiveDocument 'get the actively displayed document, not this lacks error caching, ie your program could crash here is an assembly is displayed for example

        'setup lower left and upper right points for the rectangle
        Dim PositionX As Double = Double.Parse(Me.posX.Text) 'get the entries and convert them to a decimal for creating points
        Dim PositionY As Double = Double.Parse(Me.posY.Text) 'note that the API uses these values as centimeters, i typically multiply them here by 2.54 if they are entered in inches on the form
        Dim CutWidth As Double = Double.Parse(Me.CutWidth.Text)
        Dim CutLength As Double = Double.Parse(Me.CutLength.Text)

        'create geometry points to be used by the application to create the rectangle
        Dim LowerLeftPoint As Point2d = oINV.TransientGeometry.CreatePoint2d(PositionX, PositionY)
        Dim UpperRightPoint As Point2d = oINV.TransientGeometry.CreatePoint2d(PositionX + CutWidth, PositionY + CutLength)

        Dim oSketch As Sketch = oPart.ComponentDefinition.Sketches.Add(oFace) 'add a sketch, edit it, use the built in function to create your rectangle, exit editor
        oSketch.Edit()
        oSketch.SketchLines.AddAsTwoPointRectangle(LowerLeftPoint, UpperRightPoint)
        oSketch.ExitEdit()

        Dim oProfile As Profile = oSketch.Profiles.AddForSolid 'defines the profile for the extrude, similar to selecting it using the UI workflow
        Dim oExtrudeDef As ExtrudeDefinition = oPart.ComponentDefinition.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, PartFeatureOperationEnum.kCutOperation) 'creates the definition needed to extrude

        Dim cutDepth As Double = 1
        Dim oExtrude As ExtrudeFeature = oPart.ComponentDefinition.Features.ExtrudeFeatures.AddByDistanceExtent(oProfile, cutDepth, PartFeatureExtentDirectionEnum.kSymmetricExtentDirection, PartFeatureOperationEnum.kCutOperation)
    End Sub
End Class

 

Clicking the button with a part open in inventor and after selecting a face when prompted, you will get the rectangle cut as shown in the attached images.

P. Andrew White, P.Eng
Manufacturing Engineering Manager
Silent-Aire Manufacturing
Message 11 of 12
bmerton
in reply to: andrewwhiteinc

Andrew

 

Many thanks for this.  I am running into problems.  I have created the text boxes and button and named them in the Name field on the properties as you say.

 

However, when I paste the code I am getting the following errors:

 

Error 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. 

 

Error 2 'posX' is not a member of 'WindowsApplication1.frmTestCode'.

 

and the same errors for all the Text boxes.

 

I am assuming that I haven't defined the items properly (ie just changing the name won't do it - there should be some other link).

 

I am also unable to get the Label text (ie Position X, Position Y as in your screenshot) to appear to the left of the text field.  Am I missing something?

 

Again, thank you for all your help in advance.  I haven't worked with VB for years, so it will take some time to get into the swing of things!

 

Ben

 

 

Message 12 of 12
andrewwhiteinc
in reply to: bmerton

no worries, glad to help,

 

Error 1 Handles clause requires a WithEvents variable defined in the containing type or one of its base types. 

- create a new button with a different name and paste all the code after the line Sub ... and before End Sub

 

Error 2 'posX' is not a member of 'WindowsApplication1.frmTestCode'

- could be a name problem. look in the code for where posX is called and type Me. (when you type the "." a list of available controls comes up, that is where you find your text boxes)

P. Andrew White, P.Eng
Manufacturing Engineering Manager
Silent-Aire Manufacturing

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

Post to forums  

Autodesk Design & Make Report