Quantcast
Channel: NX Journaling
Viewing all articles
Browse latest Browse all 19

Circular detail view border and label on parent

$
0
0

Have you ever needed to get the label or arc representing the detail view border from the parent view? Unfortunately, the detail view builder does not give you immediate access to these objects related to the detail view. Fortunately, they are not too difficult to track down. The following class will take either the detail view itself or the arc from the parent representing the view boundary and return the following information:

  • DetailViewName - the name of the detail view
  • ParentView - the view the detail view is taken from
  • CenterPoint - the center point of the circular boundary (in the parent view)
  • BoundingPoint1 - the first bounding point of the detail view; for circular detail views, this is the same as the center point
  • BoundingPoint2 - the second bounding point of the detail view; for circular detail views, this is a point on the circumference
  • BorderArc - this is the arc object on the parent view that represents the detail view border
  • LabelOnParent - the label associated to the border arc, if one is created

WARNING: in its current form, this code only works on circular detail views.

This class was inspired by code on GTAC (nx_api6015, written by Frank Berger). When the detail view is created, NX associates the arc and label to the detail view; we can use some "smart object" methods to find and interrogate these relations. The code asks for the drafting view's smart object children to find the label. Unfortunately, the associativity with the border arc is more difficult to find. To find the border arc, given the detail view, we first look through all the arcs in the current work part (which should be your drawing) looking for those that have a drafting view as one of the smart parents. Since a view might be a parent view to multiple detail views, we need a way to check if this particular arc matches the information for the detail view. If/when an arc is found that is associated to a drafting view, we compare its center point to bounding point 1 of the detail view; if the coordinates match, we have found the border arc.

Class code
The code below cannot be run by itself, it needs other code to instantiate it and call its methods. If you do not have an author license, you can copy and paste this class code into your journal (an example will follow). Your journal code will make use of this class code, the class code should not be changed unless you find a bug or want to add new features.

'NXJournaling.com'February 19, 2019'This class helps get objects related to a detail view (circular view border and label on parent) that the detail view builder does not provide access to.'Use the "New" method and pass in either the detail view itself OR the border arc (the arc drawn on the parent view representing the detail view border).'The class will gather info and provide it through the following read only properties:'  DetailViewName   the name of the detail view'  ParentView       the view the detail view is taken from'  CenterPoint      the center point of the circular boundary (in parent view)'  BoundingPoint1   the first bounding point defining the detail view boundary (same as center point for circular detail views)'  BoundingPoint2   the second bounding point defining the detail view boundary (for circular detail views this point is on the circumference of the defining arc)'  BorderArc        the border arc on the parent view (returns Nothing if the label on parent type is set to "none")'  LabelOnParent    the label on the border arc, returns nothing if there is no label on the parent (label on parent display option: none, circle, boundary) 
'Update January 28, 2020'Add code to return the label on parent, given the detail view 
'March 31, 2021'If the .LabelOnParent type is set to "none", return "nothing" for the label 
 
 
'Required imports'Imports System'Imports System.Collections.Generic'Imports NXOpen'Imports NXOpen.UF 
 
PublicClass NXJ_DetailViewInfo
 
#Region "Private variables"Private _theSession As Session = Session.GetSessionPrivate _theUfSession As UFSession = UFSession.GetUFSession()Private lg As LogFile = _theSession.LogFile 
    Private lw As ListingWindow = _theSession.ListingWindowPrivate _theDetailView As Drawings.DetailView 
