Re: [CPP] How can I determine if a model is a instance

Date : Fri, 02 Dec 2005 10:29:04 +0100
To : XSI(at)Softimage.COM
From : Guy Rabiller <guy(at)alamaison.fr>
Subject : Re: [CPP] How can I determine if a model is a instance

Hi Steve,

strange, I've just tried your code and I get 1 Parameters Count on Instance Groups.

Try with this code, see if it works for you:


// ---------------------------------------------------------------------------
    Application oApp;

    CRef oSel( oApp.GetSelection()[0] );

    // ===[ Model Selected ? ]================================================
    if( oSel.GetClassID() == siModelID ) {

        // ---[ Get Owners ]--------------------------------------------------
        CRefArray oOwners( Model(oSel).GetOwners() );
        long      iCount ( oOwners.GetCount()      );
        long      i;

        // ---[ Find Groups ]-------------------------------------------------
        for( i=0; i<iCount; ++i ) {
            if( oOwners[i].GetClassID() == siGroupID ) {

                // ---[ Get Parameters Count ]--------------------------------
                Group oGroup ( oOwners[i]                        );
                long  iParams( oGroup.GetParameters().GetCount() );

                oApp.LogMessage( L"Group: [" + oGroup.GetFullName() + L"] (" +
                                 CValue(iParams).GetAsText() + L")" );
            }
        }
    }
// ---------------------------------------------------------------------------

--
guy rabiller | 3d technical director (at) LaMaison





Steve Yin a écrit :
hi, I got some new, when I check this in SDK explorer, it only shows one parameter, but if i use these codes:
 
  ownerArray=modelObj.GetOwners();
 
  //check to see if this model is a instanced, if it is, export it
  for(long j=0; j<ownerArray.GetCount(); j++){
   //one of it's owner is group
   if(ownerArray.GetItem(j).GetClassID()==XSI::siGroupID){
    instanceGroup=ownerArray.GetItem(j);
    XSIApp.LogMessage(instanceGroup.GetParent().GetClassIDName());
    XSIApp.LogMessage(XSI::CValue(instanceGroup.GetParameters().GetCount()));
 
    //the group only have 1 parameter, and it's parent is a model is a instance group
    if(instanceGroup.GetParent().IsValid() && instanceGroup.GetParameters().GetCount()==1l &&
     instanceGroup.GetParent().GetClassID()==XSI::siModelID){
 
I always get 5 parameters. what's wrong with my code?
 
----- Original Message -----
From: "Guy Rabiller" <guy(at)alamaison.fr>
Sent: Wednesday, November 30, 2005 7:37 PM
Subject: Re: [CPP] How can I determine if a model is a instance

>
> Hi Steve,
>
> either the GetMaster command or if you need the ObjectModel approach,
> try this heuristic:
> ( I think this might be the GetMaster approach ):
>
> -> To Check if a Model is an Instance:
> ( and to find its Master )
> 1) Check if one of the Model.GetOwners() is of ClassID siGroupID.
> 2) Check if the Group.GetParameters().GetCount() is 1 or 5.
> If it is 1 it is either an "InstanceGroup" of a Master Model or an
> "Associated Models" of a Light.
> From here, to distinguish the two of them, either check the name of the
> Group ( wich is rarely changed by the user ), or just to be sure, check
> if the Owner of the Group - there must be only 1 - is of Class siModelID.
> ( then you've found your master - or source - model )
>
> -> To Check if a Model is a Master
> 1) Check if one of its Groups - if any - has Parameters Count equal to 1.
> If yes, then it has been instanciated and is/was a Master.
> ( you cant remove a Model InstanceGroup )
>
> Tell me if that works for you.
>
> Regarding Clones, freeze works here in v5, without the need to save/open.
> --
> guy rabiller | 3d technical director (at) LaMaison
>
>
> Steve Yin wrote:
>
>> no, there is no such a property.
>>
>>     ----- Original Message -----
>>     *From:* kim aldis <mailto:kim(at)cg-soup.com>
>>     *To:* XSI(at)Softimage.COM <mailto:XSI(at)Softimage.COM>
>>     *Sent:* Wednesday, November 30, 2005 5:28 PM
>>     *Subject:* RE: [CPP] How can I determine if a model is a instance
>>
>>     check to see if the model has a master property.
>>
>>         ------------------------------------------------------------------------
>>         *From:* owner-xsi(at)Softimage.COM
>>         <mailto:owner-xsi(at)Softimage.COM>
>>         [mailto:owner-xsi(at)Softimage.COM] *On Behalf Of *Steve Yin
>>         *Sent:* 30-November-2005 08:48
>>         *To:* XSI(at)Softimage.COM <mailto:XSI(at)Softimage.COM>
>>         *Subject:* [CPP] How can I determine if a model is a instance
>>
>>         Hi people:
>>             I have a c++ problem, I'm trying to write a plugin for
>>         xsi, Now I need to determine if a model is a instance, and if
>>         it is, get the source model of instance.
>>           
>>             I know cloned object have a opterator called copyop, but
>>         seems instanced model do not have this operator.
>>         
>>             BTW, How can I change a cloned object to normal object? in
>>         XSI4.2 I just freeze the cloned object, save and open, then it
>>         will change to normal object. in XSI 5 this method(maybe a xsi
>>         bug) does not working.
>>         
>>         
>>             Thanks :)
>>
>
> ---
> Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body:
> unsubscribe xsi

--- Unsubscribe? Mail Majordomo(at)Softimage.COM with the following text in body: unsubscribe xsi

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.