[Closed] group geometry only from selection
I want to create a group and filtering classof to only group geometry… but i fail to do it
fragsel = selection where classof == geometry
if isValidNode $‘blabla’
then ungroup $‘kaboom’
group fragsel name:“blabla”
if not isValidNode $‘blabla’
then group fragsel name:“blabla”
Hi Laurent,
my approach is to test and deselect invalid nodes, then create the group with remaining objects.
(
-- Runs trough each node in selection and deselects it if not a geometry object
for n in selection where (superClassOf n != GeometryClass) do ( deselect n )
-- Creates a Group of geometry objects still selected
group selection name:"ObjectsGroup"
-- Selects the newly created group
select $ObjectsGroup
)
- Enrico
thank you.
It seems that if several object arnt geometry, only one is deselected…
Hey, try this, it should work. The issue is that “selection” is a collection and gets dynamically updated while objects are deselected by the loop. Sometimes it slips.
(
-- Gets selection as Array
local aSelection = selection as Array
-- Runs trough each node in selection and deselects it if not a geometry object
for n in aSelection where (superClassOf n != GeometryClass) do ( deselect n )
-- Creates a Group of geometry objects still selected
group selection name:"ObjectsGroup"
-- Selects the newly created group
select $ObjectsGroup
)
- Enrico
you don’t need to deselect not geometry nodes. it’s cleaner to collect and group only geometry class nodes:
group (for node in selection where iskindof node GeometryClass collect node)
Hey Denis, you’re right, I was carried a little away by reading the pseudocode
- Enrico
Well done DenisT ! that is what I wanted!
Thank you for your efforts SyncViewS, nice try from my “pseudoCode” ;))
thanks guys, glad to always find some help here!
Hey Laurent, I hope you didn’t feel offended by the “pseudocode”. It’s not meant to insult your work at all. It’s a technical term to identify a form of code written for human reading, rather than machine. You can define algorithms with it, then write them in machine language.
http://en.wikipedia.org/wiki/Pseudocode
- Enrico
Hey SyncViewS, no offense at all! don’t worry!! I am not scripter and I just keep trying to assemble pieces of code. I have a lot to learn with maxscript!! thank you for your time man