Submitted by quicova@gmail.com on Tue, 12/13/2016 - 02:40
Forums:
Hello,
I'm trying to create a script to project all sheet edges from a group of surfaces that are in a feature group onto a surface.
I'm strolling to access the features inside a group.
I know the group name as a string and the destination surface name as a string. Now I'm trying to loop through all the features inside the group, and if the feature is a sheet project its edges.
I was trying to use:
.AskSetFromName to access the group and them use
.IsFeatureASetMember or .AskAllMembersOfSet to loop through the group and project the sheet edges if the feature is a sheet.
But I can't use any of the group functions, i always get a errors.
hope you can help me
cheers
kico
re: features in group
The code below shows how to access the features contained within a feature group.
Option Strict Off
Imports System
Imports System.Collections.Generic
Imports NXOpen
Imports NXOpen.UF
Module Module2
Sub Main()
Dim theSession As Session = Session.GetSession()
Dim theUfSession As UFSession = UFSession.GetUFSession
If IsNothing(theSession.Parts.Work) 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 = "NXJ feature group"
Dim markId1 As Session.UndoMarkId
markId1 = theSession.SetUndoMark(Session.MarkVisibility.Visible, undoMarkName)
For Each tempFeat As Features.Feature In workPart.Features
If TypeOf (tempFeat) Is Features.FeatureGroup Then
lw.WriteLine("Feature Group: " & tempFeat.GetFeatureName)
Dim numFeatures As Integer
Dim setFeatureTags() As Tag
theUfSession.Modl.AskAllMembersOfSet(tempFeat.Tag, setFeatureTags, numFeatures)
Dim setFeatures As New List(Of Features.Feature)
'get features from tags
For Each tempTag As Tag In setFeatureTags
setFeatures.Add(Utilities.NXObjectManager.Get(tempTag))
Next
For Each setFeat As Features.Feature In setFeatures
lw.WriteLine(" " & setFeat.GetFeatureName)
Next
lw.WriteLine("")
End If
Next
lw.Close()
End Sub
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 Module
access features of a selected group
hi NXJournaling, how do i access only the feature type 'Text' in a user defined feature group. I need to browse through all the feature group and get only the features from a single feature group of my interest. Im able to narrow down the search to the feature type 'Text' but the journal selects from all the feature group. Thanks, B
Balaji