Skip to content

create_fbx

Creator plugins for FBX, like static mesh and model products

CreateFBX

Bases: HoudiniCreator

Model as FBX.

Source code in client/ayon_houdini/plugins/create/create_fbx.py
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
class CreateFBX(plugin.HoudiniCreator):
    """Model as FBX."""

    identifier = "io.ayon.creators.houdini.model.fbx"
    label = "model (FBX)"
    product_type = "model"
    icon = "cube"
    default_variants = ["Main"]

    # Default render target
    render_target = "local"

    def get_publish_families(self):
        return ["fbx", "model"]

    def create(self, product_name, instance_data, pre_create_data):

        instance_data.update({"node_type": "filmboxfbx"})
        creator_attributes = instance_data.setdefault(
            "creator_attributes", dict())
        creator_attributes["render_target"] = pre_create_data["render_target"]

        instance = super().create(
            product_name,
            instance_data,
            pre_create_data)

        # get the created rop node
        instance_node = hou.node(instance.get("instance_node"))

        # prepare parms
        output_path = hou.text.expandString(
            "$HIP/pyblish/{}.fbx".format(product_name)
        )

        parms = {
            "startnode": self.get_selection(),
            "sopoutput": output_path,
            # vertex cache format
            "vcformat": pre_create_data.get("vcformat"),
            "convertunits": pre_create_data.get("convertunits"),
            # set render range to use frame range start-end frame
            "trange": 1,
            "createsubnetroot": pre_create_data.get("createsubnetroot"),
            "exportkind": pre_create_data.get("exportkind")
        }

        # set parms
        instance_node.setParms(parms)

        # Lock any parameters in this list
        to_lock = ["productType", "id"]
        self.lock_parameters(instance_node, to_lock)

    def get_network_categories(self):
        return [
            hou.ropNodeTypeCategory(),
            hou.objNodeTypeCategory(),
            hou.sopNodeTypeCategory()
        ]

    def get_instance_attr_defs(self):
        render_target_items = {
            "local": "Local machine rendering",
            "local_no_render": "Use existing frames (local)",
            "farm": "Farm Rendering",
        }

        return [
            EnumDef("render_target",
                    items=render_target_items,
                    label="Render target",
                    default=self.render_target)
        ]

    def get_pre_create_attr_defs(self):
        """Add settings for users. """

        attrs = super().get_pre_create_attr_defs()
        createsubnetroot = BoolDef("createsubnetroot",
                                   tooltip="Create an extra root for the "
                                           "Export node when it's a "
                                           "subnetwork. This causes the "
                                           "exporting subnetwork node to be "
                                           "represented in the FBX file.",
                                   default=False,
                                   label="Create Root for Subnet")
        vcformat = EnumDef("vcformat",
                           items={
                               0: "Maya Compatible (MC)",
                               1: "3DS MAX Compatible (PC2)"
                           },
                           default=0,
                           label="Vertex Cache Format")
        convert_units = BoolDef("convertunits",
                                tooltip="When on, the FBX is converted"
                                        "from the current Houdini "
                                        "system units to the native "
                                        "FBX unit of centimeters.",
                                default=False,
                                label="Convert Units")
        format_ascii = EnumDef("exportkind",
                               items={
                                   0: "Binary",
                                   1: "ASCII"
                               },
                               default=0,
                               label="Export Format")
        return attrs + [
            createsubnetroot,
            vcformat,
            convert_units,
            format_ascii,
        ] + self.get_instance_attr_defs()

    def get_dynamic_data(
        self,
        project_name,
        folder_entity,
        task_entity,
        variant,
        host_name,
        instance
    ):
        """
        The default prodcut name templates for Unreal include {asset} and thus
        we should pass that along as dynamic data.
        """
        dynamic_data = super().get_dynamic_data(
            project_name,
            folder_entity,
            task_entity,
            variant,
            host_name,
            instance
        )
        dynamic_data["asset"] = folder_entity["name"]
        return dynamic_data

    def get_selection(self):
        """Selection Logic.

        how self.selected_nodes should be processed to get
        the desirable node from selection.

        Returns:
            str : node path
        """

        selection = ""

        if self.selected_nodes:
            selected_node = self.selected_nodes[0]

            # Accept sop level nodes (e.g. /obj/geo1/box1)
            if isinstance(selected_node, hou.SopNode):
                selection = selected_node.path()
                self.log.debug(
                    "Valid SopNode selection, 'Export' in filmboxfbx"
                    " will be set to '%s'.", selected_node
                )

            # Accept object level nodes (e.g. /obj/geo1)
            elif isinstance(selected_node, hou.ObjNode):
                selection = selected_node.path()
                self.log.debug(
                    "Valid ObjNode selection, 'Export' in filmboxfbx "
                    "will be set to the child path '%s'.", selection
                )

            else:
                self.log.debug(
                    "Selection isn't valid. 'Export' in "
                    "filmboxfbx will be empty."
                )
        else:
            self.log.debug(
                "No Selection. 'Export' in filmboxfbx will be empty."
            )

        return selection

