RE: Scripting : Referenced Model owner

Date : Mon, 4 Jun 2007 18:38:58 +0100
To : <XSI(at)Softimage.COM>
From : "Adam Seeley" <adam.seeley(at)clearpost.co.uk>
Subject : RE: Scripting : Referenced Model owner
Just whatI was looking for, but staying clear of the fun & games 'till the next version ta very much.
 
A.


From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Steven Caron
Sent: 04 June 2007 18:11
To: XSI(at)Softimage.COM
Subject: Re: Scripting : Referenced Model owner

if your in 6.x

"Model.ModelKind" is helpful

steven

On 6/4/07, Adam Seeley <adam.seeley(at)clearpost.co.uk > wrote:
Hi
 
In the absence of a handy Property that knows that what the Referenced Model is,  I iterated up from the Current object checking the .Model Parameter "storage_type" to see if it was loaded or not.
 
You could check for "Referenced_" being the first 11 characters of the Name as well, it would catch Referenced Models inside Reference Models then.
 
Excuse that safety "i"'s dotted around, iterations can be dangerous.
 
'-------------------------------------------------------------
function fnFindRefModel(oSelection)
     i = 0

     set oObject = oSelection
     do until oObject.Model.Parameters("storage_type").Value = False or i > 10
     set oObject = oObject.Model
 
     if i > 10 then Exit Do
     i = i + 1
     loop
 
     fnFindRefModel = oObject.Parent.Name

end function
'-------------------------------------------------------------
 
Adam.

From: owner-xsi(at)Softimage.COM [mailto:owner-xsi(at)Softimage.COM] On Behalf Of Nick
Sent: 04 June 2007 04:28
To: XSI(at)Softimage.COM
Subject: Re: Scripting : Referenced Model owner

that seems to be pretty wasteful, isn't it?

oModel = Application.Selection(0)
while not oModel.Model.IsEqualTo(Application.ActiveSceneRoot):
    oModel = oModel.Model

--
''.join([chr(ord(c)-10) for c in 'xzo~s~J|}z8myw8k '])
teedee - Rising Sun Pictures

On 6/2/07, Bernard Lebel <3dbernard(at)gmail.com> wrote:
I'd recursively walk up the hierarchy.



// Collection to store all visited models
oModels = XSIFactory.createobject( "XSI.Collection" );

checkParent( selection(0) );

// Get model before last (last model being the scene root
oModel = oModels.item( oModels.count-2 );
logmessage( oModel.fullname );


function checkParent( oObject )
{
        if( oObject.type == "Scene" )
                return;
        else if( oObject.type == siModelType )
        {
                oModels.add( oObject );
        }

        checkParent( oObject.parent );
}




Cheers
Bernard
---

No virus found in this outgoing message.
Checked by AVG Free Edition.
Version: 7.5.472 / Virus Database: 269.8.7/829 - Release Date: 02/06/2007 17:26


Search the XSI List archives here or use the advanced search form to search across mailing lists. Searching help is available.
This site supposedly brought to you by Benjamin Grosser and the Imaging Technology Group.