Get holes in pattern or mirror

DWhiteley
Advisor

Get holes in pattern or mirror

DWhiteley
Advisor
Advisor

I am extracting the thread info of holes as well as the brep data of each hole in a pattern or mirror.

At the moment I can only get the properties of the original hole.

Here is a snippet of the code. How can I get the properties of each hole in a pattern or mirror?

 

Ptr<Features> features = comp->features();
Ptr<ThreadFeatures> threads = features->threadFeatures();

Ptr<HoleFeatures> holes = features->holeFeatures();
size_t i = threads->count();
for (size_t j = 0; j < i; ++j)
{
Ptr<ThreadFeature> thread = threads->item(j);
Ptr<ThreadInfo> threadinfo = thread->threadInfo();
Ptr<BaseFeature> basef = thread->baseFeature();
Ptr<BRepFace> bface = thread->inputCylindricalFace();

 

Many thanks in advance, Dave

0 Likes
Reply
522 Views
4 Replies
Replies (4)

prainsberry
Autodesk
Autodesk

I think it's just about taking a different approach.  Get the info from the seed features on the pattern then get the placement information from the pattern and mirror features to compute the values for the rest of the holes.  Since there really isn't a "Hole Feature" in the locations created by the pattern.  Does that work for your application?

 



Patrick Rainsberry
Developer Advocate, Fusion 360
1 Like

DWhiteley
Advisor
Advisor

Hi Patrick,

 

I'm really stumped here. There seems to be no way to find out if a hole is in a pattern & to get access to that pattern.

 

Dave

0 Likes

prainsberry
Autodesk
Autodesk

i think the approach would be to kind of go in reverse.   Iterate over any pattern features that may exist in a design, then check if those pattern features contain any hole features you "care" about.

 

in pseudo code:

for rect_pattern in my_design.featuress.rectangularPatternFeatures:
    if rect_pattern.patternEntityType == adsk.fusion.PatternEntityTypes.FeaturesPatternType:
        for pattern_item in rect_pattern.inputEntities:
            if pattern_item.objectType == adsk.fusion.HoleFeature.classType():
                if pattern_item.is.something.I.care.about:
                    count_this()
    elif rect_pattern.patternEntityType == adsk.fusion.PatternEntityTypes.FacesPatternType:
        for pattern_item in rect_pattern.inputEntities:
            if figure_out_if_this_face_is_from_an_important_hole():
                count_this()

 Does that make sense?  If you are worried about if a user did a pattern of "faces" for the holes, you may have to do something tricky, like first iterate the hole features, find the "created" faces, then check if those faces are used in any patterns.  
You may want to take a look at Attributes, as this is a good way to keep track of faces.  You can put attributes on faces that are of concern, then easily check if the attribute exists, or find all faces with a particular attribute.

 

Another completely alternate approach, could be, iterate over all faces of all bodies in a design.  For each face figure out if it is a "hole."  Then get its characteristics.  



Patrick Rainsberry
Developer Advocate, Fusion 360
1 Like

DWhiteley
Advisor
Advisor
That pointed me in the right direction. Many thanks for taking the time to assist me.
1 Like