VS:vsoStateGetNameChng: Difference between revisions
(add event handled in example) |
m (Transfer Orso to _c_) |
||
Line 50: | Line 50: | ||
----------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------------------- | ||
<remark> | <remark> | ||
[[User:CBM-c-|_c_]] (2016.05.14): Warning, actions that modify an object's name don't trigger a regen event, so vsoStateGetNameChng won't detect name changes until next regen. Actions that change the name can be: | |||
* editing the name object in the Data tab of the Object Info Palette | * editing the name object in the Data tab of the Object Info Palette | ||
* modifying the object's name from within the script in any fashion | * modifying the object's name from within the script in any fashion |
Latest revision as of 07:07, 30 December 2020
.VectorScript|VectorScript ..VS:Function Reference|Function Reference ..VS:Function_Reference_Appendix|Appendix
Description
Used to determine if the object name have changed. See VS:Parametric State Notifications#vsoStateGetNameChng
This function should be called during the parametric reset event: 3: {kParametricRecalculate}
FUNCTION vsoStateGetNameChng(
hObj : HANDLE;
VAR outOldName : STRING;
VAR outNewName : STRING) : BOOLEAN;
def vs.vsoStateGetNameChng(hObj): return (BOOLEAN, outOldName, outNewName)
Parameters
hObj HANDLE Handle to the parametric object. Obtained by call to VS:GetCustomObjectInfo outOldName STRING Output parameter. Old object name. outNewName STRING Output parameter. New object name.
Remarks
_c_ (2016.05.14): Warning, actions that modify an object's name don't trigger a regen event, so vsoStateGetNameChng won't detect name changes until next regen. Actions that change the name can be:
- editing the name object in the Data tab of the Object Info Palette
- modifying the object's name from within the script in any fashion
- automatic name deletion in case of name collision.
Setting your event enabled object to regen On Move is the best approach, as far as I see (even a copy in place is a move, for VW).
Example
VectorScript
BEGIN result := GetCustomObjectInfo(objectName, objectHand, recordHand, wallHand); vsoGetEventInfo(theEvent, message ); CASE theEvent OF 5: {kObjOnInitXProperties} BEGIN {enable eventing for this plug-in} SetPrefInt( 590, 1 ); {varParametricEnableStateEventing, kParametricStateEvent_ResetStatesEvent} result := SetObjPropVS(18, TRUE); {kObjXPropAcceptStates} END; 44: {kObjOnAddState} BEGIN message := vsoStateAddCurrent( objectHand, message ); END; 3: {kParametricRecalculate} BEGIN MoveTo( 5mm, 8mm ); CreateText( 'State events received after the last kParametricRecalculate:' ); IF vsoStateGetNameChng( objecthand, oldName, newName ) THEN BEGIN MoveTo( 0, -70mm ); CreateText( Concat( 'Obj name changed! oldName=', oldName, ' newName=', newName ) ); END; END; 41: {kObjOnWidgetPrep} BEGIN vsoSetEventResult(-8); { kObjectEventHandled } END;
Python
Version
Availability: from Vectorworks 2009
This is drop-in function.
See Also
VS:Parametric State Notifications | VS:vsoStateAddCurrent
VS:vsoStateGetPos | VS:vsoStateGetRot | VS:vsoStateGetParamChng | VS:vsoStateGetObjChng | VS:vsoStateGetLayrChng | VS:vsoStateGetExitGroup | VS:vsoStateGetNameChng