<commit_before>import pymel.core as pymel
import maya.mel as mel
from omtk.core.classCtrl import BaseCtrl
from omtk.core.classModule import Module
from omtk.libs import libPymel, libRigging, libSkinning

class CtrlRibbon(BaseCtrl):
    def build(self, *args, **kwargs):
        super(CtrlRibbon, self).build(*args, **kwargs)
        make = self.node.getShape().create.inputs()[0]
        make.radius.set(2)
        make.degree.set(1)
        make.sections.set(4)
        return self.node

class Ribbon(Module):
    def __init__(self, *args, **kwargs):
        super(Ribbon, self).__init__(*args, **kwargs)
        self.num_subdiv = None
        self.num_ctrl = None
        self.ctrls = []

    def build(self, rig, num_subdiv = 5, num_ctrl = 3, degree=1, create_ctrl=True, constraint=False, rot_fol=False, *args, **kwargs):
        super(Ribbon, self).build(rig, create_grp_anm=create_ctrl, *args, **kwargs)
        self.num_ctrl = num_ctrl

        nomenclature_anm = self.get_nomenclature_anm(rig)
        nomenclature_rig = self.get_nomenclature_rig(rig)

        #Create the plane and align it with the selected bones
        plane_tran = next((input for input in self.input if libPymel.isinstance_of_shape(input, pymel.nodetypes.NurbsSurface)), None)
        if plane_tran is None:
            plane_name = nomenclature_rig.resolve("ribbonPlane")
            plane_tran = libRigging.create_nurbs_plane_from_joints(self.chain_jnt, degree=degree)
            plane_tran.rename(plane_name)
            plane_tran.setParent(self.grp_rig)
        self._ribbon_shape = plane_tran.getShape()

        #Create the follicule needed for the system on the skinned bones
        for i, jnt in enumerate(self.chain_jnt):
            pymel.select(jnt, plane_tran)
            mel.eval("djRivet")
            #TODO : Support aim constraint for bones instead of follicle rotation?

        #Apply the skin on the plane and rename follicle from djRivet
        dj_rivet_grp = pymel.PyNode("djRivetX")
        follicle_grp_name = nomenclature_rig.resolve("follicle_grp")
        dj_rivet_grp.rename(follicle_grp_name)
        dj_rivet_grp.setParent(self.grp_rig)
        self._follicles = dj_rivet_grp.getChildren()
        for n in self._follicles:
            fol_name = nomenclature_rig.resolve("fol")
            n.rename(fol_name)

        # Create the joints that will drive the ribbon.
        # TODO: Support other shapes than straight lines...
        # TODO: Support ctrl hold/fetch when building/unbuilding.
        self._ribbon_jnts = libRigging.create_chain_between_objects(
            self.chain_jnt.start, self.chain_jnt.end, self.num_ctrl, parented=False)

        # Group all the joints<commit_msg>Expose width parameter in the ribbon<commit_after>import pymel.core as pymel
import maya.mel as mel
from omtk.core.classCtrl import BaseCtrl
from omtk.core.classModule import Module
from omtk.libs import libPymel, libRigging, libSkinning

class CtrlRibbon(BaseCtrl):
    def build(self, *args, **kwargs):
        super(CtrlRibbon, self).build(*args, **kwargs)
        make = self.node.getShape().create.inputs()[0]
        make.radius.set(2)
        make.degree.set(1)
        make.sections.set(4)
        return self.node

class Ribbon(Module):
    def __init__(self, *args, **kwargs):
        super(Ribbon, self).__init__(*args, **kwargs)
        self.num_subdiv = None
        self.num_ctrl = None
        self.ctrls = []
        self.width = 1.0

    def build(self, rig, num_subdiv = 5, num_ctrl = 3, degree=1, create_ctrl=True, constraint=False, rot_fol=False, *args, **kwargs):
        super(Ribbon, self).build(rig, create_grp_anm=create_ctrl, *args, **kwargs)
        self.num_ctrl = num_ctrl

        nomenclature_anm = self.get_nomenclature_anm(rig)
        nomenclature_rig = self.get_nomenclature_rig(rig)

        #Create the plane and align it with the selected bones
        plane_tran = next((input for input in self.input if libPymel.isinstance_of_shape(input, pymel.nodetypes.NurbsSurface)), None)
        if plane_tran is None:
            plane_name = nomenclature_rig.resolve("ribbonPlane")
            plane_tran = libRigging.create_nurbs_plane_from_joints(self.chain_jnt, degree=degree, width=self.width)
            plane_tran.rename(plane_name)
            plane_tran.setParent(self.grp_rig)
        self._ribbon_shape = plane_tran.getShape()

        #Create the follicule needed for the system on the skinned bones
        for i, jnt in enumerate(self.chain_jnt):
            pymel.select(jnt, plane_tran)
            mel.eval("djRivet")
            #TODO : Support aim constraint for bones instead of follicle rotation?

        #Apply the skin on the plane and rename follicle from djRivet
        dj_rivet_grp = pymel.PyNode("djRivetX")
        follicle_grp_name = nomenclature_rig.resolve("follicle_grp")
        dj_rivet_grp.rename(follicle_grp_name)
        dj_rivet_grp.setParent(self.grp_rig)
        self._follicles = dj_rivet_grp.getChildren()
        for n in self._follicles:
            fol_name = nomenclature_rig.resolve("fol")
            n.rename(fol_name)

        # Create the joints that will drive the ribbon.
        # TODO: Support other shapes than straight lines...
        # TODO: Support ctrl hold/fetch when building/unbuilding.
        self._ribbon_jnts = libRigging.create_chain_between_objects(
            self.chain_jnt.start, self.chain_jnt.end, self.num_ctrl, parented=False)

        # Group all the joints
{'fraction_non_alphanumeric': 0.092802338326635, 'fraction_numerical': 0.0029229082937522835, 'mean_word_length': 2.9587852494577005, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4312181', 'n_tokens_mistral': 1838, 'n_tokens_neox': 1779, 'n_words': 397}