The problem about the spare port of Null and AbstractControl

   249   1   1
User Avatar
Member
1 posts
Joined: 10月 2025
オフライン
How to find and connect the spare ports of null and AbstractControl nodes in APEXSCRIPT?
I tried to use FindPort, FindOrAddPort, RenamePort and other ports to find the standby port of a node, but it didn't work. How can I use scripts to achieve the effect shown in the figure? Another question is that multiple data can be merged into an array. How can I operate if I want to decompose an array and output multiple data ports?



Attempts made (not beautiful):
_, _, _, abs_parm_point_0_ctrl_weights, abs_parm_point_1_ctrl_weights, abs_parm_point_2_ctrl_weights, \
abs_parm_point_3_ctrl_weights, abs_parm_point_4_ctrl_weights, abs_parm_point_5_ctrl_weights, \
abs_parm_point_6_ctrl_weights, abs_parm_point_7_ctrl_weights, abs_parm_point_8_ctrl_weights, \
abs_parm_point_9_ctrl_weights, abs_parm_point_10_ctrl_weights, abs_parm_point_11_ctrl_weights, \
abs_parm_point_12_ctrl_weights, abs_parm_point_14_ctrl_weights, abs_parm_point_15_ctrl_weights, \
abs_parm_point_16_ctrl_weights, abs_parm_point_17_ctrl_weights, abs_parm_point_18_ctrl_weights, \
abs_parm_point_19_ctrl_weights, abs_parm_point_20_ctrl_weights, abs_parm_point_21_ctrl_weights, \
abs_parm_point_22_ctrl_weights, abs_parm_point_23_ctrl_weights, abs_parm_point_24_ctrl_weights, \
abs_parm_point_25_ctrl_weights, abs_parm_point_26_ctrl_weights = apex.rig.abstractControl(
    
    __spare____out=[
        'point_0_ctrl_weights', 'point_1_ctrl_weights', 'point_2_ctrl_weights', 
        'point_3_ctrl_weights', 'point_4_ctrl_weights', 'point_5_ctrl_weights', 
        'point_6_ctrl_weights', 'point_7_ctrl_weights', 'point_8_ctrl_weights', 
        'point_9_ctrl_weights', 'point_10_ctrl_weights', 'point_11_ctrl_weights', 
        'point_12_ctrl_weights', 'point_14_ctrl_weights', 'point_15_ctrl_weights', 
        'point_16_ctrl_weights', 'point_17_ctrl_weights', 'point_18_ctrl_weights', 
        'point_19_ctrl_weights', 'point_20_ctrl_weights', 'point_21_ctrl_weights', 
        'point_22_ctrl_weights', 'point_23_ctrl_weights', 'point_24_ctrl_weights', 
        'point_25_ctrl_weights', 'point_26_ctrl_weights'
    ],
...
)

Finally, I don't know how to deal with the display sorting problem:

Attachments:
abs_ports.png (230.9 KB)
sort_vis.png (1.1 MB)

User Avatar
スタッフ
146 posts
Joined: 10月 2023
オフライン
Hi,
There are a couple of ways to do this, however it looks like the sorting on the control in the viewport is a
bug.
Copy the snippet into a autorig component.


# create the subnet with the existing names.
def subnet(
    one: Float, 
    two: Float, 
    # three: Float, 
    four: Float,
    five: Float,
):
    one = Float()
    
subnetnode = graph.addSubnet(subnet, 'mySubnet')

node = graph.addOrUpdateNode(
    callback='AbstractControl',
    name='test',
)

# find the ports of the existing subnet
ports = graph.findPorts('mySubnet:*[in]')

# loop over the list
for port in ports:
    portname = port.data()
    # create a null to set the types for the outputs
    node.promoteNodeInput(
        portname='__spare__',
        parmname=portname,
    )
    # connect the output of the abstract control to an existing subnet
    graph.findAndConnectInput(
        srcnode=node,
        srcname=portname,
        dstnode=subnetnode,
        dstname=portname,
        )
Here is another way:
node = graph.AddOrUpdateNode(
    callback='AbstractControl',
    name='test',
)
# create you list
list = ['one', 'two', 'three', 'four']
nulls = ApexNodeIDArray()
# loop over the list
for i in list:
    # create a null to set the types for the outputs
    null = graph.AddOrUpdateNode(
        callback='Null<Float>',
        name=f'null_{i}',
    )
    
    # promote the ports, NB the type of parm inputs are defined 
    # be the connected port. simply promoting them does not give them
    # a type.
    node.promoteNodeInput(
        portname='__spare__',
        parmname=i,
        )

    # Find the new port based on the new name.
    port = node.findPort(f'{i}[out]')
    
    # connect the port to the float null, This will now set the type for 
    # all the ports on the parm and abstract control
    port.connect(null.value_in)
    
    # add the nulls to the nulls array
    nulls.append(null)
# pack the loose nulls into a neat subnet
graph.packSubnet('mySubnet', nulls)
Edited by william_harley - 昨日 08:29:49

Attachments:
Screencast_from_2026-07-06_14-25-43.gif (379.4 KB)

  • Quick Links