Thomas W Posted May 24 Share Posted May 24 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 May 24 Author Share Posted May 24 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 May 24 Share Posted May 24 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 May 24 Author Share Posted May 24 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
Thomas W Posted 12 hours ago Author Share Posted 12 hours ago Test message without code Hello, I modified the script version above to make the plugin work with the new functions Get/SetObjBeginningMarker and Get/SetObjEndMarker. I found a script where @MullinRJ uses these functions here : Convert Objects in Symbol to ByClass The script below now works for me without crashing 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! Could someone tell me how to remove the attachments from the above post and how to change the title of the post? Thanks and good day! Quote Link to comment
Thomas W Posted 11 hours ago Author Share Posted 11 hours ago When I just reply with text it works I don't get a 403 error. As soon as I want to put code either with the add code function or by pasting the raw text it gives me a 403 error, if I paste a text file it's the same. I just replied to a message in my inbox and I have the same problem. I'm having a hard time understanding the cause of all this... Quote Link to comment
Thomas W Posted 11 hours ago Author Share Posted 11 hours ago just one line of code Quote Link to comment
Thomas W Posted 11 hours ago Author Share Posted 11 hours ago just ten line of code just ten line of code just ten line of code just ten line of code just ten line of code just ten line of code just ten line of code just ten line of code just ten line of code just ten line of code Quote Link to comment
Thomas W Posted 10 hours ago Author Share Posted 10 hours ago Without copying and pasting text and writing the code directly, it doesn't seem to make any mistakes. I copy either from vector or from a text file. Below is a test by rewriting the lines after : dupeHand := CreateDuplicateObject(path, objHand); IF GetObjBeginningMarker(objHand, gArrowIndex, gMarkerAng, gMarkerSize, width, thickBasis, thickness, visibility) THEN B := SetObjBeginningMarker(dupeHand, gArrowIndex, gMarkerAng, gMarkerSize, width, thickBasis, thickness, visibility); If GetObjEndMarker(objHand, gArrowIndex, gMarkerAng, gMarkerSize, width, thickBasis, thickness, visibility) THEN B := SetObjEndMarker(dupeHand, gArrowIndex, gMarkerAng, gMarkerSize, width, thickBasis, thickness, visibility); END;{ if then begin } { vsoStateClear(objHand); } END;{ kResetEventID } With this function the script works like with the old function, I just don't know if it is necessary or if it is advisable to put vsoStateClear(objHand); before the end of KResetEventID? Thanks, Quote Link to comment
MullinRJ Posted 2 hours ago Share Posted 2 hours ago I have always placed vsoStateClear() as the last statement in event 3 (kResetEventID). I think you're good if you remove the comment brackets. Also, I think it is a necessary command, but I've never removed it to see what happens. Raymond 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.