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!

Calculating Component Degrees of Freedom on NX6.0.2.8

Status
Not open for further replies.

koutilya

Marine/Ocean
Aug 10, 2011
24
Hi All,

Is there any way to find the Component Degrees of Freedom in NX Assembly. I used the below method to list out DOF information. But it is giving wrong results.

component ->GetDegreesOfFreedom();

Any help in this regard is greatly appreciated.

Thanks in advance


 
Replies continue below

Recommended for you

I use this:
Option Strict Off
Imports System
Imports System.Runtime.InteropServices
Imports NXOpen
Imports NXOpenUI
Imports NXOpen.UF
Imports NXOpen.Assemblies
Imports NXOpen.Assemblies.Component
Imports NXOpen.Utilities

Module degree_of_freedom

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

Sub Main()
Dim comps() As Component = Nothing
Dim dof As DegreesOfFreedom = Nothing
Dim dof_r As DegreesOfFreedom = Nothing

Dim theSession As Session = Session.GetSession()
Dim workPart As Part = theSession.Parts.Work
Dim displayPart As Part = theSession.Parts.Display
'Dim ref As String = Nothing

lw.Open()

SelectAndDeselectComponents("Select Components", comps)
'SelectAndDeselectComponents("Select and Deselect Components", comps)
'lw.WriteLine("haho")
lw.WriteLine(comps(0).Name)
dof = comps(0).GetDegreesOfFreedom()
'ref = comps(0).ReferenceSet

'lw.WriteLine(dof.ToString)
lw.WriteLine("Number of rotation degrees: " & dof.NumRotational)
lw.WriteLine("Number of translation degress " & dof.NumTranslational)
'lw.WriteLine(dof.Result)
'lw.WriteLine(ref)

'Leszedi a kijelolest Deselection
ufs.Disp.SetHighlight(comps(0).Tag, 0)

'Frissiti akepernyot Refresh the screen
workPart.Views.Refresh()

End Sub

Public Structure PreselectDataS
Public ItemCount As Integer
Public Items() As Tag
End Structure

Public Function PreselectComponents(ByVal select_ As IntPtr, ByVal user_data As IntPtr) As Integer

Dim preselected_data As PreselectDataS = Marshal.PtrToStructure(user_data, New PreselectDataS().GetType)

If preselected_data.ItemCount > 0 Then
ufs.Ui.AddToSelList(select_, preselected_data.ItemCount, preselected_data.Items, True)
End If

Dim mask_triples(0) As UFUi.Mask
With mask_triples(0)
.object_type = UFConstants.UF_component_type
.object_subtype = UFConstants.UF_component_subtype
.solid_type = 0
End With

ufs.Ui.SetSelMask(select_, UFUi.SelMaskAction.SelMaskClearAndEnableSpecific, 1, mask_triples)

Return UFConstants.UF_UI_SEL_SUCCESS

End Function

Public Sub SelectAndDeselectComponents(ByVal prompt As String, ByRef theComponents() As Component)

Dim resp As Integer = 0
Dim cnt As Integer = 0
Dim preselectComponentsData As PreselectDataS
With preselectComponentsData
.Items = Nothing
.ItemCount = 0
End With

If Not theComponents Is Nothing Then
Dim compTags(theComponents.Length - 1) As Tag
For ii As Integer = 0 To theComponents.Length - 1
compTags(ii) = theComponents(ii).Tag
Next
preselectComponentsData.Items = compTags
preselectComponentsData.ItemCount = theComponents.Length
End If

Dim preselectpnt As IntPtr = Marshal.AllocHGlobal(Marshal.SizeOf(preselectComponentsData))
Marshal.StructureToPtr(preselectComponentsData, preselectpnt, False)
Dim theTags() As Tag = Nothing

ufs.Ui.SetCursorView(0) ' In case a drawing is displayed - allow selection within member views
ufs.Ui.LockUgAccess(UFConstants.UF_UI_FROM_CUSTOM) ' in case running a journal

ufs.Ui.SelectWithClassDialog("Select Components", prompt, UFConstants.UF_UI_SEL_SCOPE_ANY_IN_ASSEMBLY, _
AddressOf PreselectComponents, preselectpnt, resp, cnt, theTags)

ufs.Ui.UnlockUgAccess(UFConstants.UF_UI_FROM_CUSTOM) ' in case running a journal

ReDim theComponents(cnt - 1)

For ii As Integer = 0 To cnt - 1
ufs.Disp.SetHighlight(theTags(ii), 0)
theComponents(ii) = NXObjectManager.Get(theTags(ii))
Next

End Sub


Public Function GetUnloadOption(ByVal dummy As String) As Integer

Return Session.LibraryUnloadOption.Immediately

End Function

End Module
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor