Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

  • Congratulations IDS on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

NX 7.5 - Export assembly BOM with part COG's

Status
Not open for further replies.

MrLLH

Mechanical
Oct 31, 2012
3
Hi there. I am trying to get a report (that I can put into excel) of all the parts in an assembly and each parts' mass and Centre of Gravity position in relation to the Assembly UCS. I have no problem getting a report with mass (>Information>Assemblies>List Components), but I can't seem to get it to include the CofG in the list. Alternatively, if I could add the x, y & z CofG positions to the columns in the assembly navigator, I could export this to spreadsheet, but have been unable to find a way to do so.

Any help you could provide would be appreciated.

Thanks
 
Replies continue below

Recommended for you

This is something which would be better addressed with a simple NX Open program.

John R. Baker, P.E.
Product 'Evangelist'
Product Engineering Software
Siemens PLM Software Inc.
Industry Sector
Cypress, CA
Siemens PLM:
UG/NX Museum:

To an Engineer, the glass is twice as big as it needs to be.
 
Here is a small journal that will allow you to select a component and will assign COG_X, COG_Y, and COG_Z attributes to the component (relative to the WCS of the assembly). You can add these attributes to your assembly navigator to allow export to a spreadsheet.

A couple of warnings:
[ol 1]
[li]The measurements are not associative. When the part or its position within the assembly changes, you'll have to rerun the journal.[/li]
[li]The output units are pounds inches; this can easily be changed in the journal.[/li]
[li]COG coordinates are reported relative to the assembly's current WCS.[/li]
[li]The journal is a starting point, it currently has no error checking.[/li]
[/ol]


Code:
[COLOR=blue]Option[/color] [COLOR=blue]Strict[/color] [COLOR=blue]Off[/color]  
[COLOR=blue]Imports[/color] System  
[COLOR=blue]Imports[/color] NXOpen  
[COLOR=blue]Imports[/color] NXOpen.UF  

