Elements of a connector realization seem inconsistent from Python API

Alberto_Ingeniacity
Alberto_Ingeniacity Altair Community Member

I'm trying to access the elements of a realization from a script in Python. I'm using Hypermesh 2025. The realization is of a fastener (type Hole) with a head made of CBUSH and a body made of CBAR. The body is extended with two more CBAR elements (number of body extensions 1, Body Ext Config:CBAR).

In the GUI all goes well. I then want to modify and organize the created elements. To retrieve them I'm using a simple function:

import hm

import hm.entities as ent


def retrive_bolts():

    model = hm.Model()

    bolts = []

    # Select all connectors in the model.

    all_connectors = hm.Collection(model, ent.Connector)

    # Seach for those representing bolts and realized

    status, result = model.hm_ce_datalist(all_connectors)

    for connector in result:

        connector_object = connector['id']

        if connector['config'] == 'Hole' and connector['state'] == 'realized' and connector_object.ce_style == 'bolt':

            bolts.append(connector_object)

    return bolts

So far so good, I have a list of objects where each one is a connector of the type I want.

After searching, the only way that I found for retrieving the elements than have been realized for a certain connector is to do bolts[0].realization_weld_elems

That is where the weirdness starts. For some reason, the firs connector that gets realized is missing one of the beam elements. The rest is fine. It can be check with something as simple as len(bolts[0].realization_weld_elems). All realizations but the first one have the correct number of elements. In particular, the first one is missing one of the beams that extend the body.

I don't know where the error is coming from but it looks like a bug.

Anyone can help me with a workaround? If I can retrieve the elements some other way in a connector by connector fashion I'll be in the correct position.

thanks

Tagged:

Answers

  • Alberto_Ingeniacity
    Alberto_Ingeniacity Altair Community Member

    Going deeper into the problem I've found that the elements that are returned by the method realization_weld_elems of a connector object does not match the id numbers of the elements realized for that connector at all. In fact, it mixes elements from other connectors. Either I'm not understanding what is supposed to be returned by realization_weld_elems, or there is a bug in that function. If one compares those ids with the ones that are found in the GUI by looking for the references to a connector it shows clearly.

Welcome!

It looks like you're new here. Sign in or register to get started.

Welcome!

It looks like you're new here. Sign in or register to get started.