Jump to content
Developer Wiki and Function Reference Links ×

Moving Accessories using VS


Recommended Posts

When one uses the Accessory Insertion tool to place an iris on a Source 4 Lighting Device, the iris gets placed at the front of the light.  The following code should move the iris (the only accessory) to the gate position on the S4 Lighting Device.  Instead, nothing happens.  I'm missing something yet again.

 

PROCEDURE MoveAccessory;
{$DEBUG}

CONST
    kcr = chr(13);
    
VAR
    TheLight        :HANDLE;
    TheAcc        :HANDLE;
    AccNumber    :LONGINT;
    AccIndex        :LONGINT;
    
    PosX, PosY    :REAL;
    PosRot        :REAL;
    
    Rot3DX        :REAL;
    Rot3DY        :REAL;
    Rot3DZ        :REAL;

    Pos3DX        :REAL;
    Pos3DY        :REAL;
    Pos3DZ        :REAL;
    VWAccFile    :STRING;
    
    Index            :INTEGER;
    OK                :BOOLEAN;
    
BEGIN
    TheLight := FSActLayer;
    AccNumber := LDevice_GetAccCount(TheLight, 0);
    IF AccNumber > 0 THEN
        BEGIN
            AccIndex := 0;
            LDevice_GetAccPos2D(TheLight, 0, AccIndex, PosX, PosY, PosRot);
            LDevice_GetAccPos3D(TheLight, 0, AccIndex, Rot3DX, Rot3DY, Rot3DZ, Pos3DX, Pos3DY, Pos3DZ);
            
            PosY := 4.01;
            Pos3DZ := -16.08;
            LDevice_SetAccPos2D(TheLight, 0, AccIndex, PosX, PosY, PosRot);
            LDevice_SetAccPos3D(TheLight, 0, AccIndex, Rot3DX, Rot3DY, Rot3DZ, Pos3DX, Pos3DY, Pos3DZ);

            ResetObject(TheLight);
        END;
    
END;
RUN(MoveAccessory);

Link to comment

I don't know what you mean by "absolute position" , but PosY displays 0.  I assign it 4.01, and it does not move.  I assign it -4.01, and it does not move.  The fact that it displays 0 is, in and of itself, suspicious.  A 0 value should be the insertion point of the fixture, or so I thought, but the accessory is at the front of the light.  All sorts of stuff here seems to be just wrong.  I hope it can be either explained or fixed, preferably both.

Link to comment
Guest Yordan Kostadinov

Hi @Sam Jones,

I can confirm there's an issue with both LDevice_SetAccPos2D and 3D, they do not currently work. This will be fixed in the upcoming SP3. Also, for LDevice_Get/SetAccPos3D, first are the position parameters, then the rotation, in your example they are swapped. (Edit - I saw it was wrong in the help too, so I corrected it).

Also, a minor change in behavior of LDevice_GetAccPos2D and 3D occurs in SP3 - it will return the location where the accessory is rendered (in neutral position, focusing is handled by the lighting device internally), because in SP2 it returned location values only if its position is customized, but not if in default position.

 

Also, as of SP3 Vectorworks supports Body accessories. Attach the Parts record with Body checked to the accessory symbol, and it will be positioned on the insertion point in 2D and the rotation center in 3D, not the front.

 

Thanks for reporting the problem and let me know if you have more questions.
Yordan

Link to comment

Yordan,

Thank you.  I am looking forward to the SP3 fixes and additions.  I think what you described will work well as long as we can successfully reposition accessories as needed with VS.  Checking the Body in the Parts record is an interesting and useful addition.  There will be other accessories that are custom that I will need to reposition, but that should be my issue not VW's.

For example, some users may wish to have stirrups attached to Fixtures and Static Accessories, but their default placement may vary from user to user, hence my need for the VS placement calls.  Thanks again, and I'm looking forward to getting this all rung out.

 

Link to comment

"Absolute positioning" is the method you appeared to be using to reset the accessory's location.

