General Category > General CG Discussion

Maxscript Help - assigning oID based on laer name suffix

(1/1)

DPS:
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: ---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

--- End code ---


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.

Navigation

[0] Message Index

Go to full version