Announcements
Due to scheduled maintenance, the Autodesk Community will be inaccessible from 10:00PM PDT on Oct 16th for approximately 1 hour. We appreciate your patience during this time.
Community
Inventor Programming - iLogic, Macros, AddIns & Apprentice
Inventor iLogic, Macros, AddIns & Apprentice Forum. Share your knowledge, ask questions, and explore popular Inventor topics related to programming, creating add-ins, macros, working with the API or creating iLogic tools.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Obtain the intermediate axis of the model to obtain the angle

0 REPLIES 0
Reply
Message 1 of 1
865966724
156 Views, 0 Replies

Obtain the intermediate axis of the model to obtain the angle

I used the code to obtain the part angle. Now I have encountered a new problem where the judgment criteria in my code are limited. When my parts are not on either side of the shaft, it seems that I cannot obtain the left and right parts. I am not good at coding and need help😫How to turn the axis into the center of the solid model?This is a solution that I came up with, but I cannot achieve it

 

 

'Assume ProfileHeight and ProfileWidth are defined and have values.
Dim isTall As Boolean = Measure.ExtentsLength > Measure.ExtentsWidth

Try
    Dim oMeasureTools As MeasureTools = ThisApplication.MeasureTools
    Dim oDoc As Document = ThisDoc.Document
    Dim oCompDef As ComponentDefinition = oDoc.ComponentDefinition
    Dim oSurfaceBody As SurfaceBody = oCompDef.SurfaceBodies.Item(1)

    Dim referencePlane As WorkPlane
    If isTall Then
        referencePlane = oCompDef.WorkPlanes.Item("YZ Plane")
    Else
        referencePlane = oCompDef.WorkPlanes.Item("XZ Plane")
    End If

    For Each oFace As Face In oSurfaceBody.Faces
        If oFace.SurfaceType = SurfaceTypeEnum.kPlaneSurface Then
            Dim FaceAngleRadians As Double = oMeasureTools.GetAngle(referencePlane, oFace)
            Dim FaceAngleDegrees As Double = FaceAngleRadians * 180 / Math.PI
            Dim FaceLocation As String
            
            If Not EqualWithinTolerance(FaceAngleDegrees, 90, 0.001) Then
                If isTall Then
                    If oFace.PointOnFace.X > 0 Then
                        FaceLocation = "Right"
                        Parameter("R") = Round(FaceAngleDegrees, 2)
                    Else
                        FaceLocation = "Left"
                        Parameter("L") = Round(FaceAngleDegrees, 2)
                    End If
                Else
                    If oFace.PointOnFace.Y > 0 Then
                        FaceLocation = "Right"
                        Parameter("R") = Round(FaceAngleDegrees, 2)
                    Else
                        FaceLocation = "Left"
                        Parameter("L") = Round(FaceAngleDegrees, 2)
                    End If
                End If
            End If

        End If
    Next
Catch
End Try

 

e59b05680d81ff5091bb29b3b84c9ac.png

0 REPLIES 0

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk Design & Make Report