Determine which feature was created by using a specific sketch API

Determine which feature was created by using a specific sketch API

Anonymous
Not applicable
515 Views
5 Replies
Message 1 of 6

Determine which feature was created by using a specific sketch API

Anonymous
Not applicable

Hi!

I want to determine which extrusion feature was created used a specific sketch by using the API.

Other wording: Link between sketch and extrion by using the API?

Thanks for your help!

 

0 Likes
516 Views
5 Replies
Replies (5)
Message 2 of 6

Anonymous
Not applicable

Typo fix:


@Anonymous wrote:

Hi!

I want to determine which extrusion feature was created used a specific sketch by using the API.

Other wording: Link between sketch and extrion by using the API?

Thanks for your help!

 


* extrusion

0 Likes
Message 3 of 6

johnsonshiue
Community Manager
Community Manager

Hi! I am sorry I don't understand the question. What is the particular Sketch API you are talking about?

Many thanks!



Johnson Shiue (johnson.shiue@autodesk.com)
Software Test Engineer
0 Likes
Message 4 of 6

Anonymous
Not applicable

Hi, it is not meant to say "sketch API", i just wanted to add API to the title to show that it's a problem concerning the API.

0 Likes
Message 5 of 6

Anonymous
Not applicable

i iterated over all sketches and then found the sketch that matches my criteria. I am trying to export all features like holes and extrusions. Holes can also be designed as extrusions, so I identified all skeches which use circular sketches. In order to find out more about the "hole", I need to analyse the extrusion feature. I didn't find anything capable of finding the feature which made use of this specific sketch.

 

Thanks!

 

0 Likes
Message 6 of 6

BrianEkins
Mentor
Mentor

A sketch doesn't know which features use it.  Typically, a sketch is used by a single feature, but it's possible that any number of features can be based on the same sketch.

 

However, a feature does know which sketch it's based on.  Most features are based on profiles, which is a subset of geometry within a sketch that use selects when creating the feature.  The various feature objects provide access to the Profile that they use and from the profile, you can get its parent sketch.  Below is a simple VBA program that looks for extrude features that are based on a specific sketch.  Hopefully, this helps.

Public Sub GetFeatureFromSketch()
    Dim partDoc As PartDocument
    Set partDoc = ThisApplication.ActiveDocument
    Dim partComp As PartComponentDefinition
    Set partComp = partDoc.ComponentDefinition
    
    ' Get the sketch of interest.
    Dim sk As sketch
    Set sk = partComp.Sketches.Item("Sketch3")
    
    ' Iterate through the Extrude features to see if any of them use this sketch.
    Dim extrude As ExtrudeFeature
    For Each extrude In partComp.Features.ExtrudeFeatures
        ' Get the profile used for the extrusion.
        Dim prof As Profile
        Set prof = extrude.Definition.Profile
        
        ' Get the parent sketch of the profile.
        Dim extrudeSketch As sketch
        Set extrudeSketch = prof.Parent
        
' Check if the two sketches are the same. If extrudeSketch Is sk Then MsgBox "Extrusion " & extrude.name & " uses " & sk.name End If Next End Sub
---------------------------------------------------------------
Brian Ekins
Inventor and Fusion 360 API Expert
Website/Blog: https://EkinsSolutions.com
0 Likes