How can we assign thickness to surface bodies automatically using scripting?

Erik Kostson
Erik Kostson Member, Moderator, Employee Posts: 331
50 Answers 100 Comments Second Anniversary 25 Likes
✭✭✭✭
edited May 2 in Structures

Say we have imported an external model and have hundreds of surface bodies not fully defined (missing thickness). Thus we just want to assign a shell thickness to these surface bodies to try things out (so to make sure model runs). Can this be done automatically via scripting?

Best Answer

  • Erik Kostson
    Erik Kostson Member, Moderator, Employee Posts: 331
    50 Answers 100 Comments Second Anniversary 25 Likes
    ✭✭✭✭
    edited May 6 Answer ✓

    Below is one way of doing this - it assigns to all unsuppressed surface bodies (that do not have a thickness), a 10 mm thickness - one could also read in the thickness from file and assign it accordingly - feel free to modify and to use with care and at your own risk):

    import units
    myunit='mm'
    myth=10
    for part in ExtAPI.DataModel.Project.Model.Geometry.Children: 
            if part.Suppressed is False: 
                partType = part.GetType() 
                if partType == Ansys.ACT.Automation.Mechanical.Part: 
                    for body in part.Children: 
                        if body.Suppressed is False:
                            if body.GeometryType==GeometryType.Surface:
                                th=body.Thickness
                                if th == Quantity(0, body.CentroidX.Unit):
                                    cth = units.ConvertUnit(myth, myunit,body.CentroidX.Unit, 'Length')
                                    body.Thickness=Quantity(cth, body.CentroidX.Unit)
    
    
This discussion has been closed.