#End Region
 
    Private _detailViewName AsString=""PublicReadOnlyProperty DetailViewName()AsStringGetReturn _detailViewName
        EndGetEndProperty 
    Private _parentView As Drawings.DraftingViewPublicReadOnlyProperty ParentView()As Drawings.DraftingViewGetReturn _parentView
        EndGetEndProperty 
    Private _centerPt As Point3d =NothingPublicReadOnlyProperty CenterPoint()As Point3d
        GetReturn _centerPt
        EndGetEndProperty 
    Private _boundPt1 As Point3d =NothingPublicReadOnlyProperty BoundingPoint1()As Point3d
        GetReturn _boundPt1
        EndGetEndProperty 
    Private _boundPt2 As Point3d =NothingPublicReadOnlyProperty BoundingPoint2()As Point3d
        GetReturn _boundPt2
        EndGetEndProperty 
    Private _borderArc As Arc =NothingPublicReadOnlyProperty BorderArc()As Arc
        GetReturn _borderArc
        EndGetEndProperty 
    Private _labelOnParent As Annotations.Label=NothingPublicReadOnlyProperty LabelOnParent()As Annotations.LabelGetReturn _labelOnParent
        EndGetEndProperty 
    PublicSubNew(ByVal theDetailView As Drawings.DetailView)
        lg.WriteLine("Sub New, given detail view") 
        _theDetailView = theDetailView
        _detailViewName = theDetailView.Name'given the view, return the border arcMe.GetViewBounds(theDetailView) 
        'The border arc (of a circular detail view) will be an arc where one of the smart object parents'will be the parent view of the detail view and the arc center will match _centerPt (within modeling tolerance).
        _borderArc =Me.FindBorderArc() 
        Me.GetLabelOnParent() 
    EndSub 
    PublicSubNew(ByVal theBorderArc As Arc)
        lg.WriteLine("Sub New, given the detail border arc")
        _borderArc = theBorderArc
 
        'given the border arc, return the detail viewDim theDetailView As Drawings.DetailView=Me.FindDetailView(_borderArc)If IsNothing(theDetailView)Then
            _detailViewName =""Else
            _detailViewName = theDetailView.Name
            _theDetailView = theDetailView
            Me.GetViewBounds(theDetailView)Me.GetLabelOnParent() 
        EndIf 
    EndSub 
    PrivateSub GetViewBounds(ByVal theDetailView As Drawings.DetailView)
        lg.WriteLine("GetViewBounds") 
        Dim detailViewBuilder1 As Drawings.DetailViewBuilder= _theSession.Parts.Work.DraftingViews.CreateDetailViewBuilder(theDetailView)'lw.WriteLine("label on parent: " & detailViewBuilder1.LabelOnParent.ToString)
        lg.WriteLine("parent view: "& detailViewBuilder1.Parent.View.Value.Name)
        lg.WriteLine("boundary point 1: "& detailViewBuilder1.BoundaryPoint1.Coordinates.ToString)'lw.WriteLine("boundary point 2: " & detailViewBuilder1.BoundaryPoint2.Coordinates.ToString)
        _boundPt1 = detailViewBuilder1.BoundaryPoint1.Coordinates
        _boundPt2 = detailViewBuilder1.BoundaryPoint2.Coordinates 
        If detailViewBuilder1.Type= Drawings.DetailViewBuilder.Types.CircularThen
            _centerPt = detailViewBuilder1.BoundaryPoint1.CoordinatesEndIf 
        _parentView = detailViewBuilder1.Parent.View.Value 
        detailViewBuilder1.Destroy() 
        lg.WriteLine("Exiting GetViewBounds")
        lg.WriteLine("")EndSub 
    PrivateFunction FindBorderArc()As Arc
        lg.WriteLine("FindBorderArc") 
        'TO DO: make sure arc is not view dependent'  the "view boundary" arc around the actual detail view is view dependent in the detail view,'  this is NOT the border arc we are looking for (the arc on the parent view that represents what the detail view shows). 
        ForEach tempArc As Arc In _theSession.Parts.Work.ArcsDim arcParents AsNew List(Of NXObject)
            GetSmartParents(tempArc, arcParents)ForEach tempParent As NXObject In arcParents
                IfTypeOf(tempParent)Is Drawings.DraftingViewThen 
                    lg.WriteLine("FindBorderArc: tempParent.Name: "& tempParent.Name)
                    lg.WriteLine("FindBorderArc: _parentView.Name: "& _parentView.Name)
                    lg.WriteLine("FindBorderArc: tempParent.Tag: "& tempParent.Tag.ToString)
                    lg.WriteLine("FindBorderArc: _parentView.Tag: "& _parentView.Tag.ToString) 
                    If tempParent.Name<> _parentView.NameThen
                        lg.WriteLine("tempParent.Name <> _parentView.Name")'this is not the arc we are looking for'move along...ContinueForEndIf 
                    'if we get here, the view names match'so far, so good
                    lg.WriteLine("view names match, checking points")If Point3dEqual(tempArc.CenterPoint, _centerPt)Then
                        lg.WriteLine("points match, returning tempArc")'parent views match and center points match'this is it'_borderArc = tempArcReturn tempArc
                    Else
                        lg.WriteLine("points do not match, check next parent")EndIf 
                EndIfNext'lw.WriteLine("")Next 
        'no more arcs, no matches found
        lg.WriteLine("border arc = nothing")'_borderArc = NothingReturnNothing 
        lg.WriteLine("Exiting FindBorderArc")
        lg.WriteLine("")EndFunction 
    PrivateSub GetSmartParents(ByRef theSmartObject As NXObject, ByRef theParentList As List(Of NXObject)) 
        Dim numParents AsIntegerDim theParentTags()As Tag =NothingDim isSmart AsBoolean=False 
        Try
            _theUfSession.So.IsSo(theSmartObject.Tag, isSmart)If isSmart Then'lw.WriteLine("object is smart: " & theSmartObject.Tag.ToString)
                _theUfSession.So.AskParents(theSmartObject.Tag, UFConstants.UF_SO_ASK_ALL_PARENTS, numParents, theParentTags) 
                ForEach tempTag As Tag In theParentTags
                    Dim objParent As NXObject = Utilities.NXObjectManager.Get(tempTag)'lw.WriteLine("adding " & objParent.GetType.ToString & " to parent list")
                    theParentList.Add(objParent) 
                    GetSmartParents(objParent, theParentList) 
                Next 
            Else'lw.WriteLine("object not smart: " & theSmartObject.Tag.ToString)EndIf 
        Catch ex As NXException
            'lw.WriteLine("error: " & ex.ErrorCode)'lw.WriteLine("  " & ex.Message)EndTry 
    EndSub 
    PrivateFunction Point3dEqual(ByVal pt1 As Point3d, ByVal pt2 As Point3d)AsBoolean 
        If IsNothing(pt1)OrElse IsNothing(pt2)ThenReturnFalseEndIf 
        Dim modelingTolerance AsDouble
        _theUfSession.Modl.AskDistanceTolerance(modelingTolerance) 
        lg.WriteLine("modeling distance tolerance: "& modelingTolerance.ToString) 
        If Math.Abs(pt1.X- pt2.X)> modelingTolerance Then
            lg.WriteLine("X distance exceeds modeling tolerance")ReturnFalseEndIf 
        If Math.Abs(pt1.Y- pt2.Y)> modelingTolerance Then
            lg.WriteLine("Y distance exceeds modeling tolerance")ReturnFalseEndIf 
        If Math.Abs(pt1.Z- pt2.Z)> modelingTolerance Then
            lg.WriteLine("Z distance exceeds modeling tolerance")ReturnFalseEndIf 
        lg.WriteLine("points equal withing modeling distance tolerance")ReturnTrue 
    EndFunction 
    PrivateFunction FindDetailView(ByVal theBorderArc As Arc)As Drawings.DetailView 
        ForEach tempView As Drawings.DraftingViewIn _theSession.Parts.Work.DraftingViewsIfNotTypeOf(tempView)Is Drawings.DetailViewThen'only process detail viewsContinueForEndIf 
            Me.GetViewBounds(tempView)Dim tempBorderArc As Arc
            tempBorderArc =Me.FindBorderArcIf IsNothing(tempBorderArc)ThenContinueForEndIf 
            If theBorderArc.Equals(tempBorderArc)ThenReturn tempView
            EndIf 
        Next 
        ReturnNothing 
    EndFunction 
    PrivateSub GetLabelOnParent()'Get label on parent from detail view'nx_api6015 
        Dim myChildList AsNew List(Of NXObject) 
        Dim numChildren AsIntegerDim childTags()As Tag =Nothing 
        _theUfSession.So.AskChildren(_theDetailView.Tag, UFConstants.UF_SO_ASK_ALL_CHILDREN, numChildren, childTags)ForEach tempTag As Tag In childTags
            Dim someObj As NXObject = Utilities.NXObjectManager.Get(tempTag)
            myChildList.Add(someObj)Next 
        ForEach obj As NXObject In myChildList
            'lw.WriteLine("object: " & obj.GetType.ToString)IfTypeOf(obj)Is Annotations.LabelThen
                _labelOnParent = obj
            EndIfNext 
    EndSub 
