Cancel
Showing results for 
Search instead for 
Did you mean: 

Error: This operation can only be done on the display part

Pioneer
Pioneer

I am trying to loop through an assembly, display the part, and set the RenderingStyleType to be ShadedWithEdges. However, when I apply the 

NXOpen.View.RenderingStyleType.ShadedWithEdges

It returns "This operation can only be done on the display part".  I tried to have a code to make the child to be a work component but it still fails. Any suggestion will be appreciated.

 

        Dim c As ComponentAssembly = dispPart.ComponentAssembly
        Dim comp As Component = c.RootComponent

        For Each child As Component In comp.GetChildren()
            Dim partLoadStatus1 As PartLoadStatus = Nothing
            Dim status1 As PartCollection.SdpsStatus
            Dim part1 As NXOpen.Part = CType(theSession.Parts.FindObject(child.Name), NXOpen.Part)

            'theSession.Parts.SetWorkComponent(child, NXOpen.PartCollection.RefsetOption.Entire, NXOpen.PartCollection.WorkComponentOption.Visible, partLoadStatus1)
            status1 = theSession.Parts.SetDisplay(part1, True, True, partLoadStatus1)
            workPart.ModelingViews.WorkView.RenderingStyle = NXOpen.View.RenderingStyleType.ShadedWithEdges
            partLoadStatus1.Dispose()
        Next
1 REPLY

Re: Error: This operation can only be done on the display part

PLM World Member Legend PLM World Member Legend
PLM World Member Legend

Please try with the below code sample. Hope, it'll works for your problem.

Dim workPart as Part = theSession.Parts.Work

Dim loadStatus As NXOpen.PartLoadStatus = Nothing
Dim root As Assemblies.Component = theSession.Parts.Display.ComponentAssembly.RootComponent

For Each comp As Assemblies.Component In root.GetChildren()
Try
Dim currentPrt As Part = comp.Prototype
theSession.Parts.SetDisplay(currentPrt, False, True, loadStatus)

currentPrt.ModelingViews.WorkView.RenderingStyle = View.RenderingStyleType.ShadedWithEdges
Catch ex As Exception
Echo(ex.Message)
End Try
Next

theSession.Parts.SetDisplay(workPart, False, True, loadStatus)
loadStatus.Dispose()

The reason for the error message 'This operation can only be done on the display part' is that you are not properly setting the display part in an assembly.