ScriptSpot home

Forum topic · General Scripting

Select Face Array

By Willian Kim · 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)
Branko Živković

Here we go


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
)

Reply to Branko Živković
Willian Kim

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

very thanks

Branko Živković

Little trick

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
)

Reply to Branko Živković
Willian Kim

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

Branko Živković

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
Willian Kim

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 ?

Reply to Willian Kim
Branko Živković

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

Reply to Willian Kim
Branko Živković

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

Reply to Willian Kim
Branko Živković

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

Reply to Branko Živković
Willian Kim

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
Willian Kim

.

lol.

I will try ...

very thanks

Reply to Willian Kim
Branko Živković

PolyOp Method

This is the same [PolyOp Method]

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

Branko Živković

Swordslayer is faster :)
Cheers!

Branko Živković

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

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

Vojtech Cada

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

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