PDA

View Full Version : group geometry only from selection


loran
10-05-2009, 12:24 PM
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"

SyncViewS
10-05-2009, 02:02 PM
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

loran
10-05-2009, 07:11 PM
thank you.
It seems that if several object arnt geometry, only one is deselected...

SyncViewS
10-05-2009, 07:25 PM
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

denisT
10-05-2009, 08:16 PM
I want to create a group and filtering classof to only group geometry... but i fail to do it :/

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)

SyncViewS
10-05-2009, 08:24 PM
Hey Denis, you're right, I was carried a little away by reading the pseudocode :D

- Enrico

loran
10-05-2009, 08:55 PM
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!

SyncViewS
10-05-2009, 09:03 PM
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

loran
10-05-2009, 09:57 PM
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

CGTalk Moderation
10-05-2009, 09:57 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.