As soon as you explicitly provide to IsASortOf
method, a string representing the name of a type that doesn't exist
on your platform, you will get this error message.
Using the FindType function is a way for you to do this check
(existence of a given type on the platform) prior to working with
objects of that type.
Now let's mix Matt's suggestion with mine: the customer has
created a type named "LEGO_Part_CEXT" that derives from
VPMReference. This type defines the following attributes:
- LegoPartID (String)
- LegoPartFamily (String)
- LegoPartColor (String)
I'm writing an action that first checks whether that type
LEGO_Part_CEXT exist on the platform. If yes, I use a variable of
type VPMReference. I evaluate it somehow and then if during runtime
that variable happens to hold an object of the LEGO_Part_CEXT, I
write the corresponding attributes above.
If the LEGO_Part_CEXT is not defined on the platform, I simply
abort the process after telling the user the type is not existing
on the platform.
---------------------------------------------------------------------------------------------------------------------------------------
// Test whether LEGO_Part_CEXT type does exist on the platform, if
not, abort the process. Continue otherwise.
let LegoTypeAsString (String)
LegoTypeAsString = "LEGO_Part_CEXT"
let LegoType (Type)
LegoType = FindType( LegoTypeAsString )
// If LEGO_Part_CEXT is not existing on the platform, warn the user
and abort
if LegoType == NULL
{
PopupMessage( "The LEGO_Part_CEXT type is not an
existing type. Please contact your Administrator." )
exit
}
// From this point, LEGO_Part_CEXT is an existing type on the
platform, but do not refer to it explicitly,
// use the variable LegoTypeAsString containing the name of the
type.
let MyResourceDef (VPMReference)
// Assumption is made that the type LEGO_Part_CEXT derives from
VPMReference
/*
some code that evaluates MyResourceDef ...
MyResourceDef = ...
...
*/
if MyResourceDef.IsASortOf( LegoTypeAsString )
{
// Use SetAttributeXXX (XXX = String, Integer,
Boolean etc) because these methods are generic
MyResourceDef.SetAttributeString( "LegoPartID",
"12345" )
MyResourceDef.SetAttributeString(
"LegoPartFamily", "Plate" )
MyResourceDef.SetAttributeString(
"LegoPartColor", "Blue" )
}
Hope it helps.