Paolo Posted Monday at 03:01 PM Share Posted Monday at 03:01 PM I have an event-enabled plugin that manages materials. I'd like to be notified when the material settings change. I see there is the function: FUNCTION vsoStateMaterialChng( hObj : HANDLE; VAR materialID : INTEGER; VAR deleted : BOOLEAN; VAR previousTexture : INTEGER): BOOLEAN; I have placed it in the reset event, in the same manner as IsNewCustomObject(parmName) or vsoStateGetParamChng( parmHand, widgID, prmIndex, oldValue ) but I noticed that vsoStateMaterialChng get never called whenever I change materials or set the material checkbox on / off! Is there a reason? How should be it used? Quote Link to comment
BillW Posted Monday at 05:23 PM Share Posted Monday at 05:23 PM I'm in the same boat. I could never get vsoStateMaterialChng to work so I gave up. I assume you are invoking (in kObjOnInitXProperties:) the Material check box and material list with result := SetObjPropVS(kObjXPropSupportBuildingMaterialInOIP, TRUE ); Just a thought (possible workaround) - you could try creating an invisible "Material" parameter ie "__material". In the kResetEventID: you could get the current Material settings (with GetObjMaterialName), compare with "__material" value, if different then material has changed and do somethng, then store current material settings to "__material" - if that makes sense. I suspect maybe vsoStateMaterialChng may be invoked by a change to "__material" but who knows. 1 Quote Link to comment
Paolo Posted Monday at 06:25 PM Author Share Posted Monday at 06:25 PM @BillW Quote I assume you are invoking (in kObjOnInitXProperties:) the Material check box and material list with result := SetObjPropVS(kObjXPropSupportBuildingMaterialInOIP, TRUE ); Yes, I have the material controls in the OIP, but I need some notification when the user changes it… I'll give your suggestion a try, thank you. Quote Link to comment
Paolo Posted Wednesday at 02:26 PM Author Share Posted Wednesday at 02:26 PM @BillW I got your suggestion, and applied it this way: Added a (hidden) _Material parameter of type Static text I already have a parameter Material of type Material I declare in Vars materialChange : BOOLEAN; in the prep event: kObjOnWidgetPrep: BEGIN … old_Material_Name := GetRField(parmHand, parmName, '_Material'); {parmHand and parmName are from GetCustomObjectInfo()} result := GetObjMaterialName(parmHand, new_Material_Name); {when the material checkbox is deselected, new_Material_Name = ''} {check if old and new differs.} materialChange := Not (old_Material_Name = new_Material_Name); {now set _Material to store the new_Material_Name} setRField(parmHand, parmName, '_Material', new_Material_Name); {at this point it's necessary to reset the plugin to get this working} if materialChange then resetObject(parmHand); … vsoSetEventResult( -8 {kObjectEventHandled} ); END; later, in the reset event I can get the updated material of the plugin via GetObjMaterialHandle(parmHand). There is no way to do this through vsoStateGetParamChng() or the more specific vsoStateMaterialChng() that seems to not work at all… Quote Link to comment
BillW Posted Wednesday at 02:41 PM Share Posted Wednesday at 02:41 PM Well done. You do wonder where or how vsoStateMaterialChng() actually works. Overall, it would be nice if the scripting environment got a bit more love or at least some more examples. Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.