Forum Groups
  All forums
    Help & Feedback
      Work in progress
      Finished Art
      Non-Max related

Maxunderground news unavailable

First page  Go to the previous page   [01]  [02]  Go to the next page  Last page
can anyone help me with a snippet?
show user profile  jpedleham
I have a shitload of batching to do on our model library at work and i wonder if someone could help me with a snippet that renames all scene objects to the first 8 characters unless the characters after the 8th character are _LH or_RH

Ie. the cad block might be A12-1234 but there may also be A12-1234_LH

can anyone help me?
ive tried various renaming scripts but nothing yet
read 461 times
2/29/2016 5:35:27 PM (last edit: 2/29/2016 5:35:27 PM)
show user profile  ccampbell
Will this get you by?

Nodes = objects as array
for i = 1 to Nodes.count do (

objName = Nodes[i].name
HasExt = (objName[9] + objName[10] + objName[11] )
if HasExt != "_LH" and HasExt != "_RH"
then( Nodes[i].name = (substring objName 1 8))
catch(print "N/a")
) -- end loop

$Entrepreneur = if((Designer + Engineer)*Programmer){Problem Solver};

read 444 times
2/29/2016 7:01:13 PM (last edit: 2/29/2016 7:04:39 PM)
show user profile  Garp

edirt: Damn. Too slow.

read 437 times
2/29/2016 7:13:00 PM (last edit: 2/29/2016 7:15:10 PM)
show user profile  Garp
Oops. Forgot the RH one.

read 430 times
2/29/2016 7:20:27 PM (last edit: 2/29/2016 7:20:27 PM)
show user profile  Garp
Actually, the length test is useless.

read 427 times
2/29/2016 7:28:52 PM (last edit: 2/29/2016 7:28:52 PM)
show user profile  jpedleham
I love these forums. Thanks guys :D
read 420 times
2/29/2016 8:01:15 PM (last edit: 2/29/2016 8:01:15 PM)
show user profile  jpedleham
I read somewhere about matchpattern.
If possible id like to first check that the first 8 characters match that A11-1234 pattern before going ahead with the rename so i dont end up truncating stuff that isnt from our cad library.
I tried adding in 'and matchPattern s pattern:"A11-1111" = true' but im not sure as to the syntax to define a pattern containing numbers text and punctuation.

I Also notice in this code that if the cad block name contains LH or RH it doesnt trim after the _rh or _lh. I suppose this could be done with cascading 'if statements' im not sure what the equivalent is in ms.

In maxscript does != mean does not include?

read 412 times
2/29/2016 9:29:36 PM (last edit: 2/29/2016 9:29:36 PM)
show user profile  Garp
In the mxs doc, look into MAXScript Introduction > The MAXScript Editor > Regular Epressions . . .

read 393 times
2/29/2016 11:49:54 PM (last edit: 2/29/2016 11:49:54 PM)
show user profile  jpedleham
Cool, The only part of that im not getting is the enclosing brackets. I think i have the syntax right but im not sure where the brackets should go.


should it be like this?;

read 374 times
3/1/2016 9:33:08 AM (last edit: 3/1/2016 9:33:08 AM)
show user profile  ccampbell
Unfortunately match pattern is much the same as find string(but much faster). It does not allow you to recognize naming convention patterns.If you want that kind of verification you'll want to write a small piece that checks for conformity before you perform renaming steps on the object.

For your case, It seems like you could get away with detecting the hyphen only or possibly verify only parts you know dont change.

For example maybe the first character always a-z (looks like it from your example above). In which case, maybe just verify the first letter is infact a letter and follow that up with a check to be sure the hyphen is always the 4th character. If so, continue on checking if there is an extension as well (_LH, _RH) and so on.

Get it?

$Entrepreneur = if((Designer + Engineer)*Programmer){Problem Solver};

read 348 times
3/1/2016 5:33:35 PM (last edit: 3/1/2016 5:34:20 PM)
show user profile  Garp
I'm not particularly savvy with regex. I have to look it up every time.

read 341 times
3/1/2016 6:56:14 PM (last edit: 3/1/2016 6:56:14 PM)
show user profile  ccampbell
@Garp I Learn new stuff every day. Never heard the term "regex".

@jpedleham Eitherway, your use case seems pretty simple. I'm not convinced you need to identify the naming convention pattern to be safe but you would know better than me. Is this batching something you do now and then or is this something they have you do a lot?

$Entrepreneur = if((Designer + Engineer)*Programmer){Problem Solver};

read 333 times
3/1/2016 9:12:45 PM (last edit: 3/1/2016 9:12:45 PM)
show user profile  jpedleham
its somethign i have to do at the moment on amodel library of about 1200 files. I need to place all of the files in a certain range in a single max file and then ensure their object names are cut down to simply the cad block reference and any suffixes such as the _LH, _RH _FS or _MRCH.
read 303 times
3/3/2016 9:51:38 PM (last edit: 3/3/2016 9:51:38 PM)
show user profile  jpedleham
Any ideas how to completely clear a listbox?

im using

if missingfixtures.items.count > 0 do
for i = 1 to (missingfixtures.items.count) do
deleteItem missingfixtures.items[i]

but i get the error No ""deleteItem"" function for "Teapot003"

im testing with teapots obviously.
read 272 times
3/6/2016 9:44:01 PM (last edit: 3/6/2016 9:44:01 PM)
show user profile  ccampbell
You can not manipulate the ListBox Items directly. The "Items" are an array of values. As such, you have to assign the itemslist array to a variable, manipulate new variable array and reassign the values back to the rollout element.

In this case, simply clearing the box is as simple as assigning an empty array to the .items method.

ListBox.items = #() -- where "ListBox" is your rollout element name

Edit: To manipulate the list...

-- get list box items array in a variable
-- edit the items array in the variable
-- reassign new array to rollout element.

LBList = LB1.items
deleteitem LBlist 3 -- use finditem LBList "string" to get index of specific value
LB1.items = LBList

$Entrepreneur = if((Designer + Engineer)*Programmer){Problem Solver};

read 250 times
3/7/2016 7:36:51 PM (last edit: 3/7/2016 7:50:35 PM)
First page  Go to the previous page   [01]  [02]  Go to the next page  Last page
#Maxforums IRC
Open chat window