The approach taken will depend on your needs and how much interaction you want the user to have. This GTAC example shows one way of allowing the user to select an edge. This could be combined with the code in this thread to report the tolerance value of a selected edge.
Here is a similar example that allows the user to interactively select an edge. In that code, the user is only allowed to select a circular edge. To allow selection of any edge, change the following code:
With selectionMask_array(0) .Type = UFConstants.UF_solid_type .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_CIRCULAR_EDGE End With
With selectionMask_array(0) .Type = UFConstants.UF_solid_type .SolidBodySubtype = UFConstants.UF_UI_SEL_FEATURE_ANY_EDGE End With
I tried to run following code but it is showing some error, I am not able to rectify it.
Can you please help me out with this?
Option Strict Off Imports System Imports NXOpen Imports NXOpenUI Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim theUISession As UI = UI.GetUI Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, "journal") 'change excelFileName to meet your needs Const excelFileName As String = "C:\Temp\part_dimensions.xlsm" Dim row As Long = 1 Dim column As Long = 1 'create Excel object Dim objExcel = CreateObject("Excel.Application") If objExcel Is Nothing Then theUISession.NXMessageBox.Show("Error", NXMessageBox.DialogType.Error, "Could not start Excel, journal exiting") theSession.UndoToMark(markId1, "journal") Exit Sub End If 'open Excel file Dim objWorkbook = objExcel.Workbooks.Open(excelFileName) If objWorkbook Is Nothing Then theUISession.NXMessageBox.Show("Error", NXMessageBox.DialogType.Error, "Could not open Excel file: " & excelFileName & ControlChars.NewLine & "journal exiting.") theSession.UndoToMark(markId1, "journal") Exit Sub End If objExcel.visible = True objExcel.Cells(row, 1) = workPart.FullPath Dim myDimText() As String Dim myDimDualText() As String For Each myDimension As Annotations.Dimension In workPart.Dimensions row += 1 myDimension.GetDimensionText(myDimText, myDimDualText) objExcel.Cells(row, column) = myDimText(0) Next 'objExcel.Quit() objWorkbook = Nothing objExcel = Nothing lw.Close() End Sub Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image when the NX session terminates GetUnloadOption = NXOpen.Session.LibraryUnloadOption.AtTermination '----Other unload options------- 'Unloads the image immediately after execution within NX 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately 'Unloads the image explicitly, via an unload dialog 'GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Explicitly '------------------------------- End Function End Module
The journal above uses a hardcoded path to an existing Excel file. Change the path in the code to point to your Excel file, or use a filebrowser dialog to allow the user to specify an Excel file to use.
Const excelFileName As String = "C:\Temp\part_dimensions.xlsm"
This issue is resolved.
But it gives values of indivisual dimesion only & only after selection of that dimension. I want all dimension all together as soon as I run the code.
I am searching out for stackup analysis?
Can you please help me out with this, as it is my intership project and I dont have much time to learn programming & write aprogram.
Thanks in advance.
Your last 2 questions are taking this thread off topic; I suggest you start a new thread for your questions. I wish you the best of luck with your internship project.