Announcements
Attention for Customers without Multi-Factor Authentication or Single Sign-On - OTP Verification rolls out April 2025. Read all about it here.
Ralf_Krieg
in reply to: emilda.chiuye

Hello

 

What you want to get is the outer face face of RevolveFeature1. If you use named faces in your part, you can get them with one line of code. For instance, if you name the outer face of RevolveFeature1 as "Outer_Face_of_RevolveFeature1", the iLogic would be

Dim NamedEntity = iLogicVb.Automation.GetNamedEntities.FindEntity("Outer_Face_of_RevolveFeature1")

If you don't use named faces, there's a bit more work to do. A revolve feature can have a void inside, can have a cylinder or a cone on the outside and can have more than one face on the outside. You have to check all of this possible situations and grep the right face. Here's an example, but I'm not sure it covers all possible situations.

 

Private Sub Main()
    
    Dim oApp As Inventor.Application= ThisApplication
    Dim oDoc As Inventor.PartDocument= oApp.ActiveDocument
    Dim oDef As Inventor.PartComponentDefinition= oDoc.ComponentDefinition
    Dim oTG As Inventor.TransientGeometry= oApp.TransientGeometry
    Dim oRepMan As Inventor.RepresentationsManager= oDef.RepresentationsManager
    Dim oDesignViewReps As Inventor.DesignViewRepresentations= oRepMan.DesignViewRepresentations
    Dim oOuterFace As Inventor.Face
    Dim oRevolveFeature As Inventor.RevolveFeature

    For Each oRevolveFeature In oDef.Features.RevolveFeatures
        If Feature.IsActive(oRevolveFeature.Name) And oRevolveFeature.HealthStatus = HealthStatusEnum.kUpToDateHealth Then
            If CheckExistLeader(oRevolveFeature) = False Then
                oOuterFace = GetOuterFace(oRevolveFeature)
                
                Dim oAnnoPlaneDef As Inventor.AnnotationPlaneDefinition= oDef.ModelAnnotations.CreateAnnotationPlaneDefinitionUsingPlane(oDef.WorkPlanes(2))
                Dim oLeaderPoints As Inventor.ObjectCollection= oApp.TransientObjects.CreateObjectCollection
                Dim oIntentPoint As Point
                
                Select Case oOuterFace.SurfaceType
                Case SurfaceTypeEnum.kConeSurface:
                    oIntentPoint = GetPointOnCone(oOuterFace)
                Case SurfaceTypeEnum.kCylinderSurface:
                    oIntentPoint = GetPointOnCylinder(oOuterFace)
                End Select
                 
                Dim oLeaderIntent As Inventor.GeometryIntent= oDef.CreateGeometryIntent(oOuterFace, oIntentPoint)
                'The Leaderpoint should be relative positioned to the LeaderPoint 1
                Call oLeaderPoints.Add(oTG.CreatePoint(oIntentPoint.X + 1, 0, oIntentPoint.Z + 1))
                Call oLeaderPoints.Add(oLeaderIntent)

				Dim sFormattedText As String
                sFormattedText = "2000"
                
                Dim oLeaderDef As Inventor.ModelLeaderNoteDefinition = oDef.ModelAnnotations.ModelLeaderNotes.CreateDefinition(oLeaderPoints, sFormattedText, oAnnoPlaneDef)
                
                Dim oLeader As Inventor.ModelLeaderNote= oDef.ModelAnnotations.ModelLeaderNotes.Add(oLeaderDef)
                
                oOuterFace = Nothing
            End If
        End If
    Next
End Sub

Private Function CheckExistLeader(ByVal oRevolveFeature As RevolveFeature) As Boolean
    Dim oPartCompDef As PartComponentDefinition = oRevolveFeature.Parent
    Dim oLeaderNotes As ModelLeaderNotes = oPartCompDef.ModelAnnotations.ModelLeaderNotes
    Dim oIntentFace As Face
    Dim oLeaderNote As ModelLeaderNote
    For Each oLeaderNote In oLeaderNotes
        oIntentFace = oLeaderNote.Definition.Intent.Geometry
    Next
End Function

Private Function GetOuterFace(ByVal oRevolveFeature As Inventor.RevolveFeature) As Inventor.Face
    Dim oFace As Inventor.Face
    Dim oOuterFace As Inventor.Face
    For Each oFace In oRevolveFeature.Faces
        If oFace.SurfaceType = SurfaceTypeEnum.kConeSurface Or oFace.SurfaceType = SurfaceTypeEnum.kCylinderSurface Then
            If Not oOuterFace Is Nothing Then
                If oFace.Geometry.Radius > oOuterFace.Geometry.Radius Then
                    oOuterFace = oFace
                End If
            Else
                oOuterFace = oFace
            End If
        End If
    Next
	GetOuterFace = oOuterFace
End Function

Private Function GetPointOnCone(ByVal oFace As Face) As Point
    Dim oCone As Cone= oFace.Geometry
    Dim oSB As SurfaceBody= oFace.SurfaceBody
    Dim oBasis As Point = oCone.BasePoint
    Dim oRadius As Double = oCone.Radius
    Dim oEnts As Inventor.ObjectsEnumerator
    Dim oPoints As Inventor.ObjectsEnumerator
    Dim oVector As Vector= ThisApplication.TransientGeometry.CreateVector(0, 1, 0)
    
    Call oSB.FindUsingRay(oBasis, oVector.AsUnitVector, oRadius, oEnts, oPoints, False)
    
    If oEnts.Count > 0 Then
        Dim i As Integer
        For i = 1 To oEnts.Count
            If oEnts(i) Is oFace Then
                GetPointOnCone = oPoints(i)
            End If
        Next
    End If
End Function

Private Function GetPointOnCylinder(ByVal oFace As Face) As Point
    Dim oCylinder As Cylinder= oFace.Geometry
    Dim oSB As SurfaceBody= oFace.SurfaceBody
    Dim oBasis As Point = oCylinder.BasePoint
    Dim oRadius As Double= oCylinder.Radius
    Dim oEnts As Inventor.ObjectsEnumerator
    Dim oPoints As Inventor.ObjectsEnumerator
    Dim oVector As Vector = ThisApplication.TransientGeometry.CreateVector(0, 1, 0)
    
    Call oSB.FindUsingRay(oBasis, oVector.AsUnitVector, oRadius, oEnts, oPoints, False)
    
    If oEnts.Count > 0 Then
        Dim i As Integer
        For i = 1 To oEnts.Count
            Call ThisApplication.ActiveDocument.SelectSet.Select(oEnts(i))
            Select Case oEnts(i).Type
            Case kVertexObject:
            Case kEdgeObject:
                Dim oEdge As Edge= oEnts(i)
                Dim oConFace As Face
                For Each oConFace In oEdge.Faces
                    If oConFace Is oFace Then
                        GetPointOnCylinder = oPoints(i)
                    End If
                Next
            Case kFaceObject:
                GetPointOnCylinder = oPoints(i)
            End Select
        Next
    End If
End Function
    

 


R. Krieg
RKW Solutions
www.rkw-solutions.com