Using inventor API to determine workplane that sketch is on

Using inventor API to determine workplane that sketch is on

Anonymous
Not applicable
894 Views
2 Replies
Message 1 of 3

Using inventor API to determine workplane that sketch is on

Anonymous
Not applicable

If I have a part consisting of a single extruded sketch, is there a way I can use inventors API to be able to tell which workplane the sketch is on? I'm trying to use this in an addin I'm making. (Using VBA)

 

EDIT: looks like this was already posted in the forums: https://forums.autodesk.com/t5/inventor-customization/ilogic-checking-on-which-plane-sketch-is-defin...

0 Likes
Accepted solutions (1)
895 Views
2 Replies
Replies (2)
Message 2 of 3

WCrihfield
Mentor
Mentor

Try this:

Dim oPDoc As PartDocument = ThisApplication.ActiveDocument
Dim oPDef As PartComponentDefinition = oPDoc.ComponentDefinition
Dim oExtFeat As ExtrudeFeature = oPDef.Features.ExtrudeFeatures.Item(1)
Dim oSketch As PlanarSketch = oExtFeat.Definition.Profile.Parent
Dim oWPlane As WorkPlane = oSketch.PlanarEntity
MsgBox("The extrusion sketch is on the WorkPlane named:  " & oWPlane.Name)

Oops. looks like you already found a solution.

Wesley Crihfield

EESignature

(Not an Autodesk Employee)

0 Likes
Message 3 of 3

Anonymous
Not applicable
Accepted solution

Thanks for the reply, I actually just got it to work by using PlanarEntity.Name to check the name of the plane the sketch is on, here is a section of the code im using it in:

 

Dim occ As ComponentOccurrence
For Each occ In assemDoc.ComponentDefinition.Occurrences
            For Each sk As PlanarSketch In occ.Definition.Sketches
                If sk.PlanarEntity.Name = "XY Plane" Then
                    axisNum = 3
                    planeNum = 2
                ElseIf sk.PlanarEntity.Name = "XZ Plane" Then
                    axisNum = 2
                    planeNum = 1
                ElseIf sk.PlanarEntity.Name = "YZ Plane" Then
                    axisNum = 1
                    planeNum = 2
                End If
            Next

Next

0 Likes