AskDisplayedObjects

Hello
I have a question about


Public Function CreateSetRender()

Dim listTag As Tag() = Nothing
Dim objCounter As Integer

Dim mviews As ModelingViewCollection = workPart.ModelingViews
Dim topView As NXOpen.ModelingView = Nothing
For Each mv As ModelingView In mviews
If mv.Name.Equals("Top") Then
topView = mv
End If
Next

ufs.Draw.AskDisplayedObjects(topView.Tag, objCounter, listTag)

Return Nothing
End Function

I have an error "view is not a view of element"

I need use AskDisplayedObjects for get "list of tags" to SetRenderSetObjects.


public void SetRenderSetObjects(
Tag render_set,
int number_objects,
Tag[] objects
)

Help!

The ufs.Draw.AskDsplayedObjects() method is meant to be used with drawing views. The modeling views have a method named: AskVisibleObjects() that will return the visible objects in the given view. The view itself will need to be visible for the method to work.

Dim visibleObjects() As DisplayableObject = Nothing

Dim mviews As ModelingViewCollection = theSession.Parts.Work.ModelingViews
Dim topView As NXOpen.ModelingView = Nothing
For Each mv As ModelingView In mviews
If mv.Name.Equals("Top") Then
topView = mv
theSession.Parts.Work.Layouts.Current.ReplaceView(theSession.Parts.Work.ModelingViews.WorkView, topView, True)
End If
Next

visibleObjects = topView.AskVisibleObjects()

I know, but I need TAG[] list to setrenderset().
AksVisibleObjects returns array of objects and I don't know how to convert them to list of tags.

In the bodies I have an attribiute called "TypeDetail" with value "Electrode"(string).
I cycle by all assembly to search each body with that attribute (TypeDetail=Electrode) and set previously defined renderset to them.

file/Preferences/Drafting/View/Common/General/Render Sets/Define (NX 10)

Regards

AskVisibleObjects returns an array of DisplayableObjects. A displayable object has a .Tag property that you can make use of.

One way to get an array of tags would be to create an array of tags of the same size as the array returned by AskVisibleObjects then loop through the visible objects, adding its tag to the tag array.

something like:

dim tagArray(visObjs.Length-1) as tag

for i as integer = 0 to visObjs.Length-1
tagArray(i) = visObjs(i).Tag
next i

Done !

Thank You for help. I can finish the script now.
I have:
cycle for attributes in assembly,
counting Electrode in assembly,
creating separate arrangements for each Electrode with Detail in assembly,
set renderset to Detail (black), Electrode(red),
create drawing sheet for every Electrode with Detail,
create views with arrangemet.
Left:
automatic dimmensions.

Here is a code to setRendersetObjects and get visible object type "Body".


Option Strict Off
Imports NXOpen
Imports NXOpen.Drawings
Imports NXOpen.UF
Imports NXOpenUI
Imports System.Collections
Imports System
Imports NXOpen.Assemblies
Imports NXOpen.Utilities

Module Assembly
Public theSession As Session = Session.GetSession()
Public lw As ListingWindow = theSession.ListingWindow
Public workPart As Part = theSession.Parts.Work
Public ufs As UFSession = UFSession.GetUFSession

Sub Main()

Dim numberRender As Integer
Dim renderSets As Tag() = Nothing
Dim aSet As RenderSet
Dim mviews As ModelingViewCollection = theSession.Parts.Work.ModelingViews
Dim topView As NXOpen.ModelingView
Dim arrayBody As ArrayList = New ArrayList

ufs.Draw.AskRenderSets(numberRender, renderSets)

lw.Open()

For ii As Integer = 0 To numberRender - 1

aSet = NXObjectManager.Get(renderSets(ii))
lw.WriteLine("Found RenderSet " + ii.ToString + aSet.Name)
Next
Dim visibleObjects() As DisplayableObject

For Each mv As ModelingView In mviews
If mv.Name.Equals("Top") Then
topView = mv
theSession.Parts.Work.Layouts.Current.ReplaceView(theSession.Parts.Work.ModelingViews.WorkView, topView, True)
End If
Next

visibleObjects = topView.AskVisibleObjects()
Dim countBody As Integer = 0
Dim icount As Integer = 0
Dim tagCount As Integer

For Each obj As NXObject In visibleObjects
If obj.GetType.Name = "Body" Then
lw.WriteLine(obj.GetType.Name.ToString)
arrayBody.Add(obj)
countBody = countBody + 1
End If

Next

lw.WriteLine(countBody)
'lw.WriteLine(visibleObjects.Length)

Dim tagArray(countBody) As Tag

For i As Integer = 0 To countBody - 1
tagArray(i) = arrayBody(i).Tag
Next i

ufs.Draw.SetRenderSetObjects(renderSets(0), countBody, tagArray)

End Sub

End Module