CFD Online Discussion Forums

CFD Online Discussion Forums (https://www.cfd-online.com/Forums/)
-   ANSA (https://www.cfd-online.com/Forums/ansa/)
-   -   Mesh slected Areas using Python-script? (https://www.cfd-online.com/Forums/ansa/228591-mesh-slected-areas-using-python-script.html)

StrawHat July 7, 2020 07:11

Mesh slected Areas using Python-script?
 
Dear Community,

iīm new to Ansa Scripting (Python) and need to find a way that meshes selected Areas seperatly on a whole model - in this Case for example a part from a motorengine.
after running the existing Batch mesher, there are a lot of small areas that should be finer-meshed. To Avoid, that our engineers have to spent one whole day to mesh them finer manually, we Need a script.
The idea is, that the user can select some Areas and the script is meshing them finer without changing the non-selected Areas.
It would be great if the user is able to set the Parameters by himself (ex: if there is an angle of 90 Degree, he wants 3 rows)
Unfortunetly i didnīt find a solution anywhere.
Thankīs a lot for your help in Advance! :)

rmaries July 8, 2020 02:54

Hi,
There is no need of python script for this. Batchmesher is itself capable of doing this.
In the batch mesher parameter setting use the feature handler option and set right row numbers based on your fillet radius. I remember there is a tutorial for batch meshing in ansa tutorial folder. You can refer that for further info

Best Regards
Maries

StrawHat July 8, 2020 03:33

Quote:

Originally Posted by rmaries (Post 777153)
Hi,
There is no need of python script for this. Batchmesher is itself capable of doing this.
In the batch mesher parameter setting use the feature handler option and set right row numbers based on your fillet radius. I remember there is a tutorial for batch meshing in ansa tutorial folder. You can refer that for further info

Best Regards
Maries


Hi Maries,

Yes we are using it Right now and most of the time it does itīs Job well but on some Areas not, thats why we Need to mesh them manually or run a script for a finer mesh on the selected Areas.
Is there a better solution?
Thanks in Advance! :)

rmaries July 8, 2020 05:57

Yes that is possible.

Code:

IsolateRadius,    BETA PYTHON development Manual
NAME:
IsolateRadius - Isolates all the faces based on a given radius limit.

SYNOPSIS:
ansa.base.IsolateRadius(radius)  Named Arguments

DESCRIPTION:
This function isolates on the screen all the faces based on a given radius limit.
Arguments

radius  float    The radius limit to isolate the faces.

This command will isolate the surfaces with required radius in screen. Collect that face and apply the required meshing parameter.

StrawHat July 10, 2020 04:36

Thanks for your help!

is it also possible to mesh selected Fillets ?

For now, iīm using this code:

Quote:

def get_selected_Fillet_id():
print("please select Faces")
base.SetPickMethod(base.constants.ENT_SELECTION)
collected_entities = base.PickEntities(DECK, "FILLET")
#collected_type = type(collected_entities)
for entity in collected_entities:
return entity

The result is like :
Quote:

2201 3520 <Entity: 0x000001F302B92DC0: type: 3520(3520,FILLET_ENTITY) id:2201>
<class 'list'>

The entitiy._id is equal to the id of the selected Fillet in the Feature Manager.
How can i change Values here or mesh them seperatly by using an other mesh-param-file?

MRAJALIN August 20, 2020 00:05

Hi,

You can add collected fillet faces to the batch mesh scenario by using below API,

for this you have to save one separate meshing scenario.

SYNOPSIS:
ansa.batchmesh.AddPartToMeshingScenario(INPUT_ref, SCENARIO_ref)

DESCRIPTION:
This function adds an item or an array of items (part, group, property or volume) to a batch mesh scenario.

ARGUMENTS:
[required] INPUT_ref object References the item to be added to the senario. The type of the item may be a part, group,
property or volume.
[required] SCENARIO_ref object References the senario. The senario's type must be in accordance to the type of the item.



Regards,
Rajalingam. M

MikeMart November 2, 2020 10:59

Similar issue with scripting
 
Hello every one,

I am encountering a problem very similar to yours. In order to automate a rather long process, I'm scripting the generation of layers on Ansa. However, I'm encountering a problem, and I'm afraid it will be difficult to solve, as I have the impression that some functions are missing in Ansa scripting...

My problem is the following: I want to assign different names to my layers from a python script using ansa scripting, and these layers must be in the same layers generation session because they share common boundaries, so I can't put them in separate sessions, otherwise they don't connect properly when building layers.

So I want to:

- Create a session: batchmesh.GetNewLayersSession()
- Add the PID I want to mesh: batchmesh.AddPartToSession()
- Read a parameter map: batchmesh.ReadSessionMeshParams()
- Create a certain number of Area: batchmesh.GetNewLayersArea(name_area)
- Add some PIDs from my session to these areas. This is the blocking point, there is no function for that... Has anyone ever had the problem?

Thank you so much,
Regards,
Michael

greg.cfd December 16, 2020 11:09

@MikeMart:


Indeed such a function does not exist. As a workaround you could create a filter specifically for this layers area using AddFilterToSession. This function can be used for sessions and layer areas as well. Then apply the filters using DistributeAllItemsToScenarios.


For example if you have a pointer to the layers area (it is returned by the GetNewLayerArea function) named area1, you can use:


Code:

batchmesh.AddFilterToSession('Name', 'equals', 'SHELL_PROPERTY', area1, 'all', 'no', 'layer_area_filter_1')
batchmesh.DistributeAllItemsToScenarios()

The above will create a filter named 'layer_area_filter_1' with the expression Name = SHELL_PROPERTY, as defined by the first 3 argumeents of the function.


Regarding layers areas, these are entities of type: 'BATCH_MESH_LAYERS_AREA'. You can use this keyword to collect them (CollectEntities).


@StrawHat:
You could also delete the mesh from just the faces you wish to refine and then re-run your batch mesh with the option "Freeze existing mesh".


All times are GMT -4. The time now is 23:38.