hexagon logo

PCL; how to get reference csys id (CID) for CONM2 element?

Hello!
I created a group with CONM2 elements. I would like to printout CID for each EID. I cannot figure out how to go from region ID to specific property field.
 
This is piece of code I have:
 
db_get_current_group_id(group_id)
db_get_group_name( group_id,s_name )
   db_count_elems_in_group(group_id, num_elems)
SYS_ALLOCATE_ARRAY(elem_ids, 1, num_elems)
db_get_elem_ids_in_group(num_elems, group_id, elem_ids)
 
FOR (i=1 to num_elems)
eid(1) = elem_ids(i)
db_get_region_for_elements(1, eid, region_ids)
###get_CID
dump str_from_integer(eid(1)) // " - " // ###CID
 
END FOR 
 
Regards,
Adam
Parents
  • I think you want something that is like this:
    note I shifted the db_get_region_for_elements outside the num_elems for loop for efficiency reason, minimise the number of db calls. I wanted to reduce the element_region_ids to the unique ones to minimise the db_get_prop_value calls but nothing sprang to mind on how to then efficiently expand it back for each element, so I couldn't see anything to gain by doing this.
    I haven't run this as it stands so there may be some errors in it.
     
     
    db_get_current_group_id(group_id)
    db_get_group_name( group_id,s_name )
      db_count_elems_in_group(group_id, num_elems)
      if (num_elems == 0) then return (-1)
    SYS_ALLOCATE_ARRAY(elem_ids, 1, num_elems)
    db_get_elem_ids_in_group(num_elems, group_id, elem_ids)
     
      integer element_region_ids(virtual)
      sys_allocate_array(element_region_ids, 1, num_elems)
     
      db_get_region_for_elements(num_elems, elem_ids, element_region_ids)
     
      INTEGER material_id, data_type, integer_val
      REAL real_vals(3)
      STRING character_val[31]
      INTEGER coord_id, node_id, field_id
      integer prop_word=4001
      integer previd = 0
    coord_id = 0
    FOR (i=1 to num_elems)
    if (element_region_ids(i) != previd) then
        db_get_prop_value( element_region_ids(i), prop_word, @
                 material_id, data_type, integer_val, real_vals, @
                 character_val, coord_id, node_id, field_id )
    end if
     
    dump str_from_integer(elem_ids(i)) // " - " // str_from_integer(coord_id)
     
    END FOR 
Reply
  • I think you want something that is like this:
    note I shifted the db_get_region_for_elements outside the num_elems for loop for efficiency reason, minimise the number of db calls. I wanted to reduce the element_region_ids to the unique ones to minimise the db_get_prop_value calls but nothing sprang to mind on how to then efficiently expand it back for each element, so I couldn't see anything to gain by doing this.
    I haven't run this as it stands so there may be some errors in it.
     
     
    db_get_current_group_id(group_id)
    db_get_group_name( group_id,s_name )
      db_count_elems_in_group(group_id, num_elems)
      if (num_elems == 0) then return (-1)
    SYS_ALLOCATE_ARRAY(elem_ids, 1, num_elems)
    db_get_elem_ids_in_group(num_elems, group_id, elem_ids)
     
      integer element_region_ids(virtual)
      sys_allocate_array(element_region_ids, 1, num_elems)
     
      db_get_region_for_elements(num_elems, elem_ids, element_region_ids)
     
      INTEGER material_id, data_type, integer_val
      REAL real_vals(3)
      STRING character_val[31]
      INTEGER coord_id, node_id, field_id
      integer prop_word=4001
      integer previd = 0
    coord_id = 0
    FOR (i=1 to num_elems)
    if (element_region_ids(i) != previd) then
        db_get_prop_value( element_region_ids(i), prop_word, @
                 material_id, data_type, integer_val, real_vals, @
                 character_val, coord_id, node_id, field_id )
    end if
     
    dump str_from_integer(elem_ids(i)) // " - " // str_from_integer(coord_id)
     
    END FOR 
Children
No Data