I am trying to simply place a hole onto a face of a part. Even though Inventor Help says I can, there is no option or prompt to select a face. It says, "valid inputs for holes include a face...."
My "Allow center point creation is ON" because it says that when it is on you can create a hole center randomly on a face which is exactly what I'm trying to do.
However it is not selecting anything when I hover anywhere on the part.
This can't be that hard. Sheesh.
Solved! Go to Solution.
Solved by Stakin. Go to Solution.
hey we all have those days where things are screwy. can you upload the part so i can take a look at what you are seeing please.
Thanks. After realizing this may not be on the right forum I re-posted under just the Inventor board. And u can see my and others replies. At the end of the day, I suddenly for no apparent reason on my part, was able to suddenly be able to select a face. Now I'm struggling with positioning it with respect to two edges as holes usually are.
I am able to position it with respect to one edge but can't figure out how to get it to select the other edge to dimension from. Sigh.
the best workflow i've found for that is, to create a sketch first then use the hole command, i know that can be cumbersome but its the best way i've found to get a consistent result.
like if you agree please.
Sub main()
Dim oPrt As PartDocument
oPrt = ThisApplication.ActiveDocument
Dim oHole As HoleFeature
Dim oPdef As PartComponentDefinition
oPdef=oPrt.ComponentDefinition
Dim oEdge1 As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Linear Edge 1")
Dim oEdge2 As Edge = ThisApplication.CommandManager.Pick(SelectionFilterEnum.kPartEdgeFilter, "Select Linear Edge 2")
Dim oPlane As Face =Nothing
If oEdge1 Is Nothing Or oEdge2 Is Nothing Then
MessageBox.Show("UnLess 2 edges Selected!Exit!", "Title")
Exit Sub
Else
Dim oLine As LineSegment = oEdge1.Geometry
For Each ofc As Face In oEdge1.Faces
If ofc.Edges.cast(Of Edge).Where(Function(oEd) oEd Is oEdge2).Count=1 Then
oPlane = ofc
Exit For
End If
Next
If oPlane Is Nothing Or oLine.IntersectWithCurve(oEdge2.Geometry).Count = 0 Then
MessageBox.Show("The edges are not on same face or coplanar,exit!", "Title")
Else
' MessageBox.Show("Successful selected,Be Create HoleFeature", "Title")
End If
End If
Dim oBiasPoint As Point
oBiasPoint=oPdef.MassProperties.CenterOfMass
Dim oLhdef As LinearHolePlacementDefinition
oLhdef = oPdef.Features.HoleFeatures.CreateLinearPlacementDefinition(oPlane, oEdge1, "1.5 cm", oEdge2, "1.5 cm", oBiasPoint)
oHole=oPdef.Features.HoleFeatures.AddDrilledByThroughAllExtent(oLhdef,"1 cm",PartFeatureExtentDirectionEnum.kPositiveExtentDirection)
End Sub
Try, and also refer to the sample "Hole feature linear placement".
Public Sub HoleFeatureLinearPlacement()
' Create a new part document, using the default part template.
Dim oPartDoc As PartDocument
Set oPartDoc = ThisApplication.Documents.Add(kPartDocumentObject, _
ThisApplication.FileManager.GetTemplateFile(kPartDocumentObject))
' Set a reference to the component definition.
Dim oCompDef As PartComponentDefinition
Set oCompDef = oPartDoc.ComponentDefinition
' Create a new sketch on the X-Y work plane.
Dim oSketch As PlanarSketch
Set oSketch = oCompDef.Sketches.Add(oCompDef.WorkPlanes.Item(3))
' Set a reference to the transient geometry object.
Dim oTransGeom As TransientGeometry
Set oTransGeom = ThisApplication.TransientGeometry
' Create a square on the sketch.
Call oSketch.SketchLines.AddAsTwoPointRectangle( _
oTransGeom.CreatePoint2d(0, 0), _
oTransGeom.CreatePoint2d(6, 6))
' Create the profile.
Dim oProfile As Profile
Set oProfile = oSketch.Profiles.AddForSolid
' Create an extrusion.
Dim oExtrudeDef As ExtrudeDefinition
Set oExtrudeDef = oCompDef.Features.ExtrudeFeatures.CreateExtrudeDefinition(oProfile, kJoinOperation)
Call oExtrudeDef.SetDistanceExtent("2 cm", kNegativeExtentDirection)
Dim oExtrude As ExtrudeFeature
Set oExtrude = oCompDef.Features.ExtrudeFeatures.Add(oExtrudeDef)
' Get the start face of the extrude.
Dim oFace As Face
Set oFace = oExtrude.StartFaces(1)
' Get two adjacent edges on the start face.
Dim oEdge1, oEdge2 As Edge
Set oEdge1 = oFace.Edges(1)
Set oEdge2 = oFace.Edges(2)
' Create a bias point for hole placement to place it at
' the expected location. This is the model point
' corresponding to the center of the square in the sketch.
Dim oBiasPoint As Point
Set oBiasPoint = oSketch.SketchToModelSpace(oTransGeom.CreatePoint2d(1.5, 1.5))
' Create the hole feature placement definition.
Dim oLinearPlacementDef As LinearHolePlacementDefinition
Set oLinearPlacementDef = oCompDef.Features.HoleFeatures.CreateLinearPlacementDefinition _
(oFace, oEdge1, "2 cm", oEdge2, "2 cm", oBiasPoint)
' Create the hole feature.
Call oCompDef.Features.HoleFeatures.AddDrilledByThroughAllExtent( _
oLinearPlacementDef, "1 cm", kPositiveExtentDirection)
End Sub
Hey thanks for that but I am not a programmer just a long time user (decades) of AutoCAD and a new student of Inventor (sort of). I reposted this on just the Inventor forum after realizing I mistakenly placed this on this "programming" forum of Inventor. So, I appreciate your effort and apologize for causing you to work out something for me that I may or may not know how to implement.
Can't find what you're looking for? Ask the community or share your knowledge.