Continue to Site

Eng-Tips is the largest engineering community on the Internet

Intelligent Work Forums for Engineering Professionals

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

NX Journal - Only keep visible objects in an NXObject list 1

Status
Not open for further replies.

jmarkus

Mechanical
Jul 11, 2001
377
I have a VB.NET journal which is gathering all the entities on a layer and putting them into a list of NXObject.

I want to loop through the list and remove the objects that are not not visible on the active drawing sheet. There are other drawing sheets in the part file and I don't want to include any objects on those sheets. I'm guessing I need to convert the NXObjects to Displayable objects and then check if the entity is visible since if they are not visible they must reside on the other sheets. I don't know how to check that.

Code:
Dim theObjects As New List(Of NXObject)
Dim VisObj As DisplayableObject

theObjects.AddRange(workPart.Layers.GetAllObjectsOnLayer(253))

For Each obj As NXObject In theObjects
[indent]try[/indent]
[indent][indent]VisObj=CType(obj, DisplayableObject)[/indent][/indent]
[indent][indent]'If VisObj is not visible then[/indent][/indent]
[indent][indent][indent]theObjects.Remove(obj)[/indent][/indent][/indent]
[indent][indent]End If[/indent][/indent]
[indent]end try[/indent]
Next

Any suggestions?

Thanks,
Jeff

 
Replies continue below

Recommended for you

Years ago, I found a function on GTAC that reports what drawing sheet an object is on. Hopefully it will help in your situation.

Code:
Function AskDrawingSheet(ByVal theObject As TaggedObject) As Drawings.DrawingSheet
    'Code written by Amy Webster of GTAC
    ' see nx_api4936 or nx_api4937
    ' This function will work for:
    '     an object which "Resides on drawing" or is "View Dependent In" a DraftingView
    '     a DraftingView
    '     a DrawingSheet.View
    ' Returns Nothing for all other (ie. model mode) objects

    Dim theView As View = TryCast(theObject, View)
    If Not theView Is Nothing Then
        Dim sheetTag As Tag = Nothing
        Try
            theUfSession.Draw.AskDrawingOfView(theView.Tag, sheetTag)
            Return Utilities.NXObjectManager.Get(sheetTag) ' the drawing it is on
        Catch ex As NXException
            Return Nothing  ' it is a model view
        End Try
    End If

    Dim viewName As String = Nothing
    Dim status As Integer = Nothing
    Try
        theUfSession.View.AskViewDependentStatus(theObject.Tag, status, viewName)
    Catch ex As NXException
        Return Nothing
    End Try
    If status = 0 Then Return Nothing ' it is a model mode object

    Dim viewTag As Tag = Nothing
    theUfSession.View.AskTagOfViewName(viewName, viewTag)
    Dim viewType As Integer = Nothing
    Dim viewSubtype As Integer = Nothing
    theUfSession.View.AskType(viewTag, viewType, viewSubtype)
    If viewType = 0 Then Return Nothing ' it is view dependent in a modeling view

    Dim drawingTag As Tag = Nothing
    theUfSession.Draw.AskDrawingOfView(viewTag, drawingTag)
    Return Utilities.NXObjectManager.Get(drawingTag)  ' the drawing it is on!

End Function

www.nxjournaling.com
 
Another great suggestion Cowski!

Thanks,
Jeff
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor