ScriptSpot

Forum topic · Scripts Wanted

select all polys with same mat ID than selected polys.

By titane357 · 2016-02-22

Description

Hi, to be clear : I would like to select by ids like in max rollout "Polygon: Material IDs" but not one Id by one ID.
For exemple I select three polys of an editable poly car model ( one of the body, one of the tyre and one of the Mirror ) , run the script and ALL polys of the body, the tyres and the Mirror are selected.
Thanks

Comments (2)

titane357 · 2016-02-22

Thanks Barigazy, works fine :-)
I'm desesperate to see that I will never succeed to do something with array or bitarray....

barigazy · 2016-02-22

Use this function

fn getSelectedFacesIDs = if selection.count == 1 and isKindOf (node = selection[1]) Editable_Poly do
(
if (faces = node.selectedfaces as bitarray).isEmpty then messagebox "Select some faces of editable poly object!" title:"Warning" beep:off else
(
local ids = #{} ; getFaceMatID = polyop.getFaceMatID
for f in faces do append ids (getFaceMatID node f)
if GetCommandPanelTaskMode() != #modify do SetCommandPanelTaskMode #modify
if subobjectLevel != 4 do subobjectLevel = 4
for i in ids do node.selectByMaterial i clearCurrentSelection:off
)
)
getSelectedFacesIDs()