CFD Online Logo CFD Online URL
www.cfd-online.com
[Sponsors]
Home > Forums > Mesh Generation & Pre-Processing Software > ANSA

Ansa scripting

Register Blogs Community New Posts Updated Threads Search

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   April 15, 2019, 07:53
Default Ansa scripting
  #1
New Member
 
Manon Bour
Join Date: Apr 2019
Posts: 4
Rep Power: 7
manonB is on a distinguished road
Hi everyone!

I'm new to scripts with Ansa (and to python) and I am having some difficulties trying to deal with the geometry I created. (I am working with Abaqus deck)

1) Would someone know how to get some kind of list of the nodes and also get their coordinates. I want that because I am trying to get the nodes IDs and coordinates to write that in a mesh format that Ansa doesn't support yet (.mail Format).

2) with the function GetEntityType I am just able to determine that my entities are "SOLID". What could I do in order to know exactly what elements I have ? Like HEXA, PENTA... or more specifically C3D8, C3D6 from Abaqus

3) My last question is about the sets.
If I use CollectEntities with "SETS", the result is that I have a list of 1 set that I defined for my BCs. Is there any way to know which elements are in my set (get their IDs).

Sorry to ask so many different questions but I am really not able to do that and the documentation doesn't really help...

Thank you a lot in advance if you can help me!

Manon
manonB is offline   Reply With Quote

Old   April 16, 2019, 03:04
Default
  #2
Member
 
Maries
Join Date: Mar 2010
Location: Cologne, Germany
Posts: 75
Rep Power: 16
rmaries is on a distinguished road
1.

Code:
import os
import ansa
from ansa import constants
from ansa import base

def nodes_list(node):
	coord = base.GetEntityCardValues(constants.ABAQUS, node, ('X','Y','Z'))
	return [node._id, coord['X'], coord['Y'], coord['Z']]
This above code will take node as input and return a python list contains node id, x, y, z
rmaries is offline   Reply With Quote

Old   April 16, 2019, 04:02
Default
  #3
Member
 
Maries
Join Date: Mar 2010
Location: Cologne, Germany
Posts: 75
Rep Power: 16
rmaries is on a distinguished road
2. My idea is to collect element and check for its type. I checked with ansa scripts folder, they have also used the same method.

In the below code they collect the elements and check whether it is a quad element. You can follow similar way to find other elements.

Code:
def _coreFunction(TopWindow, data):
	warpLimit = float(guitk.BCLineEditGetText(data[0]))
	quadsToSplit = []
	shells = base.CollectEntities(deck, None, 'SHELL', filter_visible = True)
	for shell in shells:
		type = base.GetEntityCardValues(deck, shell, ['type'])['type']
		if type == 'QUAD':
			qual = base.ElementQuality(shell, 'warping')
			if qual > warpLimit:
				quadsToSplit.append(shell)
rmaries is offline   Reply With Quote

Old   April 16, 2019, 04:06
Default
  #4
Member
 
Maries
Join Date: Mar 2010
Location: Cologne, Germany
Posts: 75
Rep Power: 16
rmaries is on a distinguished road
3. You can collect elements in a set with base.collectentities

Code:
base.CollectEntities(constants.ABAQUS, set_list[0], __ELEMENTS__)
This above function will collect all the elements in set_list[0]
rmaries is offline   Reply With Quote

Old   April 16, 2019, 07:25
Default
  #5
New Member
 
Manon Bour
Join Date: Apr 2019
Posts: 4
Rep Power: 7
manonB is on a distinguished road
Hi rmaries! Thanks a lot for your replies!

I managed to find a solution to get the coordinates. It's almost the same as you. I used the .get_entity_values function.
Just this morning I was able to find the elements types by determining how many nodes are contained in a solid entity.

The only Thing that still doesn't work it to get the elements contained in a set. I did the same Thing as you but I doesn't work. I get an empty list as a result...
My code is:
sets=base.CollectEntities(deck, None,"SET")
print(sets)
set_elems_shell=base.CollectEntities(deck, sets, 'SHELL')
set_elems=base.CollectEntities(deck,sets,'__ELEMEN TS__')
print(set_elems_shell)
print(set_elems)

and the result is :
[<Entity: 0x000000000EF25D98: type: 3105(3105,PAMGROUP) id:1>]
[]
[]

I tried with SHELL and with ELEMENTS but every time it's the same.

If you have an idea of what I did wrong, I'm all ears!

Thanks again

Manon
manonB is offline   Reply With Quote

Old   April 16, 2019, 07:46
Default
  #6
Member
 
Maries
Join Date: Mar 2010
Location: Cologne, Germany
Posts: 75
Rep Power: 16
rmaries is on a distinguished road
did you define deck?

'SHELL' attribute changes according to deck value.

In __ELEMENTS__ you typed above, I found the space between N and T.

Also it depends what is contained in your sets. If your set doesn't contain any element or pid, it will return you empty list
rmaries is offline   Reply With Quote

Old   April 16, 2019, 08:17
Default
  #7
New Member
 
Manon Bour
Join Date: Apr 2019
Posts: 4
Rep Power: 7
manonB is on a distinguished road
Yes sorry my deck ist constants.ABAQUS
And the space must have poped up when I pasted the code, I don't have it in my script.

My set is a Group of 44 elements
manonB is offline   Reply With Quote

Old   April 16, 2019, 08:20
Default
  #8
New Member
 
Manon Bour
Join Date: Apr 2019
Posts: 4
Rep Power: 7
manonB is on a distinguished road
Thank you a lot! You made me realize that I don't have elements in my set but SOLIDFACET so now I can get their IDs !
manonB is offline   Reply With Quote

Reply


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Ansa Scripting (Open Excel/.txt file) gohwaikien ANSA 1 September 3, 2018 09:46
ANSA Scripting Show certain parts gohwaikien ANSA 0 May 24, 2018 18:22
How to rotate plane(360 degree) using ANSA scripting. Renu123 ANSA 1 March 14, 2018 18:26
ANSA Scripting sapnite ANSA 1 March 14, 2018 18:14
Ansa Python Scripting Renu123 ANSA 1 September 16, 2017 12:45


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