|
[Sponsors] |
![]() |
![]() |
#1 |
New Member
HOJUN YU
Join Date: Jul 2020
Posts: 15
Rep Power: 4 ![]() |
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! |
|
![]() |
![]() |
![]() |
![]() |
#2 |
New Member
Join Date: May 2014
Posts: 21
Rep Power: 11 ![]() |
Hi, what do you mean by "according to a certain time."?
|
|
![]() |
![]() |
![]() |
![]() |
#3 |
New Member
HOJUN YU
Join Date: Jul 2020
Posts: 15
Rep Power: 4 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#4 |
New Member
Join Date: May 2014
Posts: 21
Rep Power: 11 ![]() |
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() |
|
![]() |
![]() |
![]() |
![]() |
#5 |
New Member
HOJUN YU
Join Date: Jul 2020
Posts: 15
Rep Power: 4 ![]() |
wow.. thank you !
Is it possible for each Properties ID or properties NAME I designated, not by part? |
|
![]() |
![]() |
![]() |
![]() |
#6 |
New Member
Join Date: May 2014
Posts: 21
Rep Power: 11 ![]() |
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 |
|
![]() |
![]() |
![]() |
![]() |
#7 |
New Member
HOJUN YU
Join Date: Jul 2020
Posts: 15
Rep Power: 4 ![]() |
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?? |
|
![]() |
![]() |
![]() |
![]() |
#8 |
New Member
Join Date: May 2014
Posts: 21
Rep Power: 11 ![]() |
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. |
|
![]() |
![]() |
![]() |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Ansa Script | ganesh0481 | ANSA | 47 | February 21, 2019 04:09 |
simplifiedSiwek - error in calculating the position of a coal error | guitar_love_15 | OpenFOAM Running, Solving & CFD | 0 | November 4, 2018 04:06 |
Ansa Script | Grigoriy_Ermolaev | ANSA | 3 | April 20, 2017 04:50 |
Wrong flow in ratating domain problem | Sanyo | CFX | 17 | August 15, 2015 06:20 |
manualInjection model in sprayFoam | Mentalo | OpenFOAM Running, Solving & CFD | 1 | April 2, 2014 09:29 |