Test if cylindrical surface is inner or outer

Test if cylindrical surface is inner or outer

Gabriel_Watson
Mentor Mentor
906 Views
3 Replies
Message 1 of 4

Test if cylindrical surface is inner or outer

Gabriel_Watson
Mentor
Mentor

I wonder how to check if cylindrical faces have their normal pointing to their axis (inner cylindrical faces) or not (outer cylindrical faces). I tried looking for this information everywhere but it has not been possible to find any examples. So far I only got this post below as an indication:

https://forums.autodesk.com/t5/inventor-customization/how-can-i-get-all-the-holes-in-a-part-assembly...

 

Please help. Thank you!

0 Likes
907 Views
3 Replies
Replies (3)
Message 2 of 4

etaCAD
Advocate
Advocate

There is an example in the Inventor API help

I hope this helps

' Before running the sample, select a cylindrical face.
Public Sub IsCylindricalFaceInterior()
    Dim oDoc As Document
    Set oDoc = ThisApplication.ActiveDocument
    
    If Not Typeof oDoc.SelectSet(1) Is Face Then
        MsgBox "A face must be selected."
        Exit Sub
    End If
    
    Dim oFace As Face
    Set oFace = oDoc.SelectSet(1)
    
    If Not oFace.SurfaceType = kCylinderSurface Then
        MsgBox "A cylindrical face must be selected."
        Exit Sub
    End If
    
    Dim oCylinder As Cylinder
    Set oCylinder = oFace.Geometry
    
    Dim params(1) As Double
    params(0) = 0.5
    params(1) = 0.5
    
    ' Get point on surface at param .5,.5
    Dim points(2) As Double
    Call oFace.Evaluator.GetPointAtParam(params, points)
    
    ' Create point object
    Dim oPoint As point
    Set oPoint = ThisApplication.TransientGeometry.CreatePoint(points(0), points(1), points(2))
        
    ' Get normal at this point
    Dim normals(2) As Double
    Call oFace.Evaluator.GetNormal(params, normals)
    
    ' Create normal vector object
    Dim oNormal As Vector
    Set oNormal = ThisApplication.TransientGeometry.CreateVector(normals(0), normals(1), normals(2))
    
    ' Scale vector by radius of the cylinder
    oNormal.ScaleBy oCylinder.Radius
    
    ' Find the sampler point on the normal by adding the
    ' scaled normal vector to the point at .5,.5 param.
    Dim oSamplePoint As point
    Set oSamplePoint = oPoint
    
    oSamplePoint.TranslateBy oNormal
    
    ' Check if the sample point lies on the cylinder axis.
    ' If it does, we have a hollow face.
   
    ' Create a line describing the cylinder axis
    Dim oAxisLine As Line
    Set oAxisLine = ThisApplication.TransientGeometry.CreateLine _
        (oCylinder.BasePoint, oCylinder.AxisVector.AsVector)
        
    'Create a line parallel to the axis passing thru the sample point.
    Dim oSampleLine As Line
    Set oSampleLine = ThisApplication.TransientGeometry.CreateLine _
        (oSamplePoint, oCylinder.AxisVector.AsVector)
        
    If oSampleLine.IsColinearTo(oAxisLine) Then
        MsgBox "Interior face."
    Else
        MsgBox "Exterior face."
    End If
End Sub

Andreas
etaCAD

Message 3 of 4

bradeneuropeArthur
Mentor
Mentor

Hi,

 

In general the "programming help" file in inventor is always a good idea to take a look in first...

 

Regards,

Regards,

Arthur Knoors

Autodesk Affiliations & Links:
blue LinkedIn LogoSquare Youtube Logo Isolated on White Background


Autodesk Software:Inventor Professional 2025 | Vault Professional 2024 | Autocad Mechanical 2024
Programming Skills:Vba | Vb.net (Add ins Vault / Inventor, Applications) | I-logic
Programming Examples:
Drawing List!|
Toggle Drawing Sheet!|
Workplane Resize!|
Drawing View Locker!|
Multi Sheet to Mono Sheet!|
Drawing Weld Symbols!|
Drawing View Label Align!|
Open From Balloon!|
Model State Lock!
Posts and Ideas:
My Ideas|
Dimension Component!|
Partlist Export!|
Derive I-properties!|
Vault Prompts Via API!|
Vault Handbook/Manual!|
Drawing Toggle Sheets!|
Vault Defer Update!

! For administrative reasons, please mark a "Solution as solved" when the issue is solved !


 


EESignature

0 Likes
Message 4 of 4

Gabriel_Watson
Mentor
Mentor

@bradeneuropeArthur: "I tried looking for this information everywhere", but somehow this sample eluded me.

 

Thank you Andreas (@etaCAD), I will see if this solves my problem here!

0 Likes