cancel
Showing results for 
Search instead for 
Did you mean: 

NXOpen Python changing the color of all breps

Experimenter
Experimenter

Hello there.

Somehow I dont manage to select imported 3d data and assign a specific color to it:

        workPart = theSession.Parts.Work

        allbreps = []
        for feat in workPart.Features:
            if feat.FeatureType == "BREP":
                allbreps.append(feat)

            else:
                continue

        displayModification1 = theSession.DisplayManager.NewDisplayModification()
        displayModification1.ApplyToAllFaces = True    
        displayModification1.ApplyToOwningParts = False
        displayModification1.NewColor = 186
        displayModification1.Apply(allbreps)

The code gives me the following error message: TypeError. Expeting List of NXOpen.DisplayableObject type, found NXOpen.Features.Brep

Can someone point me in the right direction what to do?

 

Thanks in advance.

6 REPLIES

Re: NXOpen Python changing the color of all breps

Siemens Phenom Siemens Phenom
Siemens Phenom

 

That error message is telling you that you need to get the underlying geometry, and set the color on the geometry object, rather than trying to set it on the feature.

 

Re: NXOpen Python changing the color of all breps

Honored Contributor
Honored Contributor

Your feat variable is a reference to a feature object; try using feat.GetEntities to get the geometry that the feature created. This should get you a reference to the underlying geometry as @SteveLabout suggested.

Re: NXOpen Python changing the color of all breps

Experimenter
Experimenter

as in :

        for feat in workPart.Features:
            if feat.FeatureType == "BREP":
                allbreps.append(feat.GetEntities())
            else: continue

but that gets me emty lists in "allbreps" and it isn't working either. Or do you mean something else?

I guess, I still dont get it...

Re: NXOpen Python changing the color of all breps

Siemens Phenom Siemens Phenom
Siemens Phenom

 

You might try GetBodies() instead of GetEntities().  Bodies should certainly be displayable.

Re: NXOpen Python changing the color of all breps

Experimenter
Experimenter

It worked.

That was great wisdom. Thanks for your help.

 

Re: NXOpen Python changing the color of all breps

Siemens Phenom Siemens Phenom
Siemens Phenom

In the "Getting Started with SNAP" guide, there is a section in chapter 10 entitled "Feature Display Properties'. The way these properties work in SNAP is a little different from in NX/Open, but there are many similarities, too, so the material might be useful.

山田
yamada