[COLOR=blue]Module[/color] Module1  

    [COLOR=blue]Dim[/color] theSession [COLOR=blue]As[/color] Session [COLOR=blue]=[/color] Session.GetSession()  
    [COLOR=blue]Dim[/color] ufs [COLOR=blue]As[/color] UFSession [COLOR=blue]=[/color] UFSession.GetUFSession()  
    [COLOR=blue]Dim[/color] workPart [COLOR=blue]As[/color] Part [COLOR=blue]=[/color] theSession.Parts.Work  
    [COLOR=blue]Dim[/color] selObj [COLOR=blue]As[/color] NXObject [COLOR=blue]=[/color] [COLOR=blue]Nothing[/color]  

    [COLOR=blue]Enum[/color] AnalysisType [COLOR=blue]As[/color] [COLOR=blue]Integer[/color]  
        solidBody [COLOR=blue]=[/color] 1  
        thinShellSheetBody [COLOR=blue]=[/color] 2  
        boundedBySheetBodies [COLOR=blue]=[/color] 3  
    End [COLOR=blue]Enum[/color]  

    [COLOR=blue]Enum[/color] AnalysisUnits [COLOR=blue]As[/color] [COLOR=blue]Integer[/color]  
        poundsInches [COLOR=blue]=[/color] 1  
        poundsFeet [COLOR=blue]=[/color] 2  
        gramsCm [COLOR=blue]=[/color] 3  
        kilogramMeter [COLOR=blue]=[/color] 4  
    End [COLOR=blue]Enum[/color]  

    [COLOR=blue]Enum[/color] AnalysisAccuracy [COLOR=blue]As[/color] [COLOR=blue]Integer[/color]  
        useAccuracy [COLOR=blue]=[/color] 1  
        useRelativeTolerance [COLOR=blue]=[/color] 2  
    End [COLOR=blue]Enum[/color]  

    [COLOR=blue]Sub[/color] Main()  

        [COLOR=blue]Dim[/color] dblAcc_Value(11) [COLOR=blue]As[/color] [COLOR=blue]Double[/color]  
        [COLOR=blue]Dim[/color] dblMass_Props(46) [COLOR=blue]As[/color] [COLOR=blue]Double[/color]  
        [COLOR=blue]Dim[/color] dblStats(12) [COLOR=blue]As[/color] [COLOR=blue]Double[/color]  
        [COLOR=blue]Dim[/color] strOutput [COLOR=blue]As[/color] [COLOR=blue]String[/color] [COLOR=blue]=[/color] ""  

        [COLOR=blue]If[/color] SelectAComponent("Select a component", selObj) [COLOR=blue]=[/color] Selection.Response.Cancel [COLOR=blue]Then[/color]  
            [COLOR=blue]Exit[/color] [COLOR=blue]Sub[/color]  
        End [COLOR=blue]If[/color]  

        [COLOR=blue]Dim[/color] tagList(0) [COLOR=blue]As[/color] NXOpen.Tag  
        tagList(0) [COLOR=blue]=[/color] selObj.Tag  
        dblAcc_Value(0) [COLOR=blue]=[/color] 0.99  

        ufs.Modl.AskMassProps3d(tagList, 1, AnalysisType.solidBody, AnalysisUnits.poundsInches, 0.0375, AnalysisAccuracy.useAccuracy, dblAcc_Value, dblMass_Props, dblStats)  

 [COLOR=green]'strOutput = "Surface Area: " & dblMass_Props(0) & vbCrLf[/color]
 [COLOR=green]'strOutput = strOutput & "Volume: " & dblMass_Props(1) & vbCrLf[/color]
 [COLOR=green]'strOutput = strOutput & "Mass: " & dblMass_Props(2) & vbCrLf[/color]
 [COLOR=green]'strOutput = strOutput & "COG: " & dblMass_Props(3) & ", " & dblMass_Props(4) & ", " & dblMass_Props(5) & vbCrLf[/color]
 [COLOR=green]'strOutput = strOutput & "Density: " & dblMass_Props(46)[/color]
 [COLOR=green]'MsgBox(strOutput, vbOKOnly)[/color]

        selObj.OwningComponent.SetAttribute("COG_X", dblMass_Props(3))  
        selObj.OwningComponent.SetAttribute("COG_Y", dblMass_Props(4))  
        selObj.OwningComponent.SetAttribute("COG_Z", dblMass_Props(5))  

    End [COLOR=blue]Sub[/color]  

    [COLOR=blue]Function[/color] SelectAComponent(ByVal prompt [COLOR=blue]As[/color] String, [COLOR=blue]ByRef[/color] selObj [COLOR=blue]As[/color] NXObject) [COLOR=blue]As[/color] Selection.Response  

        [COLOR=blue]Dim[/color] theUI [COLOR=blue]As[/color] UI [COLOR=blue]=[/color] UI.GetUI  
        [COLOR=blue]Dim[/color] title [COLOR=blue]As[/color] [COLOR=blue]String[/color] [COLOR=blue]=[/color] "Select a component"  
        [COLOR=blue]Dim[/color] includeFeatures [COLOR=blue]As[/color] [COLOR=blue]Boolean[/color] [COLOR=blue]=[/color] [COLOR=blue]False[/color]  
        [COLOR=blue]Dim[/color] keepHighlighted [COLOR=blue]As[/color] [COLOR=blue]Boolean[/color] [COLOR=blue]=[/color] [COLOR=blue]False[/color]  
        [COLOR=blue]Dim[/color] selAction [COLOR=blue]As[/color] Selection.SelectionAction [COLOR=blue]=[/color] Selection.SelectionAction.ClearAndEnableSpecific  
        [COLOR=blue]Dim[/color] cursor [COLOR=blue]As[/color] Point3d  
        [COLOR=blue]Dim[/color] scope [COLOR=blue]As[/color] Selection.SelectionScope [COLOR=blue]=[/color] Selection.SelectionScope.AnyInAssembly  
        [COLOR=blue]Dim[/color] selectionMask_array(0) [COLOR=blue]As[/color] Selection.MaskTriple  

        [COLOR=blue]With[/color] selectionMask_array(0)  
            .Type [COLOR=blue]=[/color] UFConstants.UF_solid_type  
            .SolidBodySubtype [COLOR=blue]=[/color] UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY  
        End [COLOR=blue]With[/color]  

        [COLOR=blue]Dim[/color] resp [COLOR=blue]As[/color] Selection.Response [COLOR=blue]=[/color] theUI.SelectionManager.SelectObject(prompt, title, scope, selAction, includeFeatures, keepHighlighted, selectionMask_array, selObj, cursor)  
        [COLOR=blue]If[/color] resp [COLOR=blue]=[/color] Selection.Response.ObjectSelected [COLOR=blue]OrElse[/color] resp [COLOR=blue]=[/color] Selection.Response.ObjectSelectedByName [COLOR=blue]Then[/color]  
            [COLOR=blue]Return[/color] Selection.Response.Ok  
        [COLOR=blue]Else[/color]  
            [COLOR=blue]Return[/color] Selection.Response.Cancel  
        End [COLOR=blue]If[/color]  

    End [COLOR=blue]Function[/color]  


    [COLOR=blue]Public[/color] [COLOR=blue]Function[/color] GetUnloadOption(ByVal dummy [COLOR=blue]As[/color] [COLOR=blue]String[/color]) [COLOR=blue]As[/color] [COLOR=blue]Integer[/color]  

 [COLOR=green]'Unloads the image when the NX session terminates[/color]
        GetUnloadOption [COLOR=blue]=[/color] NXOpen.Session.LibraryUnloadOption.AtTermination  

    End [COLOR=blue]Function[/color]  

End [COLOR=blue]Module[/color]


www.nxjournaling.com
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor