Weld_user_field_update: Among the available fields of each connection entity, there is one called ‘User’
which is editable only through scripting. This ‘User’ field can be updated only during the realization process and it’s usage can vary according to user needs. A very useful operation of this, is to display the property id for each plink that is created. First, we define in ANSA.defaults the name of the function that must be called just after realization:
# Custom function to update User field of a Connection # function format : string Function( element CONNECTION ); #
weld_user_field_update = #
A function name is assigned to this variable, eg: #
weld_user_field_update = UserPlinkProp #
This function should have the required syntax, i.e.
string Function (element connection)
and should return a string
The input argument of this function is the element (pointer) of the entity that is going to be created. Having this information it is easy to extract all necessary information. At the end of the script a string must be returned. A possible use of this function is to display in the ‘User’ field the property id of the newly created plinks:
def UserPlinkProp(element connection) {
for(ret = GetFirstFeRep(connection);ret;ret = GetNextFeRep(connection,ret)) { if(GetEntityType(PAMCRASH,ret)=="PLINK") { GetEntityCardValues(PAMCRASH,ret,"IPART",ipart); break; } } return ipart; }
thick_spw_diam: During the realization of many representations in connection manager (CBEAM,
CBAR) the diameter of a newly created entity is taken from a rule that is specified in ANSA.defaults as following:
# Flange Thickness to Spot Weld Diameter Map # format : d1 [,t1 ,d2 [,t2 ,d3 [,....]]]
# (where t : Thickness class upper bound # 0 < t(i) < t(i+1)
# i < 100
# d : Spot Weld Diameter for it )
thick_spw_diam = 4.00,1.02,5.00,1.78,6.00
In many case this rule is applied only when the option ‘Use Thickness to Diameter Map’ is activated. If the user requires a more complicated rule, then he can specify after ‘thick_spw_diam’ the name of a script function :
#
thick_spw_diam = AssignDiameter #
This function should have the syntax:
float Function(float thickness)
and should return a diameter
The input argument is a thickness value while the returned value is the diameter that will be applied:
def AssignDiameter(float thickness) {
if(thickness<=1) diameter = thickness;
else if(thickness>1 && thickness<2) diameter = thickness/4;
else if(thickness>=2 && thickness<3) diameter = thickness/2;
else
diameter = thickness*2; return diameter;
}
The thickness that is given as input is the one that calculated according to the ANSA.defaults variable ‘spw_diam_mflng’:
# Master Flange Election Method
# format : INNER|OUTER|MIDDLE|ALL,THINNEST|THICKEST|MEAN spw_diam_mflng = INNER , THINNEST
shell_to_spring_pid: The RADIOSS WELD is the only representation that can use the option ‘Use
thickness to PID Map’. If this option is activated, then ANSA during realization calls a function that is declared in ANSA.defaults under the variable ‘shell_to_spring_pid’.
# Projected shells to Radioss Spring PID mapping function # function format : element Function( matrix Shells ); # where you get a matrix of the projected shells,
# and you must return the property to be used by the # springs that will be created. This property can be # either created or selected by the properties list #
shell_to_spring_pid =
A function name is assigned to this variable eg: #
shell_to_spring_pid = DefineSpringId #
This function should have the syntax
element Function(matrix shells)
and should return the element (pointer) of a property.
The input argument is a matrix that contains the projected shells while the output must be the element of the property that is going to be assigned to the newly created radioss springs. The property is created into the function or it can be any existing one.
def DefineSpringId(matrix shells) {
len = MatLen(shells); i = 0;
foreach shell in shells { GetEntityCardValues(RADIOSS,shell,"PID",pid); prop = GetEntity(RADIOSS,"PROP/SHELL",pid); GetEntityCardValues(RADIOSS,prop,"THICK",t); thickness[i++] = Atof(t); } max = Max(thickness,len);Print(max); if(max<=1) ent = CreateEntityVa(RADIOSS,"PROP/SPR_BEAM",
"Name","Maximum thickness less than "+max, "PID",500","TYPE","SPR_BEAM 13","MASS",0.5); else
ent = CreateEntityVa(RADIOSS,"PROP/SPR_BEAM","Name","Maximum thickness greater than "+max, "PID",1000","TYPE","SPR_BEAM 13","MASS",1);
return ent; }
In the above example a different PROP/SPR_BEAM is assigned to each spring according to the thicknesses of the shells that connects.
post_realization_fn: If it is necessary to alter the results of some realized connections, after a successful
realization, the connection manager is able to call a user-script function, that will allow the user to make the required changes.
USAGE:
in the ANSA.defaults file, you can see the following variable: #
# User connection post realization function
# function format : int Function( entity Connection, # matrix XYZ_per_flange, # matrix ProjEnts_per_flange, # matrix heads_per_flange, # matrix bodies_per_flange_pair, # matrix miscellaneous ); # where :
# -"Connection" is the connection element that has just been realized
# -"XYZ_per_flange" is a matrix of the x,y,z coords of the projection on the flange # -"ProjEnts_per_flange" is a matrix of the entities at the projection
# -"heads_per_flange" is a matrix of the entities at head of the connection # -"bodies_per_flange_pair" is a matrix of the entities between the flanges # -"miscellaneous" is a matrix of miscellaneous information, # and information for future use, where
# "miscellaneous[0]" is diameter used during realization # return value: 0 if user made changes, connection will report as CUSTOM_FE # 1 if user made changes, connection will report in the usual manner #
# the post-realization function is called for each successfully realized connection, # for the user to make any custom changes on its elemens.
post_realization_fn =
A function name is assigned to this variable, eg: #
post_realization_fn = PostRealizationCallback #
This function should have the required syntax, i.e.
int Function( element Connection, matrix XYZ_per_flange, matrix ProjEnts_per_flange, matrix heads_per_flange, matrix bodies_per_flange_pair );
and user should return 1 on success of the application. Possible uses:
- users can modify diameters of bars according to their own scheme (like thickness to diameter mapping) - users can set the attributes of a Property of, say, a bar to their own values.
- users may delete/add more fe-representations to the connection
- users may produce a file output reporting on the quality of the produced elements/holes
Following is an example of how to extract the various information from a connection that has just been applied: def PostRealizationCallback( element cnctn, matrix XYZ, matrix ProjEnts, matrix heads, matrix bodies, matrix others ) {
GetEntityCardValues(NASTRAN, cnctn, "__id__", id ); // CONNECTION: Print( "Connection: " + id );
// PROJECTION COORDINATES ON EACH FLANGE: n = MatLen( XYZ );
for( i=0; i<n; i++ ) {
Print( "pt[" + i + "] = {" + XYZ[i][0] + ", " + XYZ[i][1] +
", " + XYZ[i][2] + "}" ); }
// PROJECTION ENTITIES ON EACH FLANGE: ( face/shell/node(s) ) n = MatLen( ProjEnts );
for( i=0; i<n; i++ ) {
Print( " Ent[" + i + "]:" ); nents = MatLen( ProjEnts[i] ); for( j=0; j<nents; j++ ) {
ent = ProjEnts[i][j];
GetEntityCardValues( NASTRAN, ent, "__id__", ID, "__type__", TYPE ); Print( "... id = "+ ID + "..."+TYPE );
} }
// INTERFACE ENTITIES PRODUCED BY CONNECTION MANAGER, ON EACH FLANGE: nHeads = MatLen(heads);
Print( nHeads + " HEADs:" ); for( i=0; i<nHeads; i++ ) {
Print( "-" +i + "> " ); nents = MatLen( heads[i] ); for( j=0; j<nents; j++ ) {
GetEntityCardValues(NASTRAN, heads[i][j], "__id__", ID, "__type__", TYPE );
Print( "... id = "+ ID + "..."+TYPE ); }
} }