Depends how the polygon is referenced in your code.

A Polygon is a geometry component and part of the object's primitive.  A 
Cluster is a type of metadata and lives outside the geometry, but makes 
references to parts of the geometry.  Most methods provided in the SDK work 
in a top-down fashion.  That is, they start with a major object or 
primitive, then the methods dig down to find subcomponents or elements of 
smaller stature.  What you're requesting is the ability to go the other 
direction (bottom-up).  While some examples of that do exist in the SDK, 
they're pretty scarce and I don't think any exist for your particular 
request.

If you have a reference to a polygon as a ClusterElement you may be able to 
call the .Parent property to crawl up the graph to get the Cluster that owns 
it.

If you have a reference to a polygon as a PolygonFace as obtained through 
most of the geometry methods, then no.  You must traverse the clusters and 
query if the polygon is contained within.

If you want to bypass the object model and go completely old school command 
based manipulating of strings, you may (in some cases) dump the full path of 
the polygon, then tokenize it by '.' characters and crawl up the path until 
you find the cluster.  There are limitations with this method as the number 
of path components is not consistent and will change depending on various 
factors such as whether the object is part of a model or not, the type of 
cluster applied (polygon, point, sample, ...), the context in which the 
polygon reference was obtained, etc...  Any solution using this tactic can 
work for specific situations, but will be error prone for the general case.

In some back door esoteric secret handshake situations, you might be able to 
use a SubComponent Object to find the cluster, but if you do that you 
already know the cluster, so creating the SubComponent is irrelevant.

Long story short, if you only need to find the owning cluster once or twice, 
then just traverse the clusters and query if the polygon is in the cluster. 
If you have to do this en masse, then it might pay off to create reverse 
lookups maps using a simple associative array to store references to the 
cluster in the indices (eg; Array[PolygonIndex] = Cluster).  Creating the 
maps will take some time, but once they're established your lookups will be 
very fast.


Matt




Date: Tue, 13 Dec 2016 18:45:36 -0200
From: Fabricio Chamon <xsiml...@gmail.com>
Subject: Find cluster from polygon - script
To: "softimage@listproc.autodesk.com"

Hey guys,

is there a quick way to find which cluster(s) a polygon belongs to without
looping over all cluster elements?

thanks. 


------
Softimage Mailing List.
To unsubscribe, send a mail to softimage-requ...@listproc.autodesk.com with 
"unsubscribe" in the subject, and reply to confirm.

Reply via email to