Mini Script #07 - Hypernurb Disabler
C4D Mini Script #07 - Hypernurb Manager
 
 
Description

Very simple script helps you enable and disable all hypernurbs in your scene. If you forget to switch back on the hypernurbs and close the script window, it will automatically revert the hypernurbs back to what it was before.
 
Do not worry if you have some hypernurbs are are already disabled, it will not affect those.
One of the first scripts I wrote.
 
 
import c4d
from c4d import gui
 
class hypernurbManager(gui.GeDialog):
 
    def __init__(self):
    

        # declaring class specific variables
        self.hypernurbList = []
        
        self.storeNurbs()
        
        self.disableNurbs()

    def enableNurbs(self):
        

        # enable nurbs in nurblist
        for nurb in self.hypernurbList:
            nurb[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = 1
        return True
 
    def disableNurbs(self):
        

        # disable nurbs in nurblist
        for nurb in self.hypernurbList:
            nurb[c4d.ID_BASEOBJECT_GENERATOR_FLAG] = 0
        c4d.EventAdd()
        return True
    
    def InitValues(self):
        

        # initiate the gadgets with values if nec
        return True
 
    def Command(self, id, msg):
        

        # close window
        if id == 4001:
            self.enableNurbs()
            c4d.EventAdd()
            
        elif id == 4002:
            self.disableNurbs()
            c4d.EventAdd()
            
        c4d.EventAdd()
        return True
        
    def getNextObject(self, obj):
        

        # cycle through all objects
        if obj == None: 
            return None
        
        if obj.GetDown(): return obj.GetDown()
        
        while not obj.GetNext() and obj.GetUp():
            obj = obj.GetUp()
        
        return obj.GetNext()
 
    def storeNurbs(self):
        

        # clear nurb list
        self.hypernurbList = []
        
        eachObj = doc.GetFirstObject()
        

        # keep cycling while next object exists
        while eachObj:
            

            # check if obj is hypernurbs
            if eachObj.GetType() == 1007455:
                

                # check if hypernurbs is on
                if eachObj[c4d.ID_BASEOBJECT_GENERATOR_FLAG] == 1:
                    

                    # append to list
                    self.hypernurbList.append(eachObj)
                    

            # get next object in OM
            eachObj = self.getNextObject(eachObj)
        return True
    
    def AskClose(self):
        
        self.Command(4001,True)
        return False
    
    def CreateLayout(self):
        
        self.SetTitle("Hypernurb Manager")
        self.GroupBegin(1000,c4d.BFH_SCALEFIT, 1, 1 )
        self.AddSeparatorH(400)
        self.AddButton(4001,c4d.BFH_CENTER,300,20,"Enable Previous Nurbs")
        self.AddButton(4002,c4d.BFH_CENTER,300,20,"Disable Previous Nurbs")
        self.AddSeparatorH(400)
        
        return True
        
HNM = hypernurbManager()
HNM.Open(pluginid=1031088,dlgtype=c4d.DLG_TYPE_ASYNC, defaultw=1, defaulth=1)
Mini Script #07 - Hypernurb Disabler
3
111
0
Published:

Mini Script #07 - Hypernurb Disabler

Script for managing Hypernurbs in your Cinema 4D scene
3
111
0
Published:

Creative Fields