I have a query regarding load and boundary conditions syntax using PCL.
Problem definition: I am creating a session file for GFEM to DFEM pressure mapping using PCL commands. My query is, how patran is writing PLOAD cards for a particular subcase as highlighted in below example.
Example : How these highlighted load ids are considered in Patran PCL. Kindly explain the load case id pattern being considered as this is required to loop for many load cases.
these highlighted IDs are the internal ids of the LBCs that you are using to make the plot. These are probably all the pressure LBCs of the "current" Load Case.
You are filtering these through the gui form via the Object (= Pressure), "Current Load case" and as you highlight them in the list.
To get the lbc's for a load case name you could use functions:
db_count_lbc_by_load_case to retrieve the number of LBCs for a loadcase
ues this to size the arrays for the call to
db_get_load_case2 to retrieve all the LBC ids and additional data for the loadcase.
Then you need to filter the load_ids to get the ones you are interested in doing something with,
i.e. loop through all the LBC ids and call db_get_lbc and see what "load_type"
it is e.g. the pressure ones, and store the ones you want in the array you want to process.
Attached is a pcl routine to dump loadcase detail for a given name.
I'll leave you to do the next loop to filter those of the correct load_type.
Let me explain the problem in detail. I am creating a VBA macro to write a session file which will be used for pressure mapping as explained above. I need internal ids as input in my code so that once I run the session file in patran it should access the load case id and internal ids and map the pressure. But the problem here is internal ids are not in sequence.
I would like to know why the Patran starts internal LBCIds from 4 onwards. I have found something weird that if I select internal Ids to write dummy session file; Patran starts with 4,5,6 (for internal Ids having 4 digits) and then 8,14,20 with increment of 6 (for internal Ids having 5 digits). Any reason why is it like this?
With a new database Patran starts its internal IDs at 1 and they work upwards. However you should never rely on internal ID's as they are only for internal cross referencing. external labels are used to communicate with the outside world and these are the familiar names and numbers a user references through the gui.
The logic of the gaps that you see, for this model, will have an explanation that is related to all the other types of LBC that you are loading into the database at the same time. You should not try to use this type of logic to guess what the ids will be that you want to use. Rather than write VBA that tries to guess internal IDs, you should use your VBA to write a session file that has function calls to query the db and extract the necessary information to build the arguments to the functions you want to make.
The previous pcl function (to dump loadcase load ids) could, with some work, turn into a function that returns the number and string array of ids for a particular load type like pressure, This could be the arguments "11, [4,5, 6, 7, 13, 19, 25, 31, 37, 43, 49]" for the lbc_create_scalar_table function call.
You will need to write PCL code to query the database(similar to this example) and call this from (or embed this in) the session file you are writing.
I hope this helps you understand the logic of the internal IDs and also to appreciate that you should not try to guess what they will be but always query what they actually are. That way what ever happens internally in the db you session will find the right ids.
Many Thanks Arthur. Is there any threads in MSC that has already been covered in writing PCL code to query the database?. I am a beginner in PCL coding an example would be great to understand.
There is so much in the documentation on PCL it can be difficult to know where to start.
Certainly reviewing the section :
PCL and Customization : The PATRAN Command Language (PCL) Introduction :
will give you the details on the language syntax etc.
For your application the section
Accessing the Patran Database : Loads : Exportation of Load Data
will give you some insight into some of the functions you might need to call and some of the logic of how things relate to each other.
When coding make use of the index to cross reference PCL calls and find calls of similar type. Use links in the documentation to find example coding in the Reference Manual Examples section, the Acumen section and PCL Reference Manual.
A PAT304 PCL training class can be useful.
The old Patran special topics forum is where we discussed this type of thing and has a lot of discussion on PCL .
A session file is just a list of PCL, function calls etc and Patran is itself using PCL for its own functionality; understanding how to interpret the arguments is important, arrays, strings, integers etc.
Others may suggest things they have found useful, there is lots of information so finding the right bit can be tricky and there are often many ways to do the same thing like any programming language.
Thanks for guidance. Some queries regarding the same are listed below.
In ajh_dump_loadcase.pcl should I have to change the loadcase name and input in Patran? I changed it to my XXXXXXX load case but I got some errors in string length. Please correct me if I am wrong.
2. is it possible to dump the data into a report file or text file instead of "set1" in ajh_dump_loadcase.pcl .
Attached I have slightly modified the example code.
this function will automatically loop through all the loadcases and get the information for them. I was using "dump" as a lazy way of outputting variable data to the history window. It is really a debugging tool. The "set1" in the previous routine was one of my test case loadcase names that got left hard coded.
To output the extracted data to a file you need to start using file writing commands like the "text_" commands.
Text_open to open a file for writing to - this gives you a "channel" id number that you use to do" text_write..." type commands etc.
@Arthur Hickson Super!!. This "ajh_dump_loadcase2.pcl" version works fine and dumps all the LC Id's . one slight change required here. This coding dump all the load case. What if user want for only one Type of load case. For example pressure case having load type id 8. Is possible to extract only load type 8 cases along with the total count of only type 8 cases?
I am just going one step at a time. Hope you understand .