Showing results for 
Search instead for 
Do you mean 
Reply
Solved! Go to solution

How to write all constituent files of an .afm to a text file or Excel?

To all

 

consider a .afm which is made of .fem, etc

.afm

  .fem1

    .i1.prt

      .prt

  .fem2

    .i2.prt

      .prt

repeat

 

Is there a way of "exporting" this "BOM" to either a text file/listing window or even better "excel"

I think what I am trying to understand is how to "walk" through tthe hierachy. Once this is understoed then It should be easy to output the data as one will most likely "collect" the data during the walk through. I suspect the work flow look like that

 

For each ComponentAssembly

  get Name

    get name of the ipart

       get name of the part

 Next component

 

I suspect there will be a brach if the ComponentAssembly is an .afm or a .fem

 

Thanks

Regards

 

 

Production: NX9.0.3.4, NX10.0.2.6
Development: VB.NET (amateur level !)
7 REPLIES
Solution
Solution
Accepted by topic author selex_ct
‎06-27-2017 05:42 AM

Re: How to write all constituent files of an .afm to a text file or Excel?

This will output the hierarchy to the listing window.

Re: How to write all constituent files of an .afm to a text file or Excel?

[ Edited ]

Thanks a lot for that. Just what I was looking for.

 

Didn't know about a function being able to call itself! May have read about it though

 

I'll need to have a look at the detail because the code does not return the names of the MasterCadPart & IdealizedPart- only the .fem. It also "crashes" on the the CAE.AssyFemPart call eventhough the test .afm I have only contains .fem, ipart, part

 

Thanks

Regards

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

Re: How to write all constituent files of an .afm to a text file or Excel?

That's strange. Could you share the details of the crash.

 

I've tried it on a couple of different small assemblies and it seems to handle everything (loaded/unloaded parts; no cad part; cad part only; cad part + ideal part)

 

No CAD parts loaded:

Root Component: assembly1_afm_s

  Component: assembly1_afm
  Master cad part not loaded

    Component: component2_f
    Master cad part not loaded

    Component: component1_f
    Master cad part not loaded

Cad parts loaded manually or forceLoadCadParts=True (line 28):

Root Component: assembly1_afm_s

  Component: assembly1_afm
  Master cad part: assembly1

    Component: component2_f
    Master cad part: component2
    Idealized part: component2_f_i

    Component: component1_f
    Master cad part: component1
    No Idealized part associated to this FEM part

Re: How to write all constituent files of an .afm to a text file or Excel?

run the offered code from an .afm which contains quite a few .fem (ipart & part) and .afm and I get the attached error.

 

If I exclude the call to function getCadPartNamesForAssyFem(), I get all the .fem but no Master cad part & Idealized part. I can see the lines where the code returns : No Idealized part associated to this FEM part.

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

Re: How to write all constituent files of an .afm to a text file or Excel?

[ Edited ]

If I change

femPart.MasterCadPart.Name

to

 

femPart.MasterCadPart.Leaf

then I get the name (no extension)

 

Also tested

femPart.MasterCadPart.FullPath

and one does get the the full path. For some reason the .Name returns a blank/empty string

 

As I work my way throuhg the kindly supplied code, I have noticed that repeated .fem are handled differently. Only the name of the.fem i.e. the component.displayname is listed the master cad and idealised part are skipped

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

Re: How to write all constituent files of an .afm to a text file or Excel?

In NX 11, the .Name property seems to default to the same value as the .Leaf property; in NX 10 and earlier it does not. See the following thread for another example:

https://community.plm.automation.siemens.com/t5/NX-Programming-Customization-Forum/Bodies-in-assembl...

Re: How to write all constituent files of an .afm to a text file or Excel?

Thanks for the link. I am testing in NX10

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