Mailing List
Home
Forum Home
Softimage
Carrara
trueSpace
Dir3d-l
Maya - a powerful 3D animation and visual effects software
Macromedia Flash Development
Subjects
Cameras
scaleDown command
black out solved
Aircraft Tutorial
Mathematical XYZ ?
Its done This vs That
Its done first week
recommendations for screen video captures?
3DExplorer "Oddity "
New Director
ProTeam renewals
Fuel 's new websites (X post)
Blue peter create a make toy
targeting groups question
XPost: Shockwave 3D game ( sort of )
RES: RES: RES: Fish Modeling
Emitting particles from object intersection
Fuel 's new websites (X post)
Texturing
Big Break Contest Videos
New Plugins
Models and Texture on my updated site
Error Installing Patch tS6 6
Plasma?
Looking for Inspiration
Weird EMail Q
It 's done first week ?
Cherry not cranberry
New game
Camera Animation Problem
Particle plugins?
 
checking that an object exists

checking that an object exists

2005-04-07       - By kim aldis

 Back
Reply:     1     2     3     4     5     6     7     8     9     10     >>  

Brad's method is faster and simpler. And fewer lines of code.

 __ __  

From: owner-xsi@(protected) [mailto:owner-xsi@(protected)] On Behalf Of
Jason Brynford-Jones
Sent: 07 April 2005 20:45
To: XSI@(protected)
Subject: RE: checking that an object exists


And here is a link to more

http://www.xsibase.com/forum/index.php?board=14;action=display;threadid=1768
8


-- --Original Message-- --
From: owner-xsi@(protected) [mailto:owner-xsi@(protected)] On Behalf Of
Bradley R. Gabe
Sent: Thursday, April 07, 2005 3:14 PM
To: XSI@(protected)
Subject: Re: checking that an object exists

You can always try to populate an XSI collection using the items property
set to a string. If the objects don't exist in the scene, the collection
count will remain 0. Otherwise, it will fill up with the items that match
the string input. This is very fast and never raises errors:

// Create an empty XSI collection
var findColl = new ActiveXObject('XSI.Collection');

// Find the object from the name
findColl.Items = 'objectName';

// Test the collection count
if(findColl.count>0){
   var obj = findColl(0);
   LogMessage(obj);
}
// -- ---- ---- ---- ---- ---- ---- ---- ------

NOTE: This is the same way the Selection object gets populated when you type
a string in the text selection box, so you can always test your strings
before you put them into your code. Also, wildcard selections will work with
this method, so you could use it to quickly grab all the nodes in a specific
model space:

// Create an empty XSI collection
var modelColl = new ActiveXObject('XSI.Collection');

// Get the name of the current selected model
var modelName = selection(0).name;

// Get all the nodes in the model space
modelColl.Items = modelName + '.*';
// -- ---- ---- ---- ---- ---- ---- ---- ------

You can also use this technique to fill a collection with multiple
parameters or properties. I like to use an Array because it reads clearly,
requires less string concatenation, and is easy to add or remove items from:

// Create an empty XSI collection
var visColl = new ActiveXObject('XSI.Collection');

// Get the visibility parameters of the currently selected obj
var obj = selection(0);

visColl.Items = [
               obj + '.visibility.viewvis',
               obj + '.visibility.rendvis',
               obj + '.visibility.selectability'
               ];

// Get pointers to the visibility params
var viewvis = visColl(0);
var rendvis = visColl(1);
var selectability = visColl(2);
// -- ---- ---- ---- ---- ---- ---- ---- ------

If you're interested in more techniques for getting object pointers and
speed comparisons, check out this link:
http://www.cg-soup.com/archives/2005/02/loopin_lizards.html


-Brad
CG Soup



Hi,

I got an interesting question from someone, that I wanted to check out with
you all.

Given an object's full name, he wants to check if it exists.

So there are two ways to do it.

Via command: GetValue()

Via object model: Dictionary.GetObject()

now here's the question:

Both of these solutions throw an exception if the given object does not
exist.  While you can catch the exception, I'd think this is a poor way to
go about solving the problem.  Exceptions should not be used for flow
control.  They're inherently slow (or so I've been taught time and time
again).  Is there a better fast way to check if an object exists from its
full name that doesn't involve depending on exceptions?  I can come up with
some ways of doing it that will be inherently slow...  but none that are
fast.

-brad
---
Unsubscribe? Mail Majordomo@(protected) with the following text in body:
unsubscribe xsi