Export bodies one by one to catia, and at all assembly levels

Hello, I have been reading codes from this page for a month, but I can not achieve what I need to do for my job:

I need to extract, one by one, into Catia V5 files, each of the bodies of an assembly, and recursively of its children, with the condition that each Catia file has only one body.

Anybody can help me please?

Thank you very much

I'd suggest that you start by recording a simple journal. Open a small assembly, start the journal recorder, and export one body to a Catia file. If the journal recorder returns useful code, we can incorporate it into the journal that processes an assembly:
http://nxjournaling.com/content/creating-subroutine-process-all-componen...

I tried to join the journal for export parasolids and this one of explororing an assembly, and made the journal of exporting Catia to see the classes used.
But I was unable to join all together since dont know visual basic enough.

The most I can do is put fragments of code that make things, but I dont know how to make the "For all children"-"Select each body one by one"-"export it to catia file".

I will keep trying

Thanks

Can you post the code that was returned for exporting a body to a Catia file?

I don't have a license for exporting to Catia, so I'm unsure what code is required. If you post your code, I might be able to help combine it into a journal that processes the assembly.

Ok, I have made the Journal just for select a body and export it to catia V5 (File/Export/CatiaV5).

I can recognize:
- The usual start of any module (Strict Off, Imports system...)
- The variables definition (Dim) and the class used to export to Catia (Catiav5Creator), with its Methods, that I dont have the list.
- The folder definition, that I would like to ask the user, or make general enough to be used in any computer.
- An Undo set of lines that I can erase (UndoMarkId).
- And the "stuck selection" of the object that I would need to correct as you expolain in one of the first tutorials, to select, recursively one by one each solids in the tree, and for every subassembly recursively, and one by one again export each to a catiav5 file.

Note: it is a drawback not to have the list of classes and its methods (options) to know what can be done (and honestly I have to study some standard visual basic structures because need some more background to write the code structures, just started with this a weeks ago and I am not a programmer).

Thank you very much in advance for any help.

this is the code:

' NX 7.5.5.4
' Journal created by garcijos on Fri Oct 09 09:30:03 2015 GMT Daylight Time
'
Option Strict Off
Imports System
Imports NXOpen

Module NXJournal
Sub Main

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work

Dim displayPart As Part = theSession.Parts.Display

' ----------------------------------------------
' Menu: File->Export->CATIA V5...
' ----------------------------------------------
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "Start")

Dim catiav5Creator1 As Catiav5Creator
catiav5Creator1 = theSession.DexManager.CreateCatiav5Creator()

catiav5Creator1.ExportSelectionBlock.SelectionScope = ObjectSelector.Scope.SelectedObjects

catiav5Creator1.OutputFile = "C:\Users\GarciJos\Desktop\NX journals\Padre1.catpart"

catiav5Creator1.SettingsFile = "C:\apps\nx075\catiav5\catiav5.def"

catiav5Creator1.IncludeIndWireFrame = True

catiav5Creator1.EnableHybridDesign = False

catiav5Creator1.SettingsFile = "C:\apps\nx075\catiav5\catiav5.def"

catiav5Creator1.OutputFile = "C:\Users\GarciJos\Desktop\NX journals\Padre1.catpart"

theSession.SetUndoMarkName(markId1, "Export to CATIA V5 Options Dialog")

Dim body1 As Body = CType(workPart.Bodies.FindObject("BLOCK(0)"), Body)

Dim added1 As Boolean
added1 = catiav5Creator1.ExportSelectionBlock.SelectionComp.Add(body1)

catiav5Creator1.OutputFile = "C:\Users\GarciJos\Desktop\NX journals\Padre1.CATPart"

Dim markId2 As Session.UndoMarkId
markId2 = theSession.SetUndoMark(Session.MarkVisibility.Invisible, "Export to CATIA V5 Options")

catiav5Creator1.FileSaveFlag = False

Dim nXObject1 As NXObject
nXObject1 = catiav5Creator1.Commit()

workPart = theSession.Parts.Work
displayPart = theSession.Parts.Display
theSession.DeleteUndoMark(markId2, Nothing)

catiav5Creator1.Destroy()

' ----------------------------------------------
' Menu: Tools->Journal->Stop Recording
' ----------------------------------------------

End Sub
End Module

In one of your posts you mention that "each Catia file has one body". Does this mean that the NX file only has a single solid body in it that you want to export to Catia? or perhaps the NX file has multiple solid bodies and each should be exported to its own Catia file? Should the output file be named similarly to the NX file? {12345.prt => 12345.catpart}

Hello, each part has múltiple bodies, but I must have only one body per catia file. So I wanted to go through each assembly, including the root one, and for each body extract a Catia file.
My ideal would be to make it only for the displayed bodies, so I could hide things I didn't want to export.
The name is not very important but it would be great to be able to define a secuence, like "myinitials"+0001, "myinitials"+0002 etc...
So people can identify their exportings.

How can I get information to assemble the parts of the code together?

Thank you very much

Hello, I have taken two little steps ahead in my investigation on programming NX, the second of them I think is interesting:

1. I installed Microsoft Visual Studio (the free Community option).
2. I managed to add the NX Classes to a project, so now I have the list of them in front of me.

I made this following this instructions I found in a forum:

From: http://www.eng-tips.com/viewthread.cfm?qid=364048

1) Launch Visual Studio
2) Go to Menu File->New->Project
3) Select Windows Form Application Project in window.( Specify Project Name and Location)
4) Click Ok
5) Now you a pre created structure in Solution Explorer with Form1.cs, References, Properties, Program.cs items.

Linking the NX Libraries with Windows Form Project:
--------------------------------------------------

1) Right click on the References folder in Solution Explorer and click "Add References"
2) Now Go to Browse tab and browse for below libraries.
\UII\managed\NXOpen.dll
\UII\managed\NXOpen.UF.dll
\UII\managed\NXOpen.Utilities.dll
\UII\managed\NXOpenUI.dll
3) Select the above mentioned libraries and Click ok.
4) Add resource file as mentioned by "gelsonnicoletto"
5) Now Add the NX library namespace in Form1.cs file. ( Like "using NXOpen;" "using NXOpen.UF;")
6) Add your customization code, Build and execute in NX.

Now I just have to learn visual basic..... :-))))) Any help is very welcomed

Regards!