Your code was setting it to a coordinate location rather than directing it some distance from wherever it was currently located.

The latter being referred to as "relative positioning".

Link to comment
  • 2 weeks later...
On 3/11/2021 at 12:08 PM, Yordan Kostadinov said:

I can confirm there's an issue with both LDevice_SetAccPos2D and 3D, they do not currently work. This will be fixed in the upcoming SP3.

 

In SP3, build 587753, the code below, which incorporates your correction, does not move the iris that has been placed at the front of the light by Lighting Accessory tool.

Am I doing something wrong, or did the fix not get into SP3?

 

PROCEDURE MoveAccessory;
{DEBUG}

CONST
    kcr = chr(13);
    
VAR
    TheLight        :HANDLE;
    TheAcc        :HANDLE;
    AccNumber    :LONGINT;
    AccIndex        :LONGINT;
    
    PosX, PosY    :REAL;
    PosRot        :REAL;
    
    Rot3DX        :REAL;
    Rot3DY        :REAL;
    Rot3DZ        :REAL;

    Pos3DX        :REAL;
    Pos3DY        :REAL;
    Pos3DZ        :REAL;
    VWAccFile    :STRING;
    
    Index            :INTEGER;
    OK                :BOOLEAN;
    
BEGIN
    TheLight := FSActLayer;
    AccNumber := LDevice_GetAccCount(TheLight, 0);
    IF AccNumber > 0 THEN
        BEGIN
            AccIndex := 1;
            LDevice_GetAccPos2D(TheLight, 0, AccIndex, PosX, PosY, PosRot);
            LDevice_GetAccPos3D(TheLight, 0, AccIndex, Pos3DX, Pos3DY, Pos3DZ, Rot3DX, Rot3DY, Rot3DZ);
AlrtDialog(CONCAT('PosY = ', PosY, kcr,
                        'Pos3DZ = ', Pos3DZ));
            PosY := -4.01;
            Pos3DZ := -16.08;
            LDevice_SetAccPos2D(TheLight, 0, AccIndex, PosX, PosY, PosRot);
            LDevice_SetAccPos3D(TheLight, 0, AccIndex, Pos3DX, Pos3DY, Pos3DZ, Rot3DX, Rot3DY, Rot3DZ);

            ResetObject(TheLight);
        END; {IF AccNumber > 0 }
    
END;
RUN(MoveAccessory)

 

 

Link to comment
Guest Yordan Kostadinov

Hi @Sam Jones,

 

I see only one problem with this code:

6 hours ago, Sam Jones said:

AccIndex := 1;

Note that the new functions uses 0 based indexing, the script will work as expected with AccIndex := 0;

 

Let me know if you have further problems.

Regards,

Yordan

Link to comment

The new functions seem to work well.  The next question is how can I retrieve the names of the accessory symbols being used?  

LDevice_GetParamStr() seems to require a string (universal name) to get a string.  I would like to retrieve the name of the symbol being used at a specified accessory index.

Thx

Link to comment
  • Vectorworks, Inc Employee

The UniversalName required by the function is the Universal Parameter name field, in this case "Symbol Name".

We use the same filed names as the lighting device for accessories and cells.

SymbolName  := LDevice_GetParamStr(handle, cellIndex, accessoryIndex, 'Symbol Name')

Link to comment

Cool.  Seems obvious now.

 

Kevin and Yordan,  

Despite what seemed to be some hiccups during the beta period,  I think the Accessory implementation is very good.  I haven't played with multiple cells yet, so that may be an issue, but both the functions available to the user and to VS seem to work well.  I have only one or two tools that I think are necessary for me to make.  The VW UI for accessory editing is a little arcane, but once figured out, it is simple and fairly efficient, much better than the old way.  Some caviats:  I haven't checked the interaction with LW, I haven't used the Instrument Summary yet, and I haven't worked with multiple cells.  Those three scare me a bit, but still, good job.

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