Author Topic: Maxscript Help - assigning oID based on laer name suffix  (Read 1096 times)

2022-06-12, 03:50:38

DPS

  • Active Users
  • **
  • Posts: 117
    • View Profile
I'm an absolute beginner when it comes to Maxscript. Wondering if someone can help me to improve my script?

Background: when assigning object gbuffer IDs I am using a script to assign these based on my standard layer names. That part works fine.

However - there are some circumstances where I'd like to assign Object Ids based on a suffix on the layer name - for example "Layer01[OID16]" - and I wish to have a script that searches for the suffix and adds the appropriate ID.

Here is my script so far:

Code: [Select]
ObjLay = $.layer.name -- layer of selected objects

MyString1 = (FilterString ObjLay "[OID")[2] -- search the slected layer name for "[oid".  This is so I can add a suffix e.g. [OID7] to specify the Gbuffer ID I wish to assign.

MyString2 = (FilterString MyString1 "]")[1] as integer-- best I could do.

for o in selection do o.gbufferchannel = MyString2


I'm actually using this within Vexus (a nodal scripting tool for Max), and I already have another node that selects all objects on layers that contain "*[OID*]*"

The problem is this script doesn't work when I have different layers with different [OID] suffixes. I understand why it doesn't work, I just don't know how to fix it. I hope that makes sense.
Specs: AMD 1950X, Aorus Gaming 7 x399, 64GB RAM, 1080ti. Win10, Max 2017, Corona 1.7.3