ScriptSpot

Forum topic · General Scripting

Select Face Array

By kimarotta · 2012-06-05

Description

Hi,

I need a help in faces...
I'm trying to collect some faces, some faces have an array but I can not load the array in setSelection ...

Thanks in advanced



	prov = $.selectedFaces as integer
-- Unable to convert: #faces(181, 234, 347 : $Editable_Poly:Plane003 @ [32.705963,272.583252,0.000000]) to type: Integer

prov
#faces(181, 234, 347 : $Editable_Poly:Plane003 @ [32.705963,272.583252,0.000000])

$.EditablePoly.SetSelection #Face #{prov}
-- Unable to convert: #faces(181, 234, 347 : $Editable_Poly:Plane003 @ [32.705963,272.583252,0.000000]) to type: Integer


Comments (21)

Here we go

barigazy · 2012-06-06


with redraw off
(
max create mode
plane1 = $Plane001
plane1Mod = plane1.modifiers[#Vol__Select]
modNode = plane1Mod.node
plane2 = snapshot $Plane001
prov1 = #{} -- empty bitarray
intersectFrames = #()
getFaceSel = getFaceSelection
setfmID = setFaceMatID
for t in 0 to 50 do
(
at time t
if (intersects plane1 modNode) do append intersectFrames t
local selFaces = getFaceSel plane1.mesh
if selFaces.numberset != 0 do prov1 += selFaces

)
for f in prov1 do (setfmID plane2 f 2)
plane2 = (convertto plane2 Editable_Poly)
plane1.baseobject = plane2
delete plane2
format "frames at intersection = %\n" intersectFrames
)

kimarotta · 2012-06-06

I'm testing ... and everything went right ... when I grow up I want to be like you ...
lol =D

very thanks

barigazy · 2012-06-06

No man i'm bad example. :)
And i'm not old (30) :)

jos · 2012-06-07

lol :)

Little trick

barigazy · 2012-06-05

This works with your file. Solution for Editable Poly object

with redraw off
(
max create mode
plane1 = $Plane001
plane2 = snapshot $Plane001
prov1 = #{} -- empty bitarray
getFaceSel = getFaceSelection
setfmID = setFaceMatID
for t in 0 to 50 do
(
at time t
local selFaces = getFaceSel plane1.mesh
if selFaces.numberset != 0 do prov1 += selFaces
)
for f in prov1 do (setfmID plane2 f 2)
plane2 = (convertto plane2 Editable_Poly)
plane1.baseobject = plane2
delete plane2
)

kimarotta · 2012-06-06

Yeah Barigazy very thanks your help...

barigazy · 2012-06-06

This is what you want, right?

kimarotta · 2012-06-06

yes, I will use this separation to paint a map of footprint ... I do have one more question ... could somehow know which frame each collision that occurs?
thanks in advanced

barigazy · 2012-06-05

this works only if you use editable_mesh object not editable_poly.
open the file in attachments and run this code

plane1 = $Plane001
plane2 = $Plane002
prov1 = #{} -- empty bitarray
getFaceSel = getFaceSelection
setfmID = setFaceMatID
for f in 0 to 50 do
(
--sliderTime = f
at time f
local selFaces = getFaceSel plane1.mesh
if selFaces.numberset != 0 do prov1 += selFaces
)
--uncomment *line 14* i if you want to select faces
--plane2.selectedfaces = prov1 --
for f in prov1 do setfmID plane2 f 2
update $

Attachments

kimarotta · 2012-06-05

So, two question.

when I use "prov = $. selectedFaces the BitArray" and then ask prov.count it returns the total number of faces and not the number of items in the array ...

.
above the editablepoly I have a Vol. Select modifier and when I use "prov = $.selectedFaces as bitarray" he can not get the selected faces anyone have any idea ?

barigazy · 2012-06-05

First if you use array and you want to know the count then use:


arr = #(1,5,8,10)
arr.count
-->4


But for bitarray you need to use:

bitarr = #{1..5,10,16}
bitarr.numberset
-->7

kimarotta · 2012-06-05

very good and very thanks Barigazy...

and the question of vol. select has any idea?

barigazy · 2012-06-05

Next time say if you use modifiers or not :)
For the editpoly mod you can use various methods
Read mxs help, topic Edit_Poly : Modifier

EditPolyMod.GetSelection $.modifiers[#Edit_Poly] #Face
--or
EditPolyMod.GetSelection $.Edit_Poly #Face
--or
$.modifiers[#Edit_Poly].EditPolyMod.GetSelection #Face
--or
$.Edit_Poly.EditPolyMod.GetSelection #Face
--or
$.modifiers[#Edit_Poly].GetSelection #Face
--or
$.Edit_Poly.GetSelection #Face

kimarotta · 2012-06-05

Sorry... and thanks again.

barigazy · 2012-06-05

Are you preparing some new script or just playing with modifiers?
Share at least one screenshoot :)

kimarotta · 2012-06-05

Hey... I am trying to solve a problem ... I'll try to explain ... I have a plane with a modifier "Vol.Select", and would like to collect the faces that "Vol.Select" select ... I select only the latest faces and not all. would like to create an ID for each selection group that creates the Box Plane ... you get the idea? I'm sending the file to the test ...
was trying something like...


for f in 0 to 50 do
(
sliderTime = f
prov1 = #()
tst = $.VolselectMod.GetSelection #Face ---- This line is not working ... not found the correct code 
	append prov1 tst
)

prov1

p.s. I'm a begginer... help are welcome

Attachments

.

kimarotta · 2012-06-05

lol.

I will try ...

very thanks

PolyOp Method

barigazy · 2012-06-05

This is the same [PolyOp Method]

prov = polyop.getFaceSelection $
polyop.setFaceSelection $ #{}
polyop.setFaceSelection $ prov
max views redraw

barigazy · 2012-06-05

Swordslayer is faster :)
Cheers!

barigazy · 2012-06-05

You can't convert as integer but you can convert as bitarray

prov = $.selectedFaces as bitarray
$.SetSelection #Face #{}
$.SetSelection #Face prov

Swordslayer · 2012-06-05

Hi, did you try to cast it to bitarray? Like this:

prov = $.selectedFaces as bitarray
$.EditablePoly.SetSelection #Face prov -- or $.selectedFaces = prov