Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

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

Stock size in NX 8.5

Status
Not open for further replies.

ashivu123

Aerospace
Joined
Oct 24, 2013
Messages
153
Location
US
How to represent stock size of machining component in NX8.5??
 
Represent stock size ?
- Document the stock size ?


Regards,
Tomas
 
iam looking like representing 3D block which shows the stock size that need to make the part
 
DO U WANT TO REPRENT IN DRAWING OR DO YOU WANT CREATE ANY BLOCK.

If you want bounding block creation there was journal which will create rectangular bounding box
 
Exactly what I was looking gani, long back in my previous company I seen that bounding block creating on the part. Do u have that journal??
If stock size to be shown in drafting how do you show it??
 
here is the code from GTAC which will create bounding block with respect to the relative WCS
Code:
'**************************************************************
' Will be prompted to select a body and will make a bounding block
' based on the WCS
'**************************************************************

Option Strict Off

Imports System

Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.UF

Module make_bounding_block_of_selected_body_relative_to_wcs

    Dim s As Session = Session.GetSession()
    Dim ufs As UFSession = UFSession.GetUFSession()
    Dim lw As ListingWindow = s.ListingWindow()

    Sub Main()

        Dim a_body As NXOpen.Tag = NXOpen.Tag.Null
        Dim csys As NXOpen.Tag = NXOpen.Tag.Null
        Dim target As NXOpen.Tag = NXOpen.Tag.Null
        Dim blockFeature As NXOpen.Tag = NXOpen.Tag.Null

        Dim min_corner(2) As Double
        Dim directions(2, 2) As Double
        Dim distances(2) As Double
        Dim edge_len(2) As String

        While select_a_body(a_body) = Selection.Response.Ok

            ufs.Csys.AskWcs(csys)

            ufs.Modl.AskBoundingBoxExact(a_body, csys, min_corner, directions, _
                distances)

            lw.Open()

            lw.WriteLine("Min_corner: " & _
                min_corner(0).ToString & ", " & _
                min_corner(1).ToString & ", " & _
                min_corner(2).ToString & ", ")

            lw.WriteLine("X direction: " & _
                directions(0, 0).ToString & ", " & _
                directions(0, 1).ToString & ", " & _
                directions(0, 2).ToString & ", ")
            lw.WriteLine("X distance: " & _
                distances(0).ToString)

            lw.WriteLine("Y direction: " & _
                directions(1, 0).ToString & ", " & _
                directions(1, 1).ToString & ", " & _
                directions(1, 2).ToString & ", ")
            lw.WriteLine("Y distance: " & _
                distances(1).ToString)

            lw.WriteLine("Z direction: " & _
                directions(2, 0).ToString & ", " & _
                directions(2, 1).ToString & ", " & _
                directions(2, 2).ToString & ", ")
            lw.WriteLine("Z distance: " & _
                distances(2).ToString)

            edge_len(0) = distances(0).ToString()
            edge_len(1) = distances(1).ToString()
            edge_len(2) = distances(2).ToString()

            ' Create a block
            Dim workPart As Part = s.Parts.Work

            ' Create block feature builder
            Dim nullFeatures_Feature As Features.Feature = Nothing
            Dim blockFeatureBuilder1 As Features.BlockFeatureBuilder
            blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullFeatures_Feature)

            ' Define block by Origin and edge length
            blockFeatureBuilder1.Type = Features.BlockFeatureBuilder.Types.OriginAndEdgeLengths
            Dim originPoint1 As Point3d = New Point3d(min_corner(0), min_corner(1), min_corner(2))
            blockFeatureBuilder1.SetOriginAndLengths(originPoint1, distances(0), distances(1), distances(2))            

            ' Create the block by committing the builder
            Dim feature1 As Features.Feature
            feature1 = blockFeatureBuilder1.CommitFeature()

            ' The function below is accessing an old UFunc to create the block. The UFunc however requires
            ' a solid modeling license - which does not work in cam_express. The above method to create a
            ' a block uses the new JA methods. And that will work with a cam_base license as well.
            'ufs.Modl.CreateBlock(FeatureSigns.Nullsign, _
            '                     target, min_corner, edge_len, blockFeature)
        End While

    End Sub

    Function select_a_body(ByRef a_body As NXOpen.Tag) As Selection.Response

        Dim message As String = "Select a body"
        Dim title As String = "Select a body"
        Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
        Dim response As Integer

        Dim view As NXOpen.Tag
        Dim cursor(2) As Double
        Dim ip As UFUi.SelInitFnT = AddressOf body_init_proc

        ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

        Try
            ufs.Ui.SelectWithSingleDialog(message, title, scope, ip, _
                         Nothing, response, a_body, cursor, view)
        Finally
            ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)
        End Try

        If response <> UFConstants.UF_UI_OBJECT_SELECTED And _
           response <> UFConstants.UF_UI_OBJECT_SELECTED_BY_NAME Then
            Return Selection.Response.Cancel
        Else
            ufs.Disp.SetHighlight(a_body, 0)
            Return Selection.Response.Ok
        End If

    End Function

    Function body_init_proc(ByVal select_ As IntPtr, _
                           ByVal userdata As IntPtr) As Integer

        Dim num_triples As Integer = 1
        Dim mask_triples(0) As UFUi.Mask
        mask_triples(0).object_type = UFConstants.UF_solid_type
        mask_triples(0).object_subtype = UFConstants.UF_solid_body_subtype
        mask_triples(0).solid_type = UFConstants.UF_UI_SEL_FEATURE_BODY

        ufs.Ui.SetSelMask(select_, _
                           UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, _
                           num_triples, mask_triples)
        Return UFConstants.UF_UI_SEL_SUCCESS

    End Function

    Public Function GetUnloadOption(ByVal dummy As String) As Integer

        GetUnloadOption = UFConstants.UF_UNLOAD_IMMEDIATELY

    End Function

End Module


If you want to show in drawing need to make attributes of block size and call in drawing
 
How do I build/write this into nx so I can use code because this would be very useful for me?

Thank you.

Regards Daniel.
 
Copy this code to journal file with extension .vb and Execute through Tools->Journal->Play
 
this is great

Thank you

Regards Daniel Lamb.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top