hexagon logo

Material ID for an element

Hi,
​I have element ID and I need to get the property set ID and its material ID defined in the property.   db_element function returns part ID and its not matching with BDF file. Please suggest to get the material ID for an element.
Parents
  • Comment on coding for performance.
     
    When working with PCL there is a relatively large CPU hit for every database transaction that you do, so you should seek to minimise the number of "db_..." calls that you make.
    When coding PCL it can be very tempting to count the number of elements, nodes etc and then do a FOR loop for 1 to number_of_elements (nodes etc) and within this loop get from the database the information you seek for a single element. This works fine for test models but in real life the loop that is calling db transactions for every item can be slow. (or even very slow)
     
    To minimise the performance impact of the db transactions most db_ routines allow you to get the information for arrays of ids in one go.
     
    In the attached example I have tried to illustrate this, the function retrieves the material names for an array of element ids . The number of db calls has been minimised. There is one "FOR" loop over all elements, this could possibly be improved by use of a 2d array and a sort..., but it is sufficient to demonstrate the basics of using arrays of ids to minimise db transactions within loops.
     
    Like most coding the first task is to make it work with a prototype, then you start to look at performance if it is actually an issue..
     
    best regards
    Arthur
     

    Attached Files (1)
Reply
  • Comment on coding for performance.
     
    When working with PCL there is a relatively large CPU hit for every database transaction that you do, so you should seek to minimise the number of "db_..." calls that you make.
    When coding PCL it can be very tempting to count the number of elements, nodes etc and then do a FOR loop for 1 to number_of_elements (nodes etc) and within this loop get from the database the information you seek for a single element. This works fine for test models but in real life the loop that is calling db transactions for every item can be slow. (or even very slow)
     
    To minimise the performance impact of the db transactions most db_ routines allow you to get the information for arrays of ids in one go.
     
    In the attached example I have tried to illustrate this, the function retrieves the material names for an array of element ids . The number of db calls has been minimised. There is one "FOR" loop over all elements, this could possibly be improved by use of a 2d array and a sort..., but it is sufficient to demonstrate the basics of using arrays of ids to minimise db transactions within loops.
     
    Like most coding the first task is to make it work with a prototype, then you start to look at performance if it is actually an issue..
     
    best regards
    Arthur
     

    Attached Files (1)
Children
No Data