cancel
Showing results for 
Search instead for 
Did you mean: 

Select waveSketches

Pioneer
Pioneer

Hello,

 

I tried to select wave sketches on a part.

I can't find (in .chm) right properties for this types of sketch.

 

Dim selectSketch = workPart.Sketches.ToArray

This one work great for "regular" sketch...

 

Best regards

 

Adrien

4 REPLIES

Re: Select waveSketches

Legend
Legend

I think you have to go through FeatureCollection and look for 'UF_sketch_type' and 'UF_extracted_sketch_subtype'.

Re: Select waveSketches

Honored Contributor
Honored Contributor

Below is a small journal that will write the work part's wave sketch feature names to the information window.

 

Option Strict Off
Imports System
Imports NXOpen
Imports NXOpen.UF

Module Module1

    Dim theSession As Session = Session.GetSession()
    Dim theUfSession As UFSession = UFSession.GetUFSession()

    Dim theUI As UI = UI.GetUI()
    Dim lw As ListingWindow = theSession.ListingWindow

    Sub Main()

        lw.Open()

        lw.WriteLine("work part sketches: " & theSession.Parts.Work.Sketches.ToArray.Length.ToString)

        For Each tempFeat As Features.Feature In theSession.Parts.Work.Features
            If TypeOf (tempFeat) Is Features.WaveSketch Then
                lw.WriteLine("wave sketch: " & tempFeat.GetFeatureName)
            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

Re: Select waveSketches

Pioneer
Pioneer

Hello,

 

Perfect this loop is works great Smiley Wink

 

Now, my goal is to move "tempFeat" (WaveSketch) on a specific layer.

 

I tried this but VS said " Value of type "DisplayableObject" cannot be converted to "displayableObject()"...

 

i trid to cast it, no success at all....

 

 

For Each tempFeat As Features.Feature In theSession.Parts.Work.Features
            If TypeOf (tempFeat) Is Features.WaveSketch Then
                lw.WriteLine("wave sketch: " & tempFeat.GetFeatureName)

                Dim i As DisplayableObject = workPart.Sketches.FindObject(tempFeat.GetFeatureName)

                displayPart.Layers.ApplyMoveToLayerToOwningParts(WaveSketchLayer, i)

            End If
        Next

Best regards

 

Adrien

 

 

 

Re: Select waveSketches

Honored Contributor
Honored Contributor

Try the following:

 

For Each tempFeat As Features.Feature In theSession.Parts.Work.Features
            If TypeOf (tempFeat) Is Features.WaveSketch Then
                lw.WriteLine("wave sketch: " & tempFeat.GetFeatureName)

                Dim i As DisplayableObject = tempFeat.GetEntities(0)

                displayPart.Layers.ApplyMoveToLayerToOwningParts(WaveSketchLayer, i)

            End If
Next

You can think of a Feature object as a container for the geometry that the feature creates (this isn't a perfect analogy, but it works in many cases), the .GetEntities method will return the object(s) created by the feature.