Get Informationf of Features and its asscoicated Sketch using API

Get Informationf of Features and its asscoicated Sketch using API

Anonymous
Not applicable
1,250 Views
4 Replies
Message 1 of 5

Get Informationf of Features and its asscoicated Sketch using API

Anonymous
Not applicable

 I have a model with a list of features and sketch in it.

How do I access the information of the features and its associated sketch using API.

For eg.

I want to extract the information of feature of Sketch1 is Boss-Extrude1 and Sketch2 is Cut-Revolve2 and so on.

 

Is it possible to get this information from the tree view?

 

For a reference, I have attached the image of my model too.

 

キャプチャ.JPG

0 Likes
1,251 Views
4 Replies
Replies (4)
Message 2 of 5

cwhetten
Advisor
Advisor

Hello.  It appears to be possible.

 

In a part file:

 

ThisApplication.ActiveDocument.ComponentDefinition.Sketches will get you the collection of 2D sketches in the part.

 

Let's say oSketch1 is one of the objects in that collection:

 

oSketch1.Dependents will get you a collection of objects that includes any features generated from that sketch.  This part is a little tricky because there are probably other objects in that collection--for example, I saw that it included profile objects.  So, you'll have to find a way to loop through the collection and pick out just the dependent features, or maybe filter out anything that isn't a feature.

 

I hope this is helpful.

 

Cameron Whetten
Inventor 2016

0 Likes
Message 3 of 5

Anonymous
Not applicable

Hello,

Thank you for your help.

But I didn't get an idea to use it?

I used your solution in this way:

foreach (PlanarSketch oSketch in oPartDoc.ComponentDefinition.Sketches)
{
        MessageBox.Show(oSketch.Name);  //its gives the sketch name as Sketch1, but how to get the feature name as Boss-Extrude 1, linked with  Sketch1
         ObjectCollection aa = default(ObjectCollection);
        aa = oSketch.Dependents;

}

The variable aa gives the number of object i.e. count = 2.

but how do I know the  the information of feature, its name from this soltuion?

 

I might be wrong using the code, so please suggest me

Regard,

0 Likes
Message 4 of 5

Anonymous
Not applicable

Hello Whetten,

 

Thank you very much.

I did it using the BrowseNode function.

 

Thank you in advance. 🙂

0 Likes
Message 5 of 5

Maxim-CADman77
Advisor
Advisor

Could you, please, share with us your solution based on BrowseNode ?

Please vote for Inventor-Idea Text Search within Option Names

0 Likes