Cancel
Showing results for 
Search instead for 
Did you mean: 

The curves belong to a specific sketch rather than all the curves in a session

Valued Contributor
Valued Contributor

Hello,

How can I get only the curves belong to a specific sketch rather than all the curves in a session?

Thanks

 

Dim curves = theSession.Parts.Work.Curves
For Each targetCurves As Curve In curves
.....

next

 

10 REPLIES 10

Re: The curves belong to a specific sketch rather than all the curves in a session

The Sketch class has a GetAllGeometry function.

 

https://docs.plm.automation.siemens.com/data_services/resources/nx/11/nx_api/custom/en_US/nxopen_pyt...

 

You could use that and then filter out all non-curves.

Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX12 | CentOS7 | Python

Re: The curves belong to a specific sketch rather than all the curves in a session

Valued Contributor
Valued Contributor

@NikolasLosse

 

I tried like below but "GetAllGeometry " is not a member of features.feature

 

 

 

   For Each targetSketch As features.feature In workPart.Features
            If targetSketch.name = "PARCA" Then
                parcaSketch = targetSketch
                MsgBox(parcaSketch.tag)
                Exit For
            End If
        Next

        For Each abc As Curve In parcaSketch.getallgeometries
            lw.WriteLine(abc.Tag)
        Next

Re: The curves belong to a specific sketch rather than all the curves in a session

Yes, there is a Sketch class and a SketchFeature class. You got the SketchFeature class. You can get the Sketch from that with feature.Sketch.

 

So in your case parcaSketch.Sketch.GetAllGeometries()

Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX12 | CentOS7 | Python

Re: The curves belong to a specific sketch rather than all the curves in a session

Valued Contributor
Valued Contributor

@NikolasLosse

am I doing wrong?

 

e1.jpg

Highlighted

Re: The curves belong to a specific sketch rather than all the curves in a session

Don't know what you are using, but maybe your autocomplete only shows you the functions without a return value because your line is not something like xyz = parcaSketch.Sketch ?

Nikolas Losse | Developer | Siemens PG PR R&D TEC
NX12 | CentOS7 | Python

Re: The curves belong to a specific sketch rather than all the curves in a session

Creator
Creator

try to typecast feature type to sketchFeature type. then you will be able to get sketch from intellisense.

 

Regards,

Gowtham

Re: The curves belong to a specific sketch rather than all the curves in a session

Valued Contributor
Valued Contributor

When I start to write ".sk" it brings me other things rather than "Sketch". That means I could not cast properly.

Re: The curves belong to a specific sketch rather than all the curves in a session

Creator
Creator

That means, that variable is still a feature type, so you won't ba able to see it unless you cast it to sketchFeature.

In vb, you have to manually cast it to particular feature type. Since, it is a sketch, you will be able to cast it to sketchFeature.

Re: The curves belong to a specific sketch rather than all the curves in a session

Gears Esteemed Contributor Gears Esteemed Contributor
Gears Esteemed Contributor
Every part has a sketch collection that you can use to quickly narrow your search. I suggest iterating through the sketch collection rather than the feature collection in this case.