Workplanes angles

Workplanes angles

VGonsalves
Advocate Advocate
1,004 Views
4 Replies
Message 1 of 5

Workplanes angles

VGonsalves
Advocate
Advocate
In a part file is it possible to find the adaptive workplanes used to create extrusion1. And then find if the two workplanes are at an angle with respect to the origin planes.
Have been looking for a while but it seems hard to find information on workplanes
0 Likes
Accepted solutions (1)
1,005 Views
4 Replies
Replies (4)
Message 2 of 5

philippe.leefsma
Alumni
Alumni

Information about workplanes is exposed through API, so you should be able to retrieve it without problem. It of course depends what situation you are in, I mean by that what is your input data and what you are looking for.

 

For an ExtrudeFeature based on a workplane, you can retrieve it using

 

ExtrudeFeature.Profile.Parent.PlanarEntity

 

Concerning the angle, Workplane.Plane returns the geometric representation of the workplane. From Plane object, you can get the Normal and compute angles betweens the planes.

 

I hope it helps.

 

Regards,

Philippe.

 

 



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 3 of 5

VGonsalves
Advocate
Advocate

Thanks Philippe

 

With your help I have got one part done. Since I am just starting out in programming iLogic and also don't have access to the API model, the whole affair has been a struggle.

 

Well the code that I have so far is

Dim objDocument As PartDocument
objDocument = ThisApplication.ActiveDocument
Dim objFeatures As PartFeatures
objFeatures = objDocument.ComponentDefinition.Features
Dim objExtrudes as ExtrudeFeatures
objExtrudes = objFeatures.ExtrudeFeatures
Dim objExtrude As ExtrudeFeature

objExtrude = objExtrudes.Item(1)
oSketch = objExtrude.Profile.Parent.PlanarEntity

MessageBox.Show(oSketch.Name, "Title")

 

Now if you could help in any way in checking the endfaces or workplane angles. I have attached a sample file with an adaptive extrusion and would like to collect the end face angles.

 

I think the way this can be done is

  1. Collect the first extrusion (as done in the code above)
  2. then find the end faces (need help here)
  3. calculate the angles between them and the origin plane as collected by oSketch (need help here)

Not to sure how to do any of the above. Hope you can help me out when you find the time.

 

Thank you

 

0 Likes
Message 4 of 5

philippe.leefsma
Alumni
Alumni
Accepted solution

Hi

 

What do you mean you don't have access to the API Object Model? That's public information.

 

Here is the place where you should start if you are new to Inventor Programming:

 

Autodesk Inventor

 

Below is a VBA sample that shows you how to iterate through your extrusion faces and get angle between base workplane. The extrusion has no end face but it has 2 start faces instead (see pic below)

 

Public Sub GetExtrusionAngle()

    Dim doc As PartDocument
    Set doc = ThisApplication.ActiveDocument
    
    Dim extrusion As ExtrudeFeature
    Set extrusion = doc.ComponentDefinition.Features.ExtrudeFeatures(1)
    
    Dim wp As workplane
    Set wp = extrusion.profile.Parent.PlanarEntity
    
    Dim face As face
    For Each face In extrusion.StartFaces
    
        Dim normal As UnitVector
        Set normal = GetNormal(face)
        
        Dim angleRad As Double
        angleRad = wp.plane.normal.AngleTo(normal)
        
        Debug.Print "Angle (deg) = " & angleRad * 180# / 3.1416
        
    Next

End Sub

Function GetNormal(PlanarEntity As Variant) As UnitVector

    If (TypeOf PlanarEntity Is face Or TypeOf PlanarEntity Is faceProxy) Then
    
        Dim oFace As face
        Set oFace = PlanarEntity

        Set GetNormal = GetFaceNormal(oFace)
        Exit Function
    
    ElseIf (TypeOf PlanarEntity Is workplane Or TypeOf PlanarEntity Is WorkPlaneProxy) Then
    
        Dim oWorkPlane As workplane
        Set oWorkPlane = PlanarEntity

        Set GetNormal = oWorkPlane.plane.normal
        Exit Function
    
    End If

    Set GetNormal = Nothing
    
End Function

Private Function GetFaceNormal(face As face) As UnitVector

    Dim evaluator As SurfaceEvaluator
    Set evaluator = face.evaluator
    
    Dim ptOnFace As point
    Set ptOnFace = face.PointOnFace
    
    Dim points(2) As Double
    points(0) = ptOnFace.X
    points(1) = ptOnFace.Y
    points(2) = ptOnFace.Z
    
    Dim guessParams(1) As Double
    Dim maxDev(1) As Double
    Dim params(1) As Double
    Dim sol(1) As SolutionNatureEnum
    
    Call evaluator.GetParamAtPoint(points, guessParams, maxDev, params, sol)
    
    Dim normal(2) As Double
    
    Call evaluator.GetNormal(params, normal)
    
    Set GetFaceNormal = ThisApplication.TransientGeometry.CreateUnitVector( _
        normal(0), _
        normal(1), _
        normal(2))

End Function

 

extr.png

 

 

Regards,

Philippe.



Philippe Leefsma
Developer Technical Services
Autodesk Developer Network

0 Likes
Message 5 of 5

VGonsalves
Advocate
Advocate

Thank you for your help.

0 Likes