EndClass

Example of using the class code
The code below shows how to call the class code and make use of the values it returns. In this case, the journal looks for every detail view in the current work part, displays the label text and origin, and changes the border arcs to color 149 (pale crimson in the default palette). To use the class, instantiate an instance with the "New" keyword and pass in either a detail view or the border arc. The NXJ_DetailViewInfo code will run automatically (no other method calls are necessary) and it will expose the information as properties of the NXJ_DetailViewInfo object.

Option Strict Off
Imports System
Imports System.Collections.GenericImports NXOpen
Imports NXOpen.UF 
Module test2
 
    Dim theSession As Session = Session.GetSession()Dim theUfSession As UFSession = UFSession.GetUFSessionDim lw As ListingWindow = theSession.ListingWindow 
 
    Sub Main() 
        lw.Open()Dim markId1 As NXOpen.Session.UndoMarkId=Nothing
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit Object Display") 
        Dim detailViewBorderArcs AsNew List(Of Arc) 
        'find border arc given a detail viewForEach tempView As Drawings.DraftingViewIn theSession.Parts.Work.DrawingSheets.CurrentDrawingSheet.SheetDraftingViewsIfTypeOf(tempView)Is Drawings.DetailViewThenDim myViewInfo AsNew NXJ_DetailViewInfo(tempView) 
                detailViewBorderArcs.Add(myViewInfo.BorderArc)If IsNothing(myViewInfo.LabelOnParent)Then
                    lw.WriteLine("no label on parent view")Else
                    lw.WriteLine("label on parent text: "& EvaluateText(myViewInfo.LabelOnParent))
                    lw.WriteLine("label origin: "& myViewInfo.LabelOnParent.AnnotationOrigin.ToString)EndIf 
            EndIfNext 
        If detailViewBorderArcs.Count>0ThenDim displayModification1 As NXOpen.DisplayModification=Nothing
            displayModification1 = theSession.DisplayManager.NewDisplayModification()
            displayModification1.ApplyToAllFaces=True
            displayModification1.ApplyToOwningParts=False
            displayModification1.NewColor=149
            displayModification1.Apply(detailViewBorderArcs.ToArray) 
            Dim nErrs1 AsInteger=Nothing
            nErrs1 = theSession.UpdateManager.DoUpdate(markId1) 
            displayModification1.Dispose()EndIf 
        lw.Close() 
    EndSub 
    Function EvaluateText(ByVal someNote As Annotations.NoteBase)AsString 
        Dim aT As Annotations.AssociativeText= theSession.Parts.Work.Annotations.CreateAssociativeText()Dim cData As Annotations.ComponentData= theSession.Parts.Work.Annotations.CreateComponentData(someNote) 
        ForEach tC As Annotations.TextComponentIn cData.GetTextComponentsReturn aT.GetEvaluatedText(someNote, tC.GetText(0))Next 
        ReturnNothing 
    EndFunction 
 
