[Closed] getting the amount of UVW channels
Hi guys,
I am still trying to get around some of this maxscripting in my free time.
Could anybody help me with the following issue;
I need to know how many UVW channels an objects has,… And if it has more then 1; the object should be hidden/deselected. I can’t find anything on the amount of UVW channels. Tried to check them in the ChannelInfo interface but that didn’t seem to work. Did quite some research but that didn’t turn out with usefull results as well. Anything I am missing? Tips/Tricks?
Thanks in advance
Pieter
Hi PpHammer,
I have written out a little function for you, and a bit of extra code underneath. The function identifies different map channels on a given object. I hope that this is what you were looking for. I have tried to add a few comments to the code to help. I hope you get what you need from it!!
--function for returning an array of UVW map channel numbers on an object
fn UVWChannelGrabber obj =
(
Local ChannelArr = #()
Local ObjMod = #()
--collect all object UVW map modifiers in an array
if obj.modifiers.count != 0 then
(
for o in obj.modifiers do
(
if iskindof o UVWMap do
(
append ObjMod o
)
)
)
else
(
return #(0)
)
--Loop through mapchannels adding new channels to ChannelArr
--Ignoring repeats
for o in ObjMod do
(
Local Addmodswitch = true
for obj in ChannelArr do
(
if o.mapchannel == obj do
(
Addmodswitch = false
)
)
if Addmodswitch == true do
(
--add the new map channel value to the Channel Arr
append ChannelArr o.mapchannel
)
)
if ChannelArr.count == 0 then
(
return #(0)
)
else
(
return ChannelArr
)
)
--This will return 1 if there are 0 or 1 uvwmap channels on the object, and it will return the precise number of mapchannels
--if there are 2 or more. (Ex. If an object has mapchannels 1,2,3. Then MapNo = 3)
--MapNo = (UVWChannelGrabber $).count
--Print ("Number of different Map channels on Object = " + MapNo as string)
--so to deselect/hide all objects that have more than one map channel just do
CurrSel = selection as array
for o in selection do
(
--Filter selection to only look at geometry.....remove if not needed
if superclassof o == GeometryClass do
(
if (UVWChannelGrabber o).count > 1 do
(
--This deselects the objects and hides them....adjust as required!
deselect o
o.isHidden = true
)
)
)
--Thats about it!
There is probably a lot faster way of writing this I am not great at Maxscript, I have given it a few tests, and I think it works pretty reliably. Hope it helps!
Take care,
EverZen
That would return a list of UVW Map modifiers on the object, but wouldn’t really tell you how many UV channels it had. Say you applied a UVW Map modifier to it, set it to channel #3 and collapsed the stack. Even with no modifiers, that object still has UVs in channel #3.
The following should do what you want, on both mesh and poly objects.
fn getNumUVChannels obj = (
count = 0
if classof obj == Editable_Poly or classof obj == PolyMeshObject then (
for i in 1 to polyOp.getNumMaps obj do
if polyOp.getMapSupport obj i then
count += 1
) else (
for i in 1 to meshOp.getNumMaps obj do
if meshOp.getMapSupport obj i then
count += 1
)
return count
)
for o in geometry do
if getNumUVChannels o > 1 then (
o.isSelected = false
o.isHidden = true
)
He guys!
Thanks for the fast reply! Very helpful! I was looking for a solution as Adam wrote, but I’ve should have been more clear in my question. Though, there are quite some things in Everzens script that are helping me along my way getting a grip on maxscript! Thanks to the both of you!
Pieter
How to select missing mapChannel Boolean2 object ?
because meshOp.getMapSupport and polyOp.getMapSupport all error
Thanks,I’m very fret