How to select all bolt holes on all bodies and create washers, using space claim scripting

SK
SK Member Posts: 6
First Comment Name Dropper
**
edited January 19 in 3D Design

How to select all bolt holes on all bodies and create washers around all selected holes, equal to 2 times dia of that hole. And later I want to create fixed joints in mechanical between opposite washer faces of bolt holes. Can anyone help me the script as we have 100s of bolt to be modeled with the fixed joints.

Answers

  • Abhijith Rajan
    Abhijith Rajan Member, Employee Posts: 8
    First Answer First Comment First Anniversary
    ✭✭✭
    edited March 16

    Hey SK, You may check this script and make necessary modifications.

    myedges=Selection.Create(mybodies).ConvertToEdges().ConvertByShape(GeometryType.Circle)
    for e in myedges:
    if e.Items[0].Shape.Geometry.Radius > MM(5.39/2) and e.Items[0].Shape.Geometry.Radius < MM(5.4/2) : # you may edit here with your required Radius/Diameter Values

            selection = e
            direction = MoveImprintEdges.GetImprintDirection(e, e.ConvertToFaces().ConvertByShape(GeometryType.Plane), False)
            options = MoveImprintEdgeOptions()
            result = MoveImprintEdges.Execute(selection, direction, MM(-1.64), options) # this value changes the washer dia
    

    myreqfaces=List IDesignFace
    myfaces=Selection. Create(GetRootPart().GetAllBodies()).ConvertToFaces().ConvertByShape(GeometryType.Plane)
    for f in myfaces:
    myedges=f.ConvertToEdges()
    if myedges.Count==2:
    myreqfaces.Add(f.Items[0])

    Selection.Create(myreqfaces).CreateAGroup("MyReqFaces")

  • Abhijith Rajan
    Abhijith Rajan Member, Employee Posts: 8
    First Answer First Comment First Anniversary
    ✭✭✭
    edited March 16

    Check out this sample code for creating the washer splits. You may make the necessary changes by changing the Hole Diameter and Washer Diameter values. Note that this script would create the washer split in both side of the hole

    myedges=Selection.Create(mybodies).ConvertToEdges().ConvertByShape(GeometryType.Circle)
    for e in myedges:
    if e.Items[0].Shape.Geometry.Radius > MM(5.39/2) and e.Items[0].Shape.Geometry.Radius < MM(5.4/2) :

            selection = e
            direction = MoveImprintEdges.GetImprintDirection(e, e.ConvertToFaces().ConvertByShape(GeometryType.Plane), False)
            options = MoveImprintEdgeOptions()
            result = MoveImprintEdges.Execute(selection, direction, MM(-1.64), options)
    

    myreqfaces=List IDesignFace
    myfaces=Selection. Create(GetRootPart().GetAllBodies()).ConvertToFaces().ConvertByShape(GeometryType.Plane)
    for f in myfaces:
    myedges=f.ConvertToEdges()
    if myedges.Count==2:
    myreqfaces.Add(f.Items[0])

    Selection.Create(myreqfaces).CreateAGroup("MyReqFaces")

  • SK
    SK Member Posts: 6
    First Comment Name Dropper
    **

    Many thanks. Can you please tell me where to declare mybodies as I'm getting an error saying "name 'mybodies' is not defined"