I wish to have curve,points,surface,axis selcting and appying layer and color

I’m looking for a code that lets the user manually select curves, surfaces, points, axes, and planes, and then automatically assigns them a specific color and layer through the script

Check out the selectionManager.SelectTaggedObjectWithFilterMembers.
You can input a list of filtermembers, which allow you to specify that the user can only select curves, axes, planes etc.

You can then use NXOpen.DisplayModification to set color and layer.

example in python:


import NXOpen
import NXOpen.Select

def main() : 

    # get the opened session and parts
    theSession  = NXOpen.Session.GetSession()
    theUI = NXOpen.UI.GetUI()
    sel = theUI.SelectionManager
    dispManager = theSession.DisplayManager
    
    # add an undo mark
    theSession.SetUndoMark(NXOpen.Session.MarkVisibility.Visible,'Objects to Layer/Color')
    
    #what members to add to the selection filter
    filterMembers = [NXOpen.Select.FilterMember.AllCurves,
                                NXOpen.Select.FilterMember.AllFaces,
                                NXOpen.Select.FilterMember.DatumPlane,
                                NXOpen.Select.FilterMember.Point,
                                NXOpen.Select.FilterMember.DatumAxis
                                ]
    
    # open a selection window
    response, objects = sel.SelectTaggedObjectsWithFilterMembers("select objects",
                                                    "select objects",
                                                    NXOpen.Selection.SelectionScope.UseDefault,
                                                    NXOpen.Selection.SelectionAction.ClearAndEnableSpecific,
                                                    filterMembers
                                                    )
    
    if response != NXOpen.Selection.Response.Ok:
        #if any other response than OK, quit the script
        return
    
    # make sure every object in objects is a DisplayableObject
    objects = [o for o in objects if isinstance(o, NXOpen.DisplayableObject)]
    
    #get a displaymodification object
    dispModification = dispManager.NewDisplayModification()
    dispModification.NewColor = 186     # red
    dispModification.NewLayer = 42
    #apply color and layer to all objects
    dispModification.Apply(objects)
    dispModification.Dispose()

if __name__ == '__main__':
    main()