×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

NX bounding Dimensions

NX bounding Dimensions

NX bounding Dimensions

(OP)
thread561-319996: NXOpen .Net - MeasureBodies performace very poor
hello all,
i would love help in some things :

i would like to retrive all the info that that journal gives in an Information window, and would like if i could select any part insteed only the work park, what im trying to do is to populate the "catalog/size" on BOM.

btw the dims displayed by this journal works on inclined solids ?

Thanks in advance.

RE: NX bounding Dimensions

(OP)
thanks for the fast reply cowski,

was tolded to our company to stay a bit longer on 8.5 due correction of bugs so i think we will be staying on 8.5 a bit longer; do you advise to upgrade ?

i saw that thread but it is to create a bounding box, but i just want the dimensions of the solid regarding if it is inclined or not, if the only way to achieve the dimensions result is by creating a bounding box, is it possible to create a journal that creates an "illusionary" box and return to me the dimensions ?

i have this journal:

CODE -->

Option Strict Off

Imports System

Imports System.Math
Imports NXOpen
Imports NXOpen.UI
Imports NXOpen.Utilities
Imports NXOpen.UF

Module report_bounding_box_plus_block

  Dim s As Session = Session.GetSession()
  Dim ufs As UFSession = UFSession.GetUFSession()
  Dim theSession As Session = Session.GetSession()
  Dim workPart As Part = theSession.Parts.Work
  Dim displayPart As Part = theSession.Parts.Display


Sub Main()

    Dim a_body As NXOpen.Tag
    Dim csys As NXOpen.Tag
    

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

	Dim n As String = vbCrLf

    While select_a_body(a_body) = Selection.Response.Ok 'And _
	'	select_a_csys(wcs) = Selection.Response.Ok

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

		ufs.Ui.OpenListingWindow()
		'ufs.Ui.WriteListingWindow("Min_corner: " & _
		'	min_corner(0).ToString & ", " & _
		'	min_corner(1).ToString & ", " & _
		'	min_corner(2).ToString & ", " & n)

	'	ufs.Ui.WriteListingWindow("Stock Size X: " & _
	'		directions(0,0).ToString & ", " & _
	'		directions(0,1).ToString & ", " & _
	'		directions(0,2).ToString & ", " & n)
		ufs.Ui.WriteListingWindow("Stock Size X: " & _
			Math.Round(distances(0),3).ToString & n)

	'	ufs.Ui.WriteListingWindow("Stock Size Y: " & _
	'		directions(1,0).ToString & ", " & _
	'		directions(1,1).ToString & ", " & _
	'		directions(1,2).ToString & ", " & n)
		ufs.Ui.WriteListingWindow("Stock Size Y " & _
			Math.Round(distances(1),3).ToString & n)

	'	ufs.Ui.WriteListingWindow("Z direction: " & _
	'		directions(2,0).ToString & ", " & _
	'		directions(2,1).ToString & ", " & _
	'		directions(2,2).ToString & ", " & n)
		ufs.Ui.WriteListingWindow("Stock Size Z: " & _
			Math.Round(distances(2),3).ToString & n & n)
                  

   ' End While

    Dim msg As String
    Dim title As String
    Dim style As MsgBoxStyle
    Dim response As MsgBoxResult

    msg = "Want to create a block?"   ' Define message.
    style = MsgBoxStyle.YesNo
    title = "Stock Size Bloco"     ' Define title.

    ' Display the dialog for the user  
    response = MsgBox(msg, style, title)

    If response = MsgBoxResult.No Then    
        ' 
        
    Exit Sub
    End If

   

--------------------------------------------------------------

Dim coordinates1 As Point3d = New Point3d (min_corner(0), min_corner(1), min_corner(2))
Dim point1 As Point

Dim T_Dim_X As String = Math.Round(distances(0),3)
Dim T_Dim_Y As String = Math.Round(distances(1),3)
Dim T_Dim_Z As String = Math.Round(distances(2),3)

T_Dim_X = T_Dim_X.replace(",", ".")
T_Dim_Y = T_Dim_Y.replace(",", ".")
T_Dim_Z = T_Dim_Z.replace(",", ".") 

point1 = workPart.Points.CreatePoint(coordinates1)

Dim nullFeatures_Feature As Features.Feature = Nothing

Dim blockFeatureBuilder1 As Features.BlockFeatureBuilder

blockFeatureBuilder1 = workPart.Features.CreateBlockFeatureBuilder(nullFeatures_Feature)

Dim originPoint1 As Point3d = New Point3d (min_corner(0), min_corner(1), min_corner(2))

blockFeatureBuilder1.SetOriginAndLengths(originPoint1, T_Dim_X, _
                                                        T_Dim_Y, _
                                                        T_Dim_Z)



                                                      ' Decimal.Round(distances(1),3), _
                                                      ' Decimal.Round(distances(2),3))




Dim feature1 As Features.Feature
feature1 = blockFeatureBuilder1.CommitFeature()

blockFeatureBuilder1.Destroy()


Dim body2 As Body

Dim LastBlock As Features.Block = CType (feature1,Features.Block)

body2 = LastBlock.GetBodies (0)

Dim displayModification1 As DisplayModification

displayModification1 = theSession.DisplayManager.NewDisplayModification()

displayModification1.ApplyToAllFaces = True

displayModification1.NewColor = 6

displayModification1.NewTranslucency = 50

displayModification1.NewFont = DisplayableObject.ObjectFont.Dashed

Dim objects1(0) As DisplayableObject

objects1(0) = body2
displayModification1.Apply(objects1)

displayModification1.Dispose()

'---------------------------------------------------------------------------------

   End While

    End Sub

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

    Dim message As String
    Dim title As String = "Select a body"
    Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
    Dim response As Integer
    Dim obj As NXOpen.Tag
    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

Function select_a_csys(ByRef csys As NXOpen.Tag) As Selection.Response

    Dim message As String
    Dim title As String = "Select a CSYS"
    Dim scope As Integer = UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY
    Dim response As Integer
    Dim obj As NXOpen.Tag
    Dim view As NXOpen.Tag
    Dim cursor(2) As Double
    Dim ip As UFUi.SelInitFnT = AddressOf csys_init_proc

    ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM)

    Try
        ufs.Ui.SelectWithSingleDialog(message, title, scope, ip, _
                     Nothing, response, csys, 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(csys, 0)
        Return Selection.Response.Ok
    End If

    End Function

Function csys_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_coordinate_system_type
    mask_triples(0).object_subtype = UFConstants.UF_csys_normal_subtype
    mask_triples(0).solid_type = 0

    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 

but on inclined objects don't work correct and creates a block larger than the max dimensions of it

here is an image that i think explains my problem

RE: NX bounding Dimensions

thread561-323165: how to use bounding box dimensions in assembly cut list? has several journals that calculate the bounding box of a body. One calculates it based on the absolute coordinate system (ACS), another uses the work coordinate system (WCS), and another uses a csys chosen by the user. The output is either shown in the information window or added to the part as attributes; the downside is: these values do not update automatically. They are only snapshots of the model at the time the journal was executed; to update the values, the journal will need to be run again. The advantage with NX 10 is, the bounding box is a full fledged feature that is associative to the solid body and csys chosen and will update accordingly.

www.nxjournaling.com

RE: NX bounding Dimensions

If you read the other thread really careful , you will notice that there are comments on how to rotate the bounding block.
This is because there is no optimizing function built into this feature. NX will create a bounding box which is parallel to the coordinate system and one of the new options in the NX903 feature is the ability to manually rotate.
i.e if you attempt to create the absolute minimum box using a program, you also need to write your own optimization routine to indirect rotate the coordinate system.

Regards,
Tomas

RE: NX bounding Dimensions

(OP)
the problem is: imagine if i have 5000 inclined solids with difer dims, i have to go manualy on all solids to rotate the WCS so i can get te correct dimension or that or going manualy thru measure distance; and with that journal that i want working i just have to do "2 clicks" i will review again the threads that you guys sent me and post news about it later

thanks for the helping so far

NX8.5 User

RE: NX bounding Dimensions

(OP)
sorry on the double post but i cant edit my posts dunno why;

on that thread cowski i tryed to run those journals but did not happen anything dunno why. is there a way to see a "log" ?

NX8.5 User

RE: NX bounding Dimensions

Some of the journals only apply the values as part attributes. To check the attributes, go to File -> properties -> attributes.

To check the NX log file after running the journal, go to Help -> log file and scroll to the bottom (or very close to it). You should either find a message that the journal executed successfully or error messages.

www.nxjournaling.com

RE: NX bounding Dimensions

I seem to remember some code that would find the largest planar face in a solid body, create a csys on that face with the X direction parallel to the longest edge, and finally calculate the bounding box based on that csys. This approach is NOT guaranteed to result in the smallest possible bounding box, but it is a better starting point than most...

www.nxjournaling.com

RE: NX bounding Dimensions

Each line of data that is listed in the old fashionned Info Window can be retrieved thru individual API functions - scroll the GTAC library, everything is there.

RE: NX bounding Dimensions

(OP)
thanks for the help so far, i will try some things then i will post back

NX8.5 User

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources