Submitted by jlandren on Mon, 07/11/2016 - 10:20
Forums:
Hello all,
new to the forum, trying to alleviate the pains of a repetitive task
I want to convert imported bodies into parts. right now the only way to do it is to:
In the part navigator -
+ select the part
+ Assemblies > Components > Create New Component...
+ In the "Model" tab, under "Name and Attributes" double click on one of the red asterisks
+ Assign a unique name
+ Hit OK
+ Hit OK again in the window "Create New Component" that pops up
for a couple parts it's not too bad, but when an assembly has 1000+ parts it takes forever and can be error prone
any thoughts?
thanks!
-J
re: convert bodies to parts
Depending on the file format and the export options used at the time of export, you may already have the assembly structure. Both parasolid and STEP files have the ability to maintain the assembly structure (I'm not sure about IGES). If you are dealing with a parasolid file, try opening the file directly (file -> open, change file type to parasolid). If it is a STEP file, make sure that the "flatten assembly" option is turned off on the import dialog.
Of course, it is also possible that whoever exported the file flattened the assembly structure upon export. If that is the case, then your current workflow of exporting the bodies into new components is one of the best options. This workflow can be automated, but you will need to devise/provide a scheme for naming the newly created files. Also, you will need to decide where you want the new files saved.
Thanks for the reply - I had
Thanks for the reply - I had read that as being an option, but (I think due to my permissions) I am unable to view or open a local file. The recorded journaling gets most of the way there, but gets hung up at a couple steps
In the meantime, I'll keep digging to see what I have to do to open exported files. Thanks again for the help!
re: convert bodies to parts
If you are having issues with the journal code, you can post what you have along with a description of the issue and I will try to help.
this is the snippet of code
this is the snippet of code it gets hung-up on:
Dim body1 As NXOpen.Body = CType(workPart.Bodies.FindObject("UNPARAMETERIZED_FEATURE(2)"), NXOpen.Body)
Dim added1 As Boolean
added1 = createNewComponentBuilder1.ObjectForNewComponent.Add(body1)
when I comment it out, the journal script does pretty much everything I was hoping it would do (create a new component in the assembly with a unique ID), with the exception of bringing in the selected body as a solid within the component
re: get bodies
Your current code is trying to convert a feature to a body, which won't work (at least not directly). You can access all of the bodies in the part file through the .Bodies collection. Alternately, if you have a reference to a feature, you can use the feature's .GetEntities (or, if it is a BodyFeature type, the .GetBodies) method of the feature.
The code below shows how to iterate through the .Bodies collection of the work part:
For Each tempBody As Body In workPart.Bodies
If tempBody.IsSolidBody Then
'code to export solid body to new part file
Else
'code to process a sheet body
End If
Next