Is there any automatic way to imprint washers/bolt heads on a face in Discovery?

Javier Vique
Javier Vique Member, Employee Posts: 76
First Answer First Anniversary Name Dropper 5 Likes

For instance, let's assume that we've got a wind blade bearing and the idea is to automatically make an imprint of the bolts holes by an edge offset. That offset is given by a ratio of the hole radius. Image below gives an overview of the final target:


Best Answer

  • Javier Vique
    Javier Vique Member, Employee Posts: 76
    First Answer First Anniversary Name Dropper 5 Likes
    Answer ✓

    Below a script developed by @Pierre Thieffry to make that imprint on a selection of faces.

    import math
    offset_value=1.1 # Size for edge offset (radius*offset_value)
    max_radius=60 # in mm, will avoid offsets for any circular edge with higher radius
    # For face selection
    # Get face selection
    # Loop over faces to find circular edges
    if len(selected_faces)!=0:    
        for face in selected_faces:                        
            for edge in face.Edges:
                try:     # Radius will exist only for circular edges                   
                    radius = MeasureHelper.ArcRadius(EdgeSelection.Create(edge))*1e3
                    if radius<=max_radius:                
                    radius = 0                                    
    # Now loop over circular edges
    if len(AllEdges)>0:
        for i in range(len(AllEdges)):        
            edge = AllEdges[i]
                radius = MeasureHelper.ArcRadius(EdgeSelection.Create(edge))*1e3                
                # Compute Offset
                offset = float(offset_value)*radius         
                # Create imprint
                direction= MoveImprintEdges.GetImprintDirection(edge_selection,face_sel, False)                    
                options = MoveImprintEdgeOptions()
                result = MoveImprintEdges.Execute(edge_selection, direction, MM(-offset), options, None)            
                # Look at newly created faces to identify which face should be imprinted (when multiple circular edges are on the same face)        
                for check_face in result.CreatedFaces:
                    # Face we look for does not contain current edge
                    if edge not in check_face.Edges:
                # As face change after imprint, need to update association between edges and faces
                for edge, face in EdgeFaces.items():
                    if face==current_face:
                i = i + 1
                print('Issue with Imprints - check for possible overlaps')


  • Mike.Thompson
    Mike.Thompson Member, Employee Posts: 290
    First Anniversary First Comment 5 Likes Ansys Employee

    This is a great example. I have a few suggestions to make the code more robust if anybody wants to utilize this script at a large scale.

    -> You can determine if an edge is a circle or not with: str(E.Shape.Geometry.GetType()).endswith('Circle'). This would be faster than a try/except most likely if you have lots of non-circle edges.

    -> You can use the built in functions for unit conversions like "MM", "IN" instead of the factors like 1E3

    -> It would be better to group all the imprints that are along the same face into a single imprint operation. Currently the script does each one-by-one, but I think you can imprint multiple edges. Create a block that first identifies the imprints, then group them by face, and do all the edges for that face in a single imprint. This is only for speed with larger models.