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.
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.
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.
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.
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.
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.
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.
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
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)