VS:IsNewCustomObject

From Vectorworks Developer
Revision as of 14:34, 12 August 2013 by Root (talk | contribs) (1 revision)
Jump to navigation Jump to search

.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix

Description

Function IsNewCustomObject returns whether the specified plug-in object is a new object, indicating that the object is being regenerated for the first time.


New object status is useful in specifying initialization and setup data, as well as calling initialization specific subroutines. This function should only be called in plug-in objects.

FUNCTION IsNewCustomObject(
objectName :STRING) : BOOLEAN;
def vs.IsNewCustomObject(objectName):
    return BOOLEAN

Parameters

objectName STRING Name of plugin object.

Remarks

Call from CustomObject scripts only. Returns true for new objects, meaning this is the first time the regeneration script is being called.

Returns false when a new object is placed into a wall, due to the dual regen issue. What you have to do is to create an invisible parameter to trap the new status on the first regen, then check that parameter in the second regen, react accordingly, then reset the parameter to its default value.

So this will evaluate on the first regen:

IF IsNewCustomObject(MyObject) & p__IsNew THEN SetRField(ghParm, MyObject, '__IsNew', 'True');

And this on the second regen:

IF p__IsNew & (hWall <> Nil) THEN BEGIN
SetRField(ghParm, MyObject, '__IsNew', 'False' );
DoMyStuffHere...
END;

IsNewCustomObject will never return TRUE on objects created by CreateCustomObjectPath.

Version

Availability: from VectorWorks8.0

See Also

VS Functions:

VS:GetCustomObjectInfo

VS Functions: [[VS:GetCustomObjectInfo]]