VS:IsNewCustomObject: Difference between revisions
m (1 revision) |
(expand my old notes, add indenting for clarity in the example script) |
||
Line 45: | Line 45: | ||
<code lang="pas"> | <code lang="pas"> | ||
IF IsNewCustomObject(MyObject) & p__IsNew THEN SetRField(ghParm, MyObject, '__IsNew', 'True'); | IF IsNewCustomObject(MyObject) & p__IsNew THEN | ||
SetRField(ghParm, MyObject, '__IsNew', 'True'); | |||
</code> | </code> | ||
Line 52: | Line 53: | ||
<code lang="pas"> | <code lang="pas"> | ||
IF p__IsNew & (hWall <> Nil) THEN BEGIN | IF p__IsNew & (hWall <> Nil) THEN BEGIN | ||
SetRField(ghParm, MyObject, '__IsNew', 'False' ); | SetRField(ghParm, MyObject, '__IsNew', 'False' ); | ||
DoMyStuffHere... | DoMyStuffHere... | ||
END; | END; | ||
</code> | </code> | ||
IsNewCustomObject will never return TRUE on objects created by CreateCustomObjectPath.</remark> | ([[User:Orso.b.schmid|Orso]] 2008.04.05): IsNewCustomObject will never return TRUE on: objects created by [[VS:CreateCustomObjectPath]], objects duplicated by alt-click + drag, by Duplicate command etc.</remark> | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
Line 67: | Line 68: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<version> | <version> | ||
Availability: from | Availability: from VectorWorks 8.0 | ||
</version> | </version> |
Revision as of 06:12, 19 February 2016
.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;
(Orso 2008.04.05): IsNewCustomObject will never return TRUE on: objects created by VS:CreateCustomObjectPath, objects duplicated by alt-click + drag, by Duplicate command etc.
Version
Availability: from VectorWorks 8.0
See Also
VS Functions: