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
  • 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 
  • Hello! I would like to continue the thread. Where can I find list of "prop_words"? I would like to extract: mass, I11, I22 and I33 also.
  • Hi Adam,
    I'm afraid it is reverse engineer them.
    for this example I started by getting the props and and then dumping out the prop words and their values to identify the prop word that corresponded to the data I had input in the gui. Having identified it as 4001 I then changed the code to work just that one word. With hindsight I should have kept the loops to anticipate this question, I'll put it together again for you(but it wont be immediate) unless you get there first.
     
  • Here is a function to dump all the prop words for created property regions.
    Hopefully this will enable you to work out which prop word you need.
    best regards
    Arthur

    Attached Files (1)
  • Hi Adam,
    I can't seem to see your reply on this thread (on word_id = 2069) though I was emailed it.
     
    in response to it have a look at this to get the mass data that you required.:
     
    INTEGER status, word_id, word_component, @
        search_element_count, search_element_id(1), @
        found_element_count, found_element_id(VIRTUAL), i_elem
    REAL found_element_value(VIRTUAL)
     
    word_id = 2069
    word_component = 1
    search_element_count = -1
    status = ep_word_val_at_el_cen(word_id, word_component, @
          search_element_count, search_element_id, @
          found_element_count, found_element_id, @
          found_element_value)
    IF (0 < status) THEN
      msg_to_form(status, 4, 0, 0, 0.0, "")
    ELSE
      IF (0 > status) THEN
    $ Error information already displayed 
      ELSE
       write_line("found_element_count =", found_element_count)
       FOR (i_elem = 1 TO found_element_count)
         write_line("found_element_id(", i_elem, ") =", @
              found_element_id(i_elem))
         write_line("found_element_value(", i_elem, ") =", @
              found_element_value(i_elem))
       END FOR
      END IF
    END IF  
  • Hi! Thank you for the code. I deleted post because I have found a workaround. It is not as elegant as your solution.
     
    FUNCTION get_field_val(field_id, eid)
    INTEGER field_id, eid
    INTEGER ia_method(VIRTUAL)
    INTEGER ia_eid(VIRTUAL)
    INTEGER ia_elem_face(VIRTUAL)
    INTEGER ia_elem_edge(VIRTUAL)
    INTEGER ia_node_pos(VIRTUAL)
    INTEGER ia_nodeid(VIRTUAL)
    REAL   ra_vals(VIRTUAL)
    INTEGER offset_idx 
    INTEGER geom_id, extrap_opt, data_type1, coord_id1, field_type
    INTEGER num_vars, var_type_1, var_type_2, var_type_3, func_1_size
    INTEGER func_2_size, func_3_size, num_var_1, num_var_2, num_var_3
    LOGICAL lin_def
    STRING field_name[31]
    INTEGER field_dim, geom_type, field_var
    db_get_field(field_id, field_name, field_var, field_dim, geom_type,@
    geom_id, extrap_opt, data_type1, coord_id1, field_type, @
    num_vars, var_type_1, var_type_2, var_type_3, func_1_size, @
    func_2_size, func_3_size, lin_def, num_var_1, num_var_2, num_var_3)
    SYS_ALLOCATE_ARRAY(ia_method,1,num_vars)
    SYS_ALLOCATE_ARRAY(ia_eid,1,num_vars)
    SYS_ALLOCATE_ARRAY(ia_elem_face,1,num_vars)
    SYS_ALLOCATE_ARRAY(ia_elem_edge,1,num_vars)
    SYS_ALLOCATE_ARRAY(ia_node_pos,1,num_vars)
    SYS_ALLOCATE_ARRAY(ia_nodeid,1,num_vars)
    SYS_ALLOCATE_ARRAY(ra_vals,1,num_vars)
    db_get_field_dfem                   @
          (field_id,                       @
          num_vars,                       @
          ia_method,                       @
          ia_eid,                        @
          ia_elem_face,                     @
          ia_elem_edge,                     @
          ia_node_pos,                      @
          ia_nodeid,                       @
          ra_vals )
    offset_idx=mth_array_search(ia_eid, eid, TRUE)
    RETURN ra_vals(offset_idx)
    END FUNCTION