Here is an example iLogic rule that will create a work axis within an assembly that coincides with the center axis of a hole in a part within. My test assembly had two parts in it. Both parts had holes in them, but the target part only had one hole in it, that was made using a hole feature, instead of just an extruded cut feature. So, if I want to specify that cylindrical face of that hole in the part without manually selecting it, I must navigate to that cylindrical face within the part. Once I've got that face, I create a FaceProxy object from it, which brings its geometry over into the context of the assembly's 3D space, instead of that parts 3D space. Then I extract the Cylinder geometry from that cylindrical face, and extract the needed Point and UnitVector objects/data needed from that. Then I use the WorkAxes.AddFixed() method, supply those last two objects to it, and there you go.
If ThisApplication.ActiveDocumentType <> DocumentTypeEnum.kAssemblyDocumentObject Then
MsgBox("An Assembly Document must be active for this rule to work. Exiting.",vbOKOnly+vbCritical, "WRONG DOCUMENT TYPE")
Exit Sub
End If
Dim oADoc As AssemblyDocument = ThisApplication.ActiveDocument
Dim oADef As AssemblyComponentDefinition = oADoc.ComponentDefinition
Dim oComp As ComponentOccurrence = oADef.Occurrences.ItemByName("TestPart1:1")
Dim oPDoc As PartDocument = oComp.Definition.Document
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oHole As HoleFeature = oPDef.Features.HoleFeatures.Item(1)
'oHole.HoleCenterPoints 'could likely use these too
Dim oCylFace As Face = oHole.SideFaces.Item(1)
If oCylFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then
Dim oCylFaceProxy As FaceProxy
oComp.CreateGeometryProxy(oCylFace, oCylFaceProxy)
oCyl = oCylFaceProxy.Geometry
Dim oPoint As Inventor.Point = oCyl.BasePoint
Dim oAxis As UnitVector = oCyl.AxisVector
oADef.WorkAxes.AddFixed(oPoint, oAxis, False)
Else
MsgBox("Hole's first side face was not a Cylinder. Exiting.", , "")
Exit Sub
End If
You could likely condense this code a bit more if you wanted, but the process of how to do what you wanted should be fairly easy for you to follow. The key in this process is creating the FaceProxy, as you may have guessed.
If this solved your problem, or answered your question, please click ACCEPT SOLUTION.
Or, if this helped you, please click (LIKE or KUDOS) 👍.
If you want and have time, I would appreciate your Vote(s) for My IDEAS 💡or you can Explore My CONTRIBUTIONS
Wesley Crihfield

(Not an Autodesk Employee)