NXOpen Getting Feature Assoicated with Dimension
NXOpen Getting Feature Assoicated with Dimension
(OP)
Dear Forum,
Is there a way to get a particular feature attached to a dimension with NXOpen? Say for example, I have a drawing dimension that is associated with a hole feature is there a way through NXOpen to get the instance feature(s) that the extension lines of the dimensions are attached too??
Any ideas?
Thanks
Is there a way to get a particular feature attached to a dimension with NXOpen? Say for example, I have a drawing dimension that is associated with a hole feature is there a way through NXOpen to get the instance feature(s) that the extension lines of the dimensions are attached too??
Any ideas?
Thanks





RE: NXOpen Getting Feature Assoicated with Dimension
What version of NX?
www.nxjournaling.com
RE: NXOpen Getting Feature Assoicated with Dimension
Mike Hyde
www.astonmartin.com
NX8.5 with TC9.1
Moving to NX10 with TC11.2
RE: NXOpen Getting Feature Assoicated with Dimension
CODE
Option Strict Off Imports System Imports NXOpen Imports NXOpen.UF Module Module1 Sub Main() Dim theSession As Session = Session.GetSession() Dim theUfSession As UFSession = UFSession.GetUFSession() If IsNothing(theSession.Parts.BaseWork) Then 'active part required Return End If Dim workPart As Part = theSession.Parts.Work Dim lw As ListingWindow = theSession.ListingWindow lw.Open() Const undoMarkName As String = "dimension -> feature(s)" Dim markId1 As Session.UndoMarkId markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName) Dim theDimension As Annotations.Dimension If SelectDimension("Select a drafting dimension", theDimension) = Selection.Response.Cancel Then Return End If lw.WriteLine("number of associativities: " & theDimension.NumberOfAssociativities.ToString) If theDimension.NumberOfAssociativities > 0 Then Dim firstA As Annotations.Associativity = theDimension.GetFirstAssociativity If Not IsNothing(firstA.FirstObject) Then lw.WriteLine("first object: " & firstA.FirstObject.GetType.ToString) If TypeOf (firstA.FirstObject) Is Edge Then Dim edgeFeatureList() As Tag theUfSession.Modl.AskEdgeFeats(firstA.FirstObject.Tag, edgeFeatureList) For Each temp As Tag In edgeFeatureList Dim edgeFeat As Features.Feature = Utilities.NXObjectManager.Get(temp) lw.WriteLine(" feature: " & edgeFeat.GetFeatureName) Next End If Else lw.WriteLine("first object is NOTHING") End If End If If theDimension.NumberOfAssociativities > 1 Then Dim secondA As Annotations.Associativity = theDimension.GetSecondAssociativity If Not IsNothing(secondA.FirstObject) Then lw.WriteLine("second object: " & secondA.FirstObject.GetType.ToString) If TypeOf (secondA.FirstObject) Is Edge Then Dim edgeFeatureList() As Tag theUfSession.Modl.AskEdgeFeats(secondA.FirstObject.Tag, edgeFeatureList) For Each temp As Tag In edgeFeatureList Dim edgeFeat As Features.Feature = Utilities.NXObjectManager.Get(temp) lw.WriteLine(" feature: " & edgeFeat.GetFeatureName) Next End If Else lw.WriteLine("second object is NOTHING") End If End If lw.Close() End Sub Function SelectDimension(ByVal prompt As String, ByRef selDim As Annotations.Dimension) As Selection.Response Dim selObj As TaggedObject = Nothing Dim theUI As UI = UI.GetUI Dim title As String = "Select a drafting dimension" Dim includeFeatures As Boolean = False Dim keepHighlighted As Boolean = False Dim selAction As Selection.SelectionAction = Selection.SelectionAction.ClearAndEnableSpecific Dim cursor As Point3d Dim scope As Selection.SelectionScope = Selection.SelectionScope.WorkPart Dim selectionMask_array(0) As Selection.MaskTriple With selectionMask_array(0) .Type = UFConstants.UF_dimension_type .Subtype = UFConstants.UF_all_subtype End With Dim resp As Selection.Response = theUI.SelectionManager.SelectTaggedObject(prompt, _ title, scope, selAction, _ includeFeatures, keepHighlighted, selectionMask_array, _ selObj, cursor) If resp = Selection.Response.ObjectSelected OrElse resp = Selection.Response.ObjectSelectedByName Then selDim = Utilities.NXObjectManager.Get(selObj.Tag) Return Selection.Response.Ok Else Return Selection.Response.Cancel End If End Function Public Function GetUnloadOption(ByVal dummy As String) As Integer 'Unloads the image immediately after execution within NX GetUnloadOption = NXOpen.Session.LibraryUnloadOption.Immediately End Function End Modulewww.nxjournaling.com
RE: NXOpen Getting Feature Assoicated with Dimension