Jump to content

Recommended Posts

Posted

Just copy and paste this code into the console:

local file = RequestFile("Open File")
if file ~= "" then
    local mdl = LoadModel(nil, file)
    if mdl ~= nil then
        for n = 1, #mdl.kids do
            local child = Model(mdl.kids[n])
            if child ~= nil then
                child:SetPosition(0,0,0)
                child:Save(StripExt(file) .. "_limb" .. tostring(n) .. ".mdl")
            end
        end
    end
end

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Sometimes models will have one or two extra nodes in the hierarchy, in which case you can use this. Adjust as needed:

local file = RequestFile("Open File")
if file ~= "" then
    local mdl = LoadModel(nil, file)
    if mdl ~= nil then
        mdl = mdl.kids[1]--[[ one level deep ]] 
        mdl = mdl.kids[1]--[[ two levels deep ]]
        for n = 1, #mdl.kids do
            local child = Model(mdl.kids[n])
            if child ~= nil then
                child:SetPosition(0,0,0)
                child:Save(StripExt(file) .. "_limb" .. tostring(n) .. ".mdl")
            end
        end
    end
end

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Posted

Or if you want to use the limb names as the new file names, use this:

local file = RequestFile("Open File")
if file ~= "" then
    local mdl = LoadModel(nil, file)
    if mdl ~= nil then
        mdl = mdl.kids[1]--[[ one level deep ]] 
        mdl = mdl.kids[1]--[[ two levels deep ]]
        for n = 1, #mdl.kids do
            local child = Model(mdl.kids[n])
            if child ~= nil then
                child:SetPosition(0,0,0)
                child:Save(ExtractDir(file) .. "/" .. child.name .. ".mdl")
            end
        end
    end
end

 

My job is to make tools you love, with the features you want, and performance you can't live without.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...