Change Inflation Mesh via PyMechanical

Options
Tobias
Tobias Member Posts: 5
Name Dropper First Comment

Hey everyone,

I am trying to control the inflation layer on a mesh via a python script and got two problems. I try to address everything via NameSelection, since I have already defined them in advance and my current code looks like this:

Rotor_Inflation = mesh.AddInflation()
Rotor_Inflation.ScopingMethod = GeometryDefineByType.Component
Rotor_Inflation.NamedSelection = ExtAPI.DataModel.GetObjectsByName("Rotor_Face")[0]
Rotor_Inflation.InflationOption = 1
Rotor_Inflation.FirstLayerHeight = Quantity(0.4, "mm")
Rotor_Inflation.MaximumLayers = 15
Rotor_Inflation.NamedSelection = ExtAPI.DataModel.GetObjectsByName("Rotor_Aussenkante")[0]
Rotor_Inflation.Name = r"""Rotor_Inflation"""
Tree.Refresh()
mesh.GenerateMesh()


Now I have the first issue that in the second line
"Rotor_Inflation.ScopingMethod = GeometryDefineByType.Component" I get the following output:
"Typenkonflikt. (Exception from HRESULT: 0x80020005 (DISP_E_TYPEMISMATCH))".
I would like to know if "Component" is wrong here or what else I should use?

My second question is, how do I change the "Boundary Scoping Method" as right now I'm using two times the same code (Line 3 and 7) and this is not working as well?

Hope someone can help me out.
Best regards.

Answers

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

    You should be able to scope the Obj.Location and Obj.BoundaryLocation properties directly to a NS. This will auto-update the scoping defined by properties, so you don't need lines to change this explicitly. Simply set those properties equal to the NS of your choice.

  • Tobias
    Tobias Member Posts: 5
    Name Dropper First Comment
    Options

    Dear @Mike.Thompson
    thanks a lot for your quick and helpful respond. Unfortunatly I'm not sure what you mean with "scope the Obj.Location and Obj.BoundaryLocation properties directly to a NS" (With NS you probably mean Name Selection)? How excatly do I do that?
    Something like: "Rotor_Inflation.ScopingMethod = GeometryDefineByNameSelection"?

    Could you give me a code snippet, what I'm looking for?

    Best regards and a big thank you for your help!

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

    Something like this. You do not need any lines to change the scoping method. This will happen automatically:

    Inflation = Model.Mesh.AddInflation()
    Inflation.Location = ExtAPI.DataModel.GetObjectsByName("My Named Selection For Inflation")[0]
    Inflation.BoundaryLocation = ExtAPI.DataModel.GetObjectsByName("My Named Selection For Inflation Boundary")[0]

  • Tobias
    Tobias Member Posts: 5
    Name Dropper First Comment
    Options

    Perfect solution, excatly what I was looking for and so much easier.

    Thanks a lot for your help!! 😊👍️