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

ansa model browser script

Register Blogs Members List Search Today's Posts Mark Forums Read

Like Tree3Likes
  • 1 Post By greg.cfd
  • 1 Post By greg.cfd
  • 1 Post By greg.cfd

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
Old   December 8, 2020, 20:45
Default ansa model browser script
  #1
New Member
 
HOJUN YU
Join Date: Jul 2020
Posts: 14
Rep Power: 4
hobing is on a distinguished road
hi.

example
model browser open > 'A' part , 'B' part , ..... 'Z' part

1. I want to see each part in order according to a certain time.
How do I create a script?

please help me

thank you!
hobing is offline   Reply With Quote

Old   December 16, 2020, 12:14
Default
  #2
New Member
 
Join Date: May 2014
Posts: 21
Rep Power: 10
greg.cfd is on a distinguished road
Hi, what do you mean by "according to a certain time."?
greg.cfd is offline   Reply With Quote

Old   December 21, 2020, 00:20
Default
  #3
New Member
 
HOJUN YU
Join Date: Jul 2020
Posts: 14
Rep Power: 4
hobing is on a distinguished road
sorry, I didn't explain it right

all i want to say is if i can see each part by name
i'm practicing my ANSA script
next script is example

import os.path
from os.path import expanduser
import ansa
from ansa import base
from ansa import utils
import time

home = expanduser("./path")
abs_filename_1 = os.path.join(home, 'image1.png')

def main():
t=time.time()
base.Open("./path/file_name.ansa")
base.SetViewButton({"SHADOW": "on", "VIEWMODE": "PID", "GRIDs": "off", "PERIMs": "off", "PERIM_POINTs": "off"})
set_view = base.SetViewAngles(f_key="F10")
status = utils.SnapShot(abs_filename_1, image_format='PNG', transparent=True, text_axes=False)
if status == 0:
print('Image saved in ' + abs_filename_1)



main()


this script can only be taken as a whole, but i want to take a snapshot by part
hobing is offline   Reply With Quote

Old   December 21, 2020, 10:40
Default
  #4
New Member
 
Join Date: May 2014
Posts: 21
Rep Power: 10
greg.cfd is on a distinguished road
You need to collect all parts and then loop over them using a for loop. To collect entities in ANSA you can use base.CollectEntities().
Then use base.Or() to isolate each part on the screen:



Code:
import os.path
from os.path import expanduser
import ansa
from ansa import base
from ansa import utils
import time

home = expanduser("./path")
abs_filename_1 = os.path.join(home, 'image1.png')

def main():
    t=time.time()
    base.Open("./path/file_name.ansa")
    base.SetViewButton({"SHADOW": "on", "VIEWMODE": "PID", "GRIDs":"off", "PERIMs": "off", "PERIM_POINTs": "off"})
    all_parts = base.CollectEntities(constants.OPENFOAM, None, 'ANSAPART')
    for part in all_parts:
        base.Or(part)
        set_view = base.SetViewAngles(f_key="F10")
        status = utils.SnapShot(abs_filename_1, image_format='PNG', t     ransparent=True, text_axes=False)
        if status == 0:
            print('Image saved in ' + abs_filename_1)



main()
hobing likes this.
greg.cfd is offline   Reply With Quote

Old   December 22, 2020, 02:59
Default
  #5
New Member
 
HOJUN YU
Join Date: Jul 2020
Posts: 14
Rep Power: 4
hobing is on a distinguished road
wow.. thank you !

Is it possible for each Properties ID or properties NAME I designated, not by part?
hobing is offline   Reply With Quote

Old   December 23, 2020, 08:09
Default
  #6
New Member
 
Join Date: May 2014
Posts: 21
Rep Power: 10
greg.cfd is on a distinguished road
Yes you can collect all PIDs using:


pids = base.CollectEntities(constants.OPENFOAM, None, 'SHELL_PROPERTY')


and then:


for pid in pids:
base.Or(pid)
...
...


All these are basic ANSA-entity and python interactions and you can find more info under:
Help Menu>Documentation Index>Scripting>Guides>ANSA & META Python API
hobing likes this.
greg.cfd is offline   Reply With Quote

Old   December 23, 2020, 20:44
Default
  #7
New Member
 
HOJUN YU
Join Date: Jul 2020
Posts: 14
Rep Power: 4
hobing is on a distinguished road
I'm doing it little by little, and it really helps a lot. Thanks for letting me know. You're a genius!!!!

I'm sorry, but can I ask you one more question?
what does base.Or mean??
hobing is offline   Reply With Quote

Old   December 24, 2020, 04:54
Default
  #8
New Member
 
Join Date: May 2014
Posts: 21
Rep Power: 10
greg.cfd is on a distinguished road
You're wellcome. base.Or() is the script equivalent of the OR focus command in GUI. It isolates entities on the screen (keeps them visible while hiding everything else).

You can see what each script function does in its help text in the script editor. Search for the function in the search list and double click on it to get the help text.
hobing likes this.
greg.cfd is offline   Reply With Quote

Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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 Script ganesh0481 ANSA 47 February 21, 2019 05:09
simplifiedSiwek - error in calculating the position of a coal error guitar_love_15 OpenFOAM Running, Solving & CFD 0 November 4, 2018 05:06
Ansa Script Grigoriy_Ermolaev ANSA 3 April 20, 2017 05:50
Wrong flow in ratating domain problem Sanyo CFX 17 August 15, 2015 07:20
manualInjection model in sprayFoam Mentalo OpenFOAM Running, Solving & CFD 1 April 2, 2014 10:29


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