Jump to content
Developer Wiki and Function Reference Links ×

Plug in and Object Events


Thomas W

Recommended Posts

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

 

Link to comment

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

Link to comment

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.

  • Like 1
Link to comment

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!

 

Link to comment

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.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...