get_dynamic_data(project_name, folder_entity, task_entity, variant, host_name, instance)

The default prodcut name templates for Unreal include {asset} and thus we should pass that along as dynamic data.

Source code in client/ayon_houdini/plugins/create/create_fbx.py
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
def get_dynamic_data(
    self,
    project_name,
    folder_entity,
    task_entity,
    variant,
    host_name,
    instance
):
    """
    The default prodcut name templates for Unreal include {asset} and thus
    we should pass that along as dynamic data.
    """
    dynamic_data = super().get_dynamic_data(
        project_name,
        folder_entity,
        task_entity,
        variant,
        host_name,
        instance
    )
    dynamic_data["asset"] = folder_entity["name"]
    return dynamic_data

get_pre_create_attr_defs()

Add settings for users.

Source code in client/ayon_houdini/plugins/create/create_fbx.py
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
def get_pre_create_attr_defs(self):
    """Add settings for users. """

    attrs = super().get_pre_create_attr_defs()
    createsubnetroot = BoolDef("createsubnetroot",
                               tooltip="Create an extra root for the "
                                       "Export node when it's a "
                                       "subnetwork. This causes the "
                                       "exporting subnetwork node to be "
                                       "represented in the FBX file.",
                               default=False,
                               label="Create Root for Subnet")
    vcformat = EnumDef("vcformat",
                       items={
                           0: "Maya Compatible (MC)",
                           1: "3DS MAX Compatible (PC2)"
                       },
                       default=0,
                       label="Vertex Cache Format")
    convert_units = BoolDef("convertunits",
                            tooltip="When on, the FBX is converted"
                                    "from the current Houdini "
                                    "system units to the native "
                                    "FBX unit of centimeters.",
                            default=False,
                            label="Convert Units")
    format_ascii = EnumDef("exportkind",
                           items={
                               0: "Binary",
                               1: "ASCII"
                           },
                           default=0,
                           label="Export Format")
    return attrs + [
        createsubnetroot,
        vcformat,
        convert_units,
        format_ascii,
    ] + self.get_instance_attr_defs()

get_selection()

Selection Logic.

how self.selected_nodes should be processed to get the desirable node from selection.

Returns:

Name Type Description
str

node path

Source code in client/ayon_houdini/plugins/create/create_fbx.py
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
def get_selection(self):
    """Selection Logic.

    how self.selected_nodes should be processed to get
    the desirable node from selection.

    Returns:
        str : node path
    """

    selection = ""

    if self.selected_nodes:
        selected_node = self.selected_nodes[0]

        # Accept sop level nodes (e.g. /obj/geo1/box1)
        if isinstance(selected_node, hou.SopNode):
            selection = selected_node.path()
            self.log.debug(
                "Valid SopNode selection, 'Export' in filmboxfbx"
                " will be set to '%s'.", selected_node
            )

        # Accept object level nodes (e.g. /obj/geo1)
        elif isinstance(selected_node, hou.ObjNode):
            selection = selected_node.path()
            self.log.debug(
                "Valid ObjNode selection, 'Export' in filmboxfbx "
                "will be set to the child path '%s'.", selection
            )

        else:
            self.log.debug(
                "Selection isn't valid. 'Export' in "
                "filmboxfbx will be empty."
            )
    else:
        self.log.debug(
            "No Selection. 'Export' in filmboxfbx will be empty."
        )

    return selection

CreateStaticMesh

Bases: CreateFBX

Static Meshes as FBX.

Source code in client/ayon_houdini/plugins/create/create_fbx.py
192
193
194
195
196
197
198
199
200
201
class CreateStaticMesh(CreateFBX):
    """Static Meshes as FBX."""

    identifier = "io.openpype.creators.houdini.staticmesh.fbx"
    label = "Static Mesh (FBX)"
    product_type = "staticMesh"
    icon = "cube"

    def get_publish_families(self):
        return ["fbx", "staticMesh"]