cancel
Showing results for 
Search instead for 
Did you mean: 

Accessing CAE Groups of the FEM in the SIM

I have a CAE Group that is defined in the FEM part.

 

I want to reference that group in the SIM part to add loads based on that group. Interactively, the group is shown in the Groups, no problem.

 

If I journal the operation, I get code using FindObject, which is not recommended for scripting as per the reference document.

 

I can build something along the lines of

 

    def getGroup(name):
        for i in range(1, 10):
            try:
                femocc = workPart.FindObject("FEModelOccurrence[{}]".format(i))
                grp = femocc.FindObject("CaeGroup[{}]".format(name))
                return grp
            except:
                pass
        lwException("CAE Group not found: {}".format(name))

That works as intended. But there must be a cleaner and more robust way of doing that.

 

I can get FEModelOccurences for the correct prototypes by using

workPart.FemPart.BaseFEModel.GetChildren()

but these have different addresses and don't have the groups in them. 

 

If I use the groups from the prototypes, I get an error.

 

Does anyone know why there are different occurrences, and how to get the correct ones? Also, a clean way to get the CaeGroups out of the FEModelOccurrence would be nice.

 

Or is that the completely wrong way for this? After all, the documentation of FEModelOccurrence states

 

        An instance of this class can not be obtained

 

Thanks a lot!

11 REPLIES

Re: Accessing CAE Groups of the FEM in the SIM

Siemens Phenom Siemens Phenom
Siemens Phenom

If you get the groups for the SimPart (via SimPart.CaeGroups), occurrances of groups from the FemPart will be included.

 

In general, for code working with groups, cast the part to CaePart and get the groups for that (CaePart.CaeGroups). Your code will then work the same for FEM, SIM and AFEM parts.

Re: Accessing CAE Groups of the FEM in the SIM

Thanks a lot Jim! That put me on the right track.

 

Seems like a very weird implementation in the Python version.

 

If I use the builtin iterator for the CaeGroupCollection (as I tried before)

 

for g in workPart.CaeGroups:

    .....

 

the groups from the FEM are not there.

 

If I use the list from

 

workPart.CaeGroups.QueryGroupList()

 

and go through that, they are there.

 

No idea how it is in the other languages, but this does not seem like intended behaviour.

 

Re: Accessing CAE Groups of the FEM in the SIM

Addendum:

The error only occurs when there is an assembly fem in between the fem and sim. If I add the fem directly to the sim, it works with the iterator.

Re: Accessing CAE Groups of the FEM in the SIM

Phenom
Phenom

I noticed the behaviour described by NikolasGoldin.

 

Is there then a way of getting all the groups regardless of the type of .fem or .afm attached to the .sim?

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Accessing CAE Groups of the FEM in the SIM

Yes, you can use the List from

 

workPart.CaeGroups.QueryGroupList()

 

that works in my case (NX 10.0.3.5, Python), no matter if it is from a fem or afm.

Re: Accessing CAE Groups of the FEM in the SIM

Phenom
Phenom

Thanks. I have been using

Dim aTheCAEGroups() As CAE.CaeGroup
aTheCAEGroups = theCAEPart.CaeGroups.ToArray()

 

where the variable 'theCAEPart' is cast at the beginning of the program.

This has the advantage of returning an array of variable type CAE.Caegroup

 

Will investigate the use of the QueryList in my spare time

 

Thanks

Regards

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)

Re: Accessing CAE Groups of the FEM in the SIM

Siemens Phenom Siemens Phenom
Siemens Phenom

@NikolasGoldin,

 

This is not a "wierd Python implementation" - the behavior is consistent across all languages.

 

The CaeGroupCollection (caePart.CaeGroups) will return the groups in the sim part and those from the immediate parent of the sim part. For a single component scenario (.prt - .fem - .sim), the CaeGroupCollection in the SimPart will include the CaeGroups from the FEM and the SIM. When Assembly FEM is added (.prt - .fem - .afm - .sim), the CaeGroupCollection in the SimPart will include the CaeGroups from the AFM and the SIM only.

 

caePart.CaeGroups.QueryGroupList() will return all groups in the .sim as well as all groups in the assembly fem hirearchy. This will match the list of groups that you see in the Simulation Navigator.

Re: Accessing CAE Groups of the FEM in the SIM

Siemens Phenom Siemens Phenom
Siemens Phenom

Forgot to include this example in the previous reply

 

caePart = theSession.Parts.BaseWork

theLw.Open()

theLw.WriteLine("CAE Group Collection:")
for caeGroup in caePart.CaeGroups:
    theLw.WriteLine("Group Name: " + caeGroup.Name)
    if caeGroup.IsOccurrence:
        theLw.WriteLine("  Prototype: " + caeGroup.Prototype.OwningPart.Name)

theLw.WriteLine("")
theLw.WriteLine("Query Group List:")

groupTo = caePart.CaeGroups.QueryGroupList()

for caeGroup in groupTo:
    theLw.WriteLine("Group Name: " + caeGroup.Name)
    if caeGroup.IsOccurrence:
        theLw.WriteLine("  Prototype: " + caeGroup.Prototype.OwningPart.Name)

Re: Accessing CAE Groups of the FEM in the SIM

Phenom
Phenom
forgive my ignorance JimB but in which programming language are these line coded?
I see things like
if caeGroup.IsOccurrence:

no Then .. End if
Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)