EndModule

Full example
If you do not have an author license, all the code above needs to reside in a single file. I suggest creating a new, blank text file, copy & paste the journal code, then create a few blank lines, and copy & paste the class code. The final result can be run as a journal.

Option Strict Off
Imports System
Imports System.Collections.GenericImports NXOpen
Imports NXOpen.UF 
Module test2
 
    Dim theSession As Session = Session.GetSession()Dim theUfSession As UFSession = UFSession.GetUFSessionDim lw As ListingWindow = theSession.ListingWindow 
 
    Sub Main() 
        lw.Open()Dim markId1 As NXOpen.Session.UndoMarkId=Nothing
        markId1 = theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible, "Edit Object Display") 
        Dim detailViewBorderArcs AsNew List(Of Arc) 
        'find border arc given a detail viewForEach tempView As Drawings.DraftingViewIn theSession.Parts.Work.DrawingSheets.CurrentDrawingSheet.SheetDraftingViewsIfTypeOf(tempView)Is Drawings.DetailViewThenDim myViewInfo AsNew NXJ_DetailViewInfo(tempView) 
                detailViewBorderArcs.Add(myViewInfo.BorderArc)If IsNothing(myViewInfo.LabelOnParent)Then
                    lw.WriteLine("no label on parent view")Else
                    lw.WriteLine("label on parent text: "& EvaluateText(myViewInfo.LabelOnParent))
                    lw.WriteLine("label origin: "& myViewInfo.LabelOnParent.AnnotationOrigin.ToString)EndIf 
            EndIfNext 
        If detailViewBorderArcs.Count>0ThenDim displayModification1 As NXOpen.DisplayModification=Nothing
            displayModification1 = theSession.DisplayManager.NewDisplayModification()
            displayModification1.ApplyToAllFaces=True
            displayModification1.ApplyToOwningParts=False
            displayModification1.NewColor=149
            displayModification1.Apply(detailViewBorderArcs.ToArray) 
            Dim nErrs1 AsInteger=Nothing
            nErrs1 = theSession.UpdateManager.DoUpdate(markId1) 
            displayModification1.Dispose()EndIf 
        lw.Close() 
    EndSub 
    Function EvaluateText(ByVal someNote As Annotations.NoteBase)AsString 
        Dim aT As Annotations.AssociativeText= theSession.Parts.Work.Annotations.CreateAssociativeText()Dim cData As Annotations.ComponentData= theSession.Parts.Work.Annotations.CreateComponentData(someNote) 
        ForEach tC As Annotations.TextComponentIn cData.GetTextComponentsReturn aT.GetEvaluatedText(someNote, tC.GetText(0))Next 
        ReturnNothing 
    EndFunction 
 
