Exit
  • Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
  • 한국 커뮤니티
0

How to recreate a Boss instance when import IDML?

Guest
Apr 23, 2011 Apr 23, 2011

Hi guys,

I have created a customized model and exported it to IDML.

From the PersistentList sample, I found that it recreate the Customized Object with UID when the Create event is invoke.

But, in my code, the Create event is not invoked. Do you have any suggestion about this? Any suggestion is appreciated.

Below is the resource added to the .fr.

resource VersionedScriptElementInfo(10)
{
    //Contexts
    {
        kFiredrakeScriptVersion, kCoreScriptManagerBoss, kInDesignAllLanguagesFS, k_Wild,
        kFiredrakeScriptVersion, kCoreScriptManagerBoss, kInDesignServerAllLanguagesFS, k_Wild,
    }
   
    //Elements
    {   
        Suite
        {
            kMySuiteScriptElement,
            s_MySuite,
            "persistent list suite",
            "Terms applicable to PersistList operations",
        }
        // Defines new script element object for this plug-in's preferences
        Object
        {
            kMyObjectScriptElement,    // this object's script element ID
            c_My,                        // ScriptID
            "MyModel",        // name
            "MyModel",        // description
            kMy_CLSID,           // Windows CLSID
            NoPluralInfo,                    // CollectionElementType (scriptID, name, descr, CLSID)
            kUniqueIDBasedObjectScriptElement,// base object script element ID
            kMySuiteScriptElement,    // suite script element ID
        }

        Event
        {
            kMyDataCreateEventScriptElement,
            e_Create,
            "add",
            "Create a new ^Object",
            ObjectType(kContainerObjectScriptElement),
            "The new ^Object",
            {
                p_Name,
                "name",
                "The name property of the new ^Object",
                StringDefaultType(kMyDataItemNameDefault),
                kOptional,
                WITHPROPERTIESPARAM
            }
        }
   
        Provider
        {
            kMyScriptProviderBoss,
            {
                Parent{ kDocumentObjectScriptElement },    //kDocumentObjectScriptElement, kStoryObjectScriptElement
                RepresentObject{ kMyObjectScriptElement },       
               
                Event{ kMyDataCreateEventScriptElement },                       
                Property{ kNamePropertyScriptElement, kReadWrite },       
            }
        }
    }
};

TOPICS
SDK
725
Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Mentor ,
Apr 23, 2011 Apr 23, 2011

I'm not sure about the use of kInDesignAllLanguagesFS - I have kWildFS in that place but that could be a deprecated approach.

As you provide no plural info in your object, this appears to be a singleton object (similar to preferences).

In that case you'll need no "create" method at all, instead in the Provider section add ParentProperty { kMyDataPropertyScriptElement, kReadOnly }.

In case you want to support multiple of your models, fix the Object to have a plural info.

Note that the meaning of Event has changed, it is now "Method" while "Event" is now a notification that feeds scripted event listeners.

Besides in CS5 for "create" you should be using CollectionMethod rather than Method, and also provide a "count" CollectionMethod.

In CS4 use CollectionEvent instead of Event

Dirk

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Guest
Apr 24, 2011 Apr 24, 2011
LATEST

Dirk,

Thanks for your reply. What I am exporting and importing are instances from the same Boss.

So, I think I need to add the plural info. But, on CS4, the event can NOT be invoked, yet.

The object is an owned item, it will be attached to a character and put into owneditemstrand of text model.

What is more should I implement to make the event be called when importing the IDML?

Then, I can recreate this model and attached this model to a character and put it into the owneditemstrand.

Below is the resource,

     Class
    {
        kMyModelBoss,
        kInvalidClass,
        {
            /** See IHidTxtModel and HidTxtModel.
            */       
            IID_IMYMODEL, kMyModelImpl,
            IID_IOWNEDITEM, kMyOwnedItemImpl,
            IID_IPMPERSIST,kPMPersistImpl,
            IID_ISCRIPT,        kMyScriptImpl,
        }
    },

resource VersionedScriptElementInfo(10)
{
    //Contexts
    {
        kFiredrakeScriptVersion, kCoreScriptManagerBoss, kInDesignAllLanguagesFS, k_Wild,
        kFiredrakeScriptVersion, kCoreScriptManagerBoss, kInDesignServerAllLanguagesFS, k_Wild,
    }
   
    //Elements
    {   
        Suite
        {
            kMySuiteScriptElement,
            s_MySuite,
            "persistent list suite",
            "Terms applicable to PersistList operations",
        }
        // Defines new script element object for this plug-in's preferences
        Object
        {
            kMyObjectScriptElement,    // this object's script element ID
            c_MyModel,                        // ScriptID
            "MyModel",        // name
            "MyModel",        // description
            kMyModel_CLSID,           // Windows CLSID
            c_MyModels,
            "MyModels",        // name
            "MyModels",        // description
            kMyModels_CLSID,
            kUniqueIDBasedObjectScriptElement,// base object script element ID
            kMySuiteScriptElement,    // suite script element ID
        }

        Event
        {
            kMyDataCreateEventScriptElement,
            e_Create,
            "add",
            "Create a new ^Object",
            ObjectType(kContainerObjectScriptElement),
            "The new ^Object",
            {
                p_Name,
                "name",
                "The name property of the new ^Object",
                StringDefaultType(kMyDataItemNameDefault),
                kOptional,
                WITHPROPERTIESPARAM
            }
        }
  
        Provider
        {
            kMyScriptProviderBoss,
            {
                Parent{ kDocumentObjectScriptElement },   
                RepresentObject{ kMyObjectScriptElement },       
               
                CollectionEvent{ kMyDataCreateEventScriptElement },                       
       
                Property{ kNamePropertyScriptElement, kReadWrite },       
            }
        }
    }
};

Translate
Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines