Thanks I checked it and it's faster!

 

From: [email protected]
[mailto:[email protected]] On Behalf Of Martin
Sent: Thursday, June 28, 2012 7:10 PM
To: [email protected]
Subject: Re: Faster way of getting subcomponents from samples in
scripting?

 

I don't exactly remember where did I get this code, but it's quite fast
I think.

 

Tested with XSI Man : 

81286 Samples to 20347 polys in 1.6 seconds.

 

------------------------------------------------------------------------
- 

 

'VBS

 

'SelectComponentsBySamples (VBS) author: [email protected]

dim sind(),components()

str = ""

set o = selection(0).subcomponent.parent3dobject

set g = o.activeprimitive.geometry

set XSIDial = CreateObject("XSIDial.XSIDialog")

aItems = Array("Points","Edges","Polygons")

indx = XSIDial.ComboEx("Select Components Type", aItems, 0)

 

if (indx=-1) then 

            logmessage "User cancelled" 

else 

            logmessage "User selected: " & aItems( indx )

            redim sind(g.samples.count - 1)

            if indx = 0 then : cmppref = "pnt" : set cmps = g.points :
end if

            if indx = 1 then : cmppref = "edge" : set cmps = g.edges :
end if

            if indx = 2 then : cmppref = "poly" : set cmps = g.polygons
: end if

            for each c in cmps

                        for each s in c.samples

                                    sind(s.index) = c.index

                        next

            next

            redim components(cmps.count - 1)

            for each s in selection(0).subcomponent.componentcollection

                        if components(sind(s.index)) <> 1 then

                                    if str <> "" then

                                                str = str & ","

                                    end if

                                    str = str & sind(s.index)

                                    components(sind(s.index)) = 1

                        end if

            next

            SelectObj o &"."& cmppref &"["& str &"]"

end if

 

------------------------------------------------------------------------
-

 

M.Yara

Reply via email to