EndModule 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
'NXJournaling.com'February 19, 2019'This class helps get objects related to a detail view (circular view border and label on parent) that the detail view builder does not provide access to.'Use the "New" method and pass in either the detail view itself OR the border arc (the arc drawn on the parent view representing the detail view border).'The class will gather info and provide it through the following read only properties:'  DetailViewName   the name of the detail view'  ParentView       the view the detail view is taken from'  CenterPoint      the center point of the circular boundary (in parent view)'  BoundingPoint1   the first bounding point defining the detail view boundary (same as center point for circular detail views)'  BoundingPoint2   the second bounding point defining the detail view boundary (for circular detail views this point is on the circumference of the defining arc)'  BorderArc        the border arc on the parent view (returns Nothing if the label on parent type is set to "none")'  LabelOnParent    the label on the border arc, returns nothing if there is no label on the parent (label on parent display option: none, circle, boundary) 
'Update January 28, 2020'Add code to return the label on parent, given the detail view 
'March 31, 2021'If the .LabelOnParent type is set to "none", return "nothing" for the label 
 
 
'Required imports'Imports System'Imports System.Collections.Generic'Imports NXOpen'Imports NXOpen.UF 
 
PublicClass NXJ_DetailViewInfo
 
#Region "Private variables"Private _theSession As Session = Session.GetSessionPrivate _theUfSession As UFSession = UFSession.GetUFSession()Private lg As LogFile = _theSession.LogFile 
    Private lw As ListingWindow = _theSession.ListingWindowPrivate _theDetailView As Drawings.DetailView 
#End Region
 
    Private _detailViewName AsString=""PublicReadOnlyProperty DetailViewName()AsStringGetReturn _detailViewName
        EndGetEndProperty 
    Private _parentView As Drawings.DraftingViewPublicReadOnlyProperty ParentView()As Drawings.DraftingViewGetReturn _parentView
        EndGetEndProperty 
    Private _centerPt As Point3d =NothingPublicReadOnlyProperty CenterPoint()As Point3d
        GetReturn _centerPt
        EndGetEndProperty 
    Private _boundPt1 As Point3d =NothingPublicReadOnlyProperty BoundingPoint1()As Point3d
        GetReturn _boundPt1
        EndGetEndProperty 
    Private _boundPt2 As Point3d =NothingPublicReadOnlyProperty BoundingPoint2()As Point3d
        GetReturn _boundPt2
        EndGetEndProperty 
    Private _borderArc As Arc =NothingPublicReadOnlyProperty BorderArc()As Arc
        GetReturn _borderArc
        EndGetEndProperty 
    Private _labelOnParent As Annotations.Label=NothingPublicReadOnlyProperty LabelOnParent()As Annotations.LabelGetReturn _labelOnParent
        EndGetEndProperty 
    PublicSubNew(ByVal theDetailView As Drawings.DetailView)
        lg.WriteLine("Sub New, given detail view") 
        _theDetailView = theDetailView
        _detailViewName = theDetailView.Name'given the view, return the border arcMe.GetViewBounds(theDetailView) 
        'The border arc (of a circular detail view) will be an arc where one of the smart object parents'will be the parent view of the detail view and the arc center will match _centerPt (within modeling tolerance).
        _borderArc =Me.FindBorderArc() 
        Me.GetLabelOnParent() 
    EndSub 
    PublicSubNew(ByVal theBorderArc As Arc)
        lg.WriteLine("Sub New, given the detail border arc")
        _borderArc = theBorderArc
 
        'given the border arc, return the detail viewDim theDetailView As Drawings.DetailView=Me.FindDetailView(_borderArc)If IsNothing(theDetailView)Then
            _detailViewName =""Else
            _detailViewName = theDetailView.Name
            _theDetailView = theDetailView
            Me.GetViewBounds(theDetailView)Me.GetLabelOnParent() 
        EndIf 
    EndSub 
    PrivateSub GetViewBounds(ByVal theDetailView As Drawings.DetailView)
        lg.WriteLine("GetViewBounds") 
        Dim detailViewBuilder1 As Drawings.DetailViewBuilder= _theSession.Parts.Work.DraftingViews.CreateDetailViewBuilder(theDetailView)'lw.WriteLine("label on parent: " & detailViewBuilder1.LabelOnParent.ToString)
        lg.WriteLine("parent view: "& detailViewBuilder1.Parent.View.Value.Name)
        lg.WriteLine("boundary point 1: "& detailViewBuilder1.BoundaryPoint1.Coordinates.ToString)'lw.WriteLine("boundary point 2: " & detailViewBuilder1.BoundaryPoint2.Coordinates.ToString)
        _boundPt1 = detailViewBuilder1.BoundaryPoint1.Coordinates
        _boundPt2 = detailViewBuilder1.BoundaryPoint2.Coordinates 
        If detailViewBuilder1.Type= Drawings.DetailViewBuilder.Types.CircularThen
            _centerPt = detailViewBuilder1.BoundaryPoint1.CoordinatesEndIf 
        _parentView = detailViewBuilder1.Parent.View.Value 
        detailViewBuilder1.Destroy() 
        lg.WriteLine("Exiting GetViewBounds")
        lg.WriteLine("")EndSub 
    PrivateFunction FindBorderArc()As Arc
        lg.WriteLine("FindBorderArc") 
        'TO DO: make sure arc is not view dependent'  the "view boundary" arc around the actual detail view is view dependent in the detail view,'  this is NOT the border arc we are looking for (the arc on the parent view that represents what the detail view shows). 
        ForEach tempArc As Arc In _theSession.Parts.Work.ArcsDim arcParents AsNew List(Of NXObject)
            GetSmartParents(tempArc, arcParents)ForEach tempParent As NXObject In arcParents
                IfTypeOf(tempParent)Is Drawings.DraftingViewThen 
                    lg.WriteLine("FindBorderArc: tempParent.Name: "& tempParent.Name)
                    lg.WriteLine("FindBorderArc: _parentView.Name: "& _parentView.Name)
                    lg.WriteLine("FindBorderArc: tempParent.Tag: "& tempParent.Tag.ToString)
                    lg.WriteLine("FindBorderArc: _parentView.Tag: "& _parentView.Tag.ToString) 
                    If tempParent.Name<> _parentView.NameThen
                        lg.WriteLine("tempParent.Name <> _parentView.Name")'this is not the arc we are looking for'move along...ContinueForEndIf 
                    'if we get here, the view names match'so far, so good
                    lg.WriteLine("view names match, checking points")If Point3dEqual(tempArc.CenterPoint, _centerPt)Then
                        lg.WriteLine("points match, returning tempArc")'parent views match and center points match'this is it'_borderArc = tempArcReturn tempArc
                    Else
                        lg.WriteLine("points do not match, check next parent")EndIf 
                EndIfNext'lw.WriteLine("")Next 
        'no more arcs, no matches found
        lg.WriteLine("border arc = nothing")'_borderArc = NothingReturnNothing 
        lg.WriteLine("Exiting FindBorderArc")
        lg.WriteLine("")EndFunction 
    PrivateSub GetSmartParents(ByRef theSmartObject As NXObject, ByRef theParentList As List(Of NXObject)) 
        Dim numParents AsIntegerDim theParentTags()As Tag =NothingDim isSmart AsBoolean=False 
        Try
            _theUfSession.So.IsSo(theSmartObject.Tag, isSmart)If isSmart Then'lw.WriteLine("object is smart: " & theSmartObject.Tag.ToString)
                _theUfSession.So.AskParents(theSmartObject.Tag, UFConstants.UF_SO_ASK_ALL_PARENTS, numParents, theParentTags) 
                ForEach tempTag As Tag In theParentTags
                    Dim objParent As NXObject = Utilities.NXObjectManager.Get(tempTag)'lw.WriteLine("adding " & objParent.GetType.ToString & " to parent list")
                    theParentList.Add(objParent) 
                    GetSmartParents(objParent, theParentList) 
                Next 
            Else'lw.WriteLine("object not smart: " & theSmartObject.Tag.ToString)EndIf 
        Catch ex As NXException
            'lw.WriteLine("error: " & ex.ErrorCode)'lw.WriteLine("  " & ex.Message)EndTry 
    EndSub 
    PrivateFunction Point3dEqual(ByVal pt1 As Point3d, ByVal pt2 As Point3d)AsBoolean 
        If IsNothing(pt1)OrElse IsNothing(pt2)ThenReturnFalseEndIf 
        Dim modelingTolerance AsDouble
        _theUfSession.Modl.AskDistanceTolerance(modelingTolerance) 
        lg.WriteLine("modeling distance tolerance: "& modelingTolerance.ToString) 
        If Math.Abs(pt1.X- pt2.X)> modelingTolerance Then
            lg.WriteLine("X distance exceeds modeling tolerance")ReturnFalseEndIf 
        If Math.Abs(pt1.Y- pt2.Y)> modelingTolerance Then
            lg.WriteLine("Y distance exceeds modeling tolerance")ReturnFalseEndIf 
        If Math.Abs(pt1.Z- pt2.Z)> modelingTolerance Then
            lg.WriteLine("Z distance exceeds modeling tolerance")ReturnFalseEndIf 
        lg.WriteLine("points equal withing modeling distance tolerance")ReturnTrue 
    EndFunction 
    PrivateFunction FindDetailView(ByVal theBorderArc As Arc)As Drawings.DetailView 
        ForEach tempView As Drawings.DraftingViewIn _theSession.Parts.Work.DraftingViewsIfNotTypeOf(tempView)Is Drawings.DetailViewThen'only process detail viewsContinueForEndIf 
            Me.GetViewBounds(tempView)Dim tempBorderArc As Arc
            tempBorderArc =Me.FindBorderArcIf IsNothing(tempBorderArc)ThenContinueForEndIf 
            If theBorderArc.Equals(tempBorderArc)ThenReturn tempView
            EndIf 
        Next 
        ReturnNothing 
    EndFunction 
    PrivateSub GetLabelOnParent()'Get label on parent from detail view'nx_api6015 
        Dim myChildList AsNew List(Of NXObject) 
        Dim numChildren AsIntegerDim childTags()As Tag =Nothing 
        _theUfSession.So.AskChildren(_theDetailView.Tag, UFConstants.UF_SO_ASK_ALL_CHILDREN, numChildren, childTags)ForEach tempTag As Tag In childTags
            Dim someObj As NXObject = Utilities.NXObjectManager.Get(tempTag)
            myChildList.Add(someObj)Next 
        ForEach obj As NXObject In myChildList
            'lw.WriteLine("object: " & obj.GetType.ToString)IfTypeOf(obj)Is Annotations.LabelThen
                _labelOnParent = obj
            EndIfNext 
    EndSub 
EndClass

Viewing all articles
Browse latest Browse all 19

Latest Images

Trending Articles





Latest Images