I have to do similar operations in our engineer to order assemblies. Here's the basics of how we make it work:
- Once you click on the face that has holes, go through all of the holes to make a list (we also sort by type to make creating go quicker).
- Find the mating face. We go through the constraints and verify by measuring distance, but you could also just click the opposing face
- Find the center line of each of the holes. You'll need to create a proxy for it since you're jumping parts
- Find the intesection points of each of the center lines and the surface of the mated parts.
Dim foundPoints As ObjectsEnumerator = ThisApplication.TransientGeometry.CurveSurfaceIntersection(centerLine, targetFace.Geometry)
-Next you can either go one at a time by creating a workpoint in the part and adding the hole feature directly, or by creating a sketch, putting the point locations on a sketch, and adding all the points at once. Both ways work. If you're creating the workpoint we use the following function and hand it the foundPoint from above:
Function CreateWorkPointInComponent(comp As ComponentOccurrence, pointLocation As Point) As WorkPoint
Dim compMatrix As Matrix = comp.Transformation.Copy
compMatrix.Invert
Dim newPoint As Point = pointLocation.Copy
newPoint.TransformBy(compMatrix)
Return comp.Definition.WorkPoints.AddFixed(newPoint)
End Function
If you're doing them one at a time and especially if it's a curved surface you are poking the hole in, you can create a work axis tangent to the face and use that along w/ the work point to create the hole feature without creating a sketch
Dim def As PartComponentDefinition = GetDefinition(comp)
Dim holePlacementDef As PointHolePlacementDefinition = def.Features.HoleFeatures.CreatePointPlacementDefinition(holePoint, holeAxis)
Dim newHole As HoleFeature = def.Features.HoleFeatures.AddDrilledByDistanceExtent(holePlacementDef, holeDiameter, holeDepth, holeDirection)
The Hole creation documentation in the API is actually halfway decent and makes a good reference once you're ready to start creating the hole features. This should at least get you going in a helpful direction, but feel free to ask questions if you'd like me to clarify anything.
If this solved your problem, or answered your question, please click Accept Solution.