Jump to content
Developer Wiki and Function Reference Links ×

Plug in and Object Events


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

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!

 

Link to comment

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

 

errorcode.thumb.png.ad850f128121ca35396a2a2364a780b1.png

Link to comment

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!

Link to comment

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...

Link to comment

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,

Link to comment

Hello,

 

For information I tried to send the complete code from home and I have the same error message 403 forbidden.

So it would be more from the content of the message than from the firewall of my workplace server.

I will see if it reproduces with other messages...

 

Have a great day,

 

Thomas

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...