Thomas W Posted Wednesday at 10:14 AM Share Posted Wednesday at 10:14 AM Hello, I'm new to the use of plug-ins, so I started by doing the various exercises of VS:Object_Events to understand the basis of operation and by looking for function examples on the forum and some information in these 2 files: MiniCadHookIntf. h and MiniCadCallBacks.h There is a lot of information, but it is interesting! I have a question about example 8: At the bottom of Example 8 it is stated that Get/SetObjArrow are deprecated since 2008 and it is advised to use Get/SetObjBeginningMarker and Get/SetObjEndMarker. According to my tests Get/SetObjArrow still works and using Get/SetObjBeginningMarker and Get/SetObjEndMarker you have to add vsoStateClear(objHand) before the end of kResetEventID otherwise vectorworks crashes when changing color or fill of 2d polygon. Is this the right solution and why should we do it on one function and not the other? Since in the explanation of VS:vsoStateClear it says "Must be called during the regen event 3 (kParametricRecalculate)" I wonder if this is also valid for kResetEventID. Below is the plugin script made with a 2d polygon and enabled for events. PROCEDURE Example081; CONST kObjOnInitXProperties = 5; kResetEventID = 3; kObjXPropAcceptsMarkers = 10; kObjXPropAcceptsNoneMarkers = 0; kObjXPropAcceptsBeginningOnlyMarkers = 1; kObjXPropAcceptsEndOnlyMarkers = 2; kObjXPropAcceptsBothMarkers = 3; kCR = Chr(13); VAR theEvent, theButton :LONGINT; result :BOOLEAN; objHand, recHand, wallHand, pathHand, dupeHand :HANDLE; objName :STRING; gArrowIndex :LONGINT; gMarkerSize :REAL; gMarkerAng :INTEGER; begArr, endArr :BOOLEAN; width :REAL; thickBasis :INTEGER; thickness :REAL; visibility :BOOLEAN; ok :BOOLEAN; BEGIN vsoGetEventInfo(theEvent, theButton); CASE theEvent OF {User has single-clicked the object's icon.} {L'utilisateur a cliqué une fois sur l'icône de l'objet.} kObjOnInitXProperties: BEGIN {This allows the object to accept marker setting from the Attributes palette.} {Cela permet à l'objet d'accepter le réglage du marqueur de la palette Attributs.} result := SetObjPropCharVS(kObjXPropAcceptsMarkers, Chr(kObjXPropAcceptsBothMarkers)); END;{ kObjOnInitXProperties } {Object reset has been called.} { Object reset – redraw everything } { Réinitialisation de l'objet - tout redessiner } kResetEventID: BEGIN IF GetCustomObjectInfo(objName, objHand, recHand, wallHand) THEN BEGIN pathHand := GetCustomObjectPath(objHand); dupeHand := CreateDuplicateObject(pathHand, objHand); {Get the settings from objHand and apply them to dupeHand.} {Obtenez les paramètres de objHand et appliquez-les à dupeHand.} {Note that Get/SetObjArrow are obsolete in 2008.} {Use Get/SetObjBeginningMarker and Get/SetObjEndMarker in 2008 or above.} { GetObjArrow(objHand, gArrowIndex, gMarkerSize, gMarkerAng, begArr, endArr); } { GetObjBeginningMarker (h, style, angle, size, width, thickBasis, thickness, visibility); } ok := GetObjBeginningMarker(objHand, gArrowIndex, gMarkerAng, gMarkerSize, width, thickBasis, thickness, visibility); AlrtDialog(Concat('gArrowIndex : ', gArrowIndex, kCR, 'gMarkerAng : ', gMarkerAng, kCR, 'gMarkerSize : ', gMarkerSize, kCR, 'width : ', width, kCR, 'thickBasis : ', thickBasis, kCR, 'thickness : ', thickness, kCR, 'visibility : ', visibility)); ok := SetObjBeginningMarker(dupeHand, gArrowIndex, gMarkerAng, gMarkerSize, width, thickBasis, thickness, visibility); ok := GetObjEndMarker(objHand, gArrowIndex, gMarkerAng, gMarkerSize, width, thickBasis, thickness, visibility); AlrtDialog(Concat('gArrowIndex : ', gArrowIndex, kCR, 'gMarkerAng : ', gMarkerAng, kCR, 'gMarkerSize : ', gMarkerSize, kCR, 'width : ', width, kCR, 'thickBasis : ', thickBasis, kCR, 'thickness : ', thickness, kCR, 'visibility : ', visibility)); ok := SetObjEndMarker(dupeHand, gArrowIndex, gMarkerAng, gMarkerSize, width, thickBasis, thickness, visibility); { SetObjArrow(dupeHand, gArrowIndex, gMarkerSize / GetPrefReal(152), gMarkerAng, begArr, endArr); } END;{ if } vsoStateClear(objHand); END;{ kResetEventID } END;{ case } END; RUN(Example081); Thank you in advance for your feedback and have a nice day, Thomas Quote Link to comment
Thomas W Posted Wednesday at 11:22 AM Author Share Posted Wednesday at 11:22 AM Attached are the 2 versions in .vso Version 08 is as in the example and version 081 is with functions Get/SetObjBeginningMarker and Get/SetObjEndMarker. If in version 081 you put vsoStateClear(objHand); in comment or if you delete it vectorworks crashes. I was wondering why this was not the case in version 08 with Get/SetObjArrow procedures. Thanks, 08-PathAcceptMarkersAttr.vso 081-PathAcceptMarkerAttr.vso Quote Link to comment
Pat Stanford Posted Wednesday at 02:34 PM Share Posted Wednesday at 02:34 PM I can't help with the PIO part, but I can comment on the history of markers. As the comments say Get/SetObjArrow are deprecated. In VW2008 there were major changes made to how markers are set on objects therefore the change to BeginningMarker and EndMarker calls. You definitely want to be using the Marker calls. While the ObjArrow might still be working in VW2023 (which actually surprises me), you never know what version will break them and then you will have to go back and fix your PIOs that use those calls. 1 Quote Link to comment
Thomas W Posted Wednesday at 03:12 PM Author Share Posted Wednesday at 03:12 PM Thank you for your feedback on the history of markers. I must have made errors while writing the script and calling Get/SetObjBeginningMarker and Get/SetObjEndMarker or vsoStateClear(objHand). Version 081 of .vso crashes vectorworks when I change fills or colors, while version 08 with deprecated procedures works! If anyone sees what's wrong with writing the script... Thanks! Quote Link to comment
Thomas W Posted Friday at 06:43 AM Author Share Posted Friday at 06:43 AM Hello, I modified the script version above to make the plugin work with the new functions Get/SetObjBeginningMarker and Get/SetObjEndMarker. Quote Link to comment
Thomas W Posted Friday at 06:57 AM Author Share Posted Friday at 06:57 AM Sorry I had a 403 error when i wanted to answer... (?) Quote Link to comment
Thomas W Posted Friday at 06:58 AM Author Share Posted Friday at 06:58 AM The script below now works for me without ceashing vectorworks, with a 2d polygon plugin and runtime options enabled. I just don't know if it is advisable to put a vsoStateClear function before the end of kResetEventID, if anyone has an opinion on this point I would appreciate it! Quote Link to comment
Thomas W Posted Friday at 07:08 AM Author Share Posted Friday at 07:08 AM Well I can no longer put a code snippet in the message, I get a 403 error each time, I restarted, disconnected from the forum and reconnected, the same.... So I want to put the script as a text file as an attachment, but it make an other error code -200 Quote Link to comment
Pat Stanford Posted Friday at 03:06 PM Share Posted Friday at 03:06 PM Test code snippet. To see if I can post without 403 error. If you can see this, please try again to post your snippet. @Thomas W 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.