Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

bounding box 1

Status
Not open for further replies.

jenuary

Mechanical
May 24, 2006
2
Good evening
I have a problem with a Journal file for extract the bounding box of the part.
I have this file but doesent work.
For me is very important.
Thank you very much.
By
 
Replies continue below

Recommended for you

When you say it doesn't work, do you mean: it doesn't run at all, it errors out, or it gives incorrect/unexpected results?

I see the journal was written with NX6 in mind, what version of NX are you running?
 

Jenuary,

It looks like this was an unfinished program.

This should run now.

Code:
' NX 6.0.0.24
' 
'
Option Strict Off

Imports System
Imports NXOpen
Imports NXOpen.UF
Imports NXOpenUI
Imports NXOpen.Assemblies
Imports System.IO

Module NXJournal
Sub Main

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

Dim displayPart As Part = theSession.Parts.Display
Dim strPart as string
Dim pos as integer
Dim bbox(5) as double
Dim dblAcc_Value(11) as double
Dim dblMass_Props(46) as double
Dim dblStats(12) as double

'''msgbox ("inizio")

        Dim solid1 As Body = SelectSolid()
        If solid1 Is Nothing Then

            Return
        End If

	Dim tagList(0) As NXOpen.Tag
	tagList(0) = solid1.Tag

	'get the full file path
	strPart = solid1.owningpart.fullpath
'''msgbox(strPart)
	pos = InStrRev(strPart, "\")
	'strip off the ".prt" extension
	strPart = Left(strPart, Len(strPart) - 4)
'''msgbox(strPart)
	'add extension to file name for parasolid export
	strPart = strPart + ".x_t"
'''msgbox ("tag: " & solid1.Tag, vbokonly, "Tag")
'''msgbox ("file: " & strPart, vbokonly, "Part")
	'export the solid to a parasolid file
	'ufs.Ps.ExportData(tagList, strPart)

	'get volume
	dblAcc_Value(0)=.999
'''	ufs.Modl.AskMassProps3d(in_Tags(),in_num_objs,in_type,in_units, _
in_density,in_accuracy,in_accuracy_values(),out_mass_props(),out_stats())
'''	ufs.Modl.AskMassProps3d(tagList,1,1,1,.0375,1,dblAcc_Value(), _
dblMass_Props(),dblStats())
	ufs.Modl.AskMassProps3d(tagList,1,1,1,.0375,1,dblAcc_Value, _
dblMass_Props,dblStats)
msgbox ("Volume: " & dblMass_Props(1), vbokonly)

	'get solid body bounding box extents
	ufs.Modl.AskBoundingBox(solid1.Tag,bbox)
msgbox ("min X: " & bbox(0) & "min Y: " & bbox(1) & "min Z: " & bbox(2) & "max X: " & bbox(3) & "max Y: " & _
bbox(4) & "max Z: " & bbox(5), vbokonly)

End Sub

    Public Function SelectSolid() As Body

'''msgbox("passato a solid")
        Dim ui As UI = ui.GetUI
        Dim message As String = "Select solid body"
        Dim title As String = "Selection"

        Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart
        Dim keepHighlighted As Boolean = False
        Dim includeFeatures As Boolean = True

        Dim selectionAction As Selection.SelectionAction = _
            Selection.SelectionAction.ClearAndEnableSpecific

        Dim selectionMask_array(1) As Selection.MaskTriple
        With selectionMask_array(0)
            .Type = UFConstants.UF_solid_type
            .Subtype = 0
            .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_SOLID_BODY
            '.SolidBodySubtype = 36
        End With

        Dim selectedObject As NXObject = Nothing
        Dim cursor As Point3d

        ui.SelectionManager.SelectObject(message, title, scope, _
                                         selectionAction, includeFeatures, _
                                         keepHighlighted, selectionMask_array, _
                                         selectedObject, cursor)

        Dim solid As Body = CType(selectedObject, Body)

        If solid Is Nothing Then
'''msgbox("Return Nothing")
            Return Nothing
        End If

'''msgbox("Return solid")
        Return solid

    End Function
End Module
 
Hi Jpetach,
thanks for the help, it's perfect.
I have a question for you:
is possible to get the total size 3 dimension?
In this exsample i have the minimun en the maximun X,y,Z dimension,
you can get the total dimension without adding parameters minum and maximun?
Sorry for my English, i'm Italian
Have a nice day
Jenuary
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor