|
[Sponsors] |
September 18, 2018, 03:51 |
Compress PID - Python script
|
#1 |
New Member
Tibor Stefanovics
Join Date: Aug 2018
Posts: 6
Rep Power: 8 |
Hey Guys!
I would like to ask for a help. I need a Python script to Compress all the PIDs with same thickness in a model. Always keep the lower PID-ID and put all the Entities from the other properties to the one is kept. I have found a easy way to compress Materials with the same name and/or same values, but coudnt find this feature for PIDs. Mostly we are working with NASTRAN or LS-DYNA. I hope someone can help me with it. Thanks in advance! |
|
September 18, 2018, 07:13 |
|
#2 |
Member
Join Date: Mar 2018
Posts: 56
Rep Power: 8 |
i don't know how to do this by scripting.
but you can show only elements/entities/etc with the same thickness. then select all shown entities/elements/etc->modify->PID->set some and compress=) easy=) |
|
September 18, 2018, 07:17 |
|
#3 |
Member
Join Date: Mar 2018
Posts: 56
Rep Power: 8 |
but be carfully, because you will have problems with hiding/showing some entities if you keep only 1 PID... but if you doesn't work with huge assembles it isn't a issue to you=)
|
|
September 18, 2018, 07:26 |
|
#4 |
New Member
Tibor Stefanovics
Join Date: Aug 2018
Posts: 6
Rep Power: 8 |
Hi!
Thanks for the reply. This is actually what we are doing, but i need a script to do it with a single click. Btw i'm working on the script, but i'm not so good with python so i'm kinda suffering to write it. Sometimes our single-part models have several PIDs with the same tickness and if we have like 30 different thicknesses, then making the compression manualy (like you assumed) takes time. I just need a script for this to do it in secounds instead or minutes. |
|
September 18, 2018, 07:35 |
|
#5 |
Member
Join Date: Mar 2018
Posts: 56
Rep Power: 8 |
it takes secund, you are quite right-it is ot 1 click.
but ANSA is good in hide/show possibilities! in data manager sort by thickness->show only and do that i write =) it takes 10-15 seconds if you have a 100 pids with the same thickness=) but if you want to scripting...) it will be great.) |
|
October 15, 2018, 10:58 |
|
#6 |
New Member
Join Date: May 2014
Posts: 21
Rep Power: 12 |
Hi,
You can try something like: Code:
# PYTHON script import os import ansa from ansa import * def main(): deck = constants.NASTRAN shell_props = base.CollectEntities(deck, None, 'PSHELL') props_with_same_thickness = {} for prop in shell_props: vals = base.GetEntityCardValues(deck, prop, ['T']) prop_thickness = vals['T'] props_with_same_thickness.setdefault(prop_thickness, []) props_with_same_thickness[prop_thickness].append(prop._id) for key, values in props_with_same_thickness.items(): if len(values) >= 2: print('Merging PIDs with thickness: ', key) print('-------------------------------------------') min_id = min(values) min_pid = base.GetEntity(deck, 'PSHELL', min_id) for x in values: if x != min_id: current_pid = base.GetEntity(deck, 'PSHELL', x) shells = base.CollectEntities(deck, current_pid, 'SHELL', recursive = True) print('Assigning SHELLS of PID: ', x, ' to PID: ', min_id) for shell in shells: base.SetEntityCardValues(deck, shell, {'PID':min_id}) print('-------------------------------------------') base.Compress({'Properties':1}) if __name__ == '__main__': main() Greg |
|
October 16, 2018, 05:00 |
|
#7 |
New Member
Tibor Stefanovics
Join Date: Aug 2018
Posts: 6
Rep Power: 8 |
Thank You very mutch!
It's working like a charm! |
|
Thread Tools | Search this Thread |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
[OpenFOAM] Using python script for automatic post processing of openFoam | vPaquet | ParaView | 12 | December 16, 2021 03:30 |
python script to create geometry for salome, and then mesh | 6863523 | Mesh Generation & Pre-Processing | 4 | March 18, 2017 09:00 |
[General] Transfer variables into python script from bash-shell | cfdFreshman | ParaView | 0 | December 3, 2015 03:33 |
[General] Python script: Auto-scale color scale | julien.decharentenay | ParaView | 2 | December 9, 2013 05:39 |
CentFOAM Python Script Installation: Error | socon009 | OpenFOAM Installation | 2 | May 26, 2012 09:36 |