Jump to content
Developer Wiki and Function Reference Links ×

Setting Z height at PIO creation


Recommended Posts

I have a hybrid PIO whose z height I want to set at creation.  The following code in the Reset Event does not work.

 

                    Rect(0, 0, BarL, BarW);
                    BeginXTrd(0,BarT);
                        Rect(0, 0, BarL, BarW);
                    EndXtrd;
                    IF IsNew THEN

                        SetHeight(PIOHan, 36*UPI);

 

I want to set a height at creation, but allow the user to adjust the Z height after creation.

???

TIA
 

Link to comment

Unfortunately neither asdfasdf or asdfasdf work in the Reset Event

 

                    Rect(0, 0, BarL,  BarW);
                    BeginXTrd(0,BarT);
                        Rect(0, 0, BarL, BarW * -1);
                    EndXtrd;
                    IF IsNew THEN
                        BEGIN
                            AlrtDialog('This is a new bar');
                            Move3DObj(PIOHan, 0, 0, 36);
                            (* Move3D(0, 0, 36); *)
                        END;
 

I want to set the Z height of the newly created hybrid PIO.

Link to comment

Move3DObj() should work.  Is IsNew evaluating as true as expected?

 

Does the object have a 3D component?  If not, you should try SetEntityMatrix().  

 

You may need the below info to use SetObjectVar to let VS know that the object is 2D or 3D before it regenerates.  This is usually only needed if it is not hybrid

 

//    Symbol type constants used to set a custom object subtype while the object is being created.  SenEntityMatrix, for example, needs this to be set in order to be called.  
//    Use this API to set the symType if the object has yet to be regenerated.
//    NOTE: the symType is determined by the objects it has regenerated.   As such, you can't force an object to be a certain subtype with this API.
#define kCustomObjectSymType2DSym            0
#define kCustomObjectSymType3DSym            1
#define kCustomObjectSymTypeHybridSym        2
const short ovCustomObjectSymType        = 803;        //    short, Used to set the symType of a custom object - SymType is determined in 2011 by the contents of the object.  Before the regeneration the 
                                                    //    symType may be set using this API.  SetEntityMatrix need the symType to be kCustomObjectSymType2DSym
 

Link to comment

"IsNew" is evaluating as expected, since the alert does occur.

 

It has a 3D component, because it is a hybrid object

                    Rect(0, 0, BarL,  BarW);
                     BeginXTrd(0,BarT);
                         Rect(0, 0, BarL, BarW * -1);
                     EndXtrd;

Move3DObj() fails.  If it supposes to work, maybe it is in the wrong place {??}.

Link to comment

Well,

Move3DObj(PIOHan, 0, 0, 36);  works if I call it right after EndXtrd, but every time I change a value in the OIP after creation 36 is added to the Z value of the PIO and it starts climbing to the moon.

I tried to put an IsNew test like this

                    Rect(0, 0, BarL,  BarW);
                      BeginXTrd(0,BarT);
                          Rect(0, 0, BarL, BarW * -1);
                      EndXtrd;

                    IF IsNewCustomObject('Load Bar') THEN 
                        Move3DObj(PIOHan, 0, 0, 36);

 

But the IsNewCustomObject flag always seems to get cleared before last reset event.  I tried to make my own flag as a parameter set to TRUE as a default and then cleared after drawing, but that doesn't work.  

 

I don't mind positing the whole thing; it's simple and short.  I can't figure it out.

 

Link to comment

No.

The first time the PIO is placed, even without running in developer mode, it seems that the flag is cleared.  It ...seems... that the reset event is run more than once, the flag is cleared and after the final exit from the PIO code the object is drawn at z = 0 height.  If I don't do an "IsNewCustomObject" test or a custom one with a custom flag, the object is drawn at the desired 36 drawing units.  But, without such a flag, every time an edit is made to OIP 36 is added to the current z height, and the object climbs.

 

 

Link to comment

In terms of IsNewCustomObject, this is only true on the first regen run by definition, so the flag should be set to false for subsequent regen events, even if those regen events are part of one object insertion command. 

 

You might need to follow the advice in my first reply. I thought objects were usually assumed to be hybrid, but it’s possible you need to explicitly set the object variable to hybrid before running the move. Are you seeing any difference to inserting in a 2D or 3D view?  If so, that would definitely point to needing to flag as hybrid. 

Link to comment

Since the Move3DObj(PIOHan, 0, 0, 36); works just fine without the IsNew flag test, I would think that I don't need to explicitly set the object to hybrid.  So, I could keep resetting the flag, but then how do allow the user to set the Z height later?

 

S

Link to comment

The move that is working is probably during the second reset, and at this point the object has existing geometry (that's being replaced on reset), so VW has already flagged it as hybrid.  If you want the move to happen when IsNewCustomObject is true, the object may not have set its 2D / 3D flags yet.

Link to comment

So the question becomes when/how do I do this: set the height at 36(or some other default) upon insertion, and then let the user set the z height.

 

BEGIN
    GetVersion(Major,Minor,Maintenance,Platform);
    GetUnits(Fraction,Display,Format,UPI,UnitName,SquareName);
    Result := GetCustomObjectInfo(PIOName,PIOHan,PIORec,WallHdl);
    vsoGetEventInfo(EventMessage, MsgData);
    OK := GetLocalizedPlugInName(PIOName,LocalPIOName);
    BarW := PBWidth * -1;
    BarL := PBLength;
    BarT := PBThick;
    NewBar := IsNewCustomObject('Load Bar');

    CASE EventMessage OF

        kResetEventID:                {3}
            BEGIN
                ParamChangeFlag := (vsoStateGetParamChng(PIOHan,ParamChangeWidget,ParamChangeIndex,OldParam));
                IF (ParamChangeFlag=True) THEN 
                    BEGIN
                        
                    END; {IF (ParamChangeFlag=True) }
                ParamChangeTrig := FALSE;
                PIOChangeTrig := FALSE;
        
                Rect(0, 0, BarL,  BarW);
                BeginXTrd(0,BarT);
                    Rect(0, 0, BarL, BarW);
                EndXtrd;
                
                IF IsNewCustomObject('Load Bar') THEN 
                    Move3DObj(PIOHan, 0, 0, 36);
                                        
                vsoStateClear(PIOHan );

            END;
    
        kObjOnAddState: {44}
            BEGIN
                GetStateChange;
            END;

        kObjOnInitXProperties:        {5}
            BEGIN
                Result := SetObjPropVS (kObjXPropHasUIOverride,True);
                Result := SetObjPropVS(12, TRUE); {kObjXHasCustomWidgetVisibilities}
                SetPrefInt(590, 1 ); {kParametricEnableStateEventing}
                Result := SetObjPropVS (18,TRUE);    {kObjXPropAcceptStates}
                Result := vsoInsertAllParams;
                Result := SetObjPropVS(kObjXPropDataNameDisabled, TRUE);{kObjXPropDataNameDisabled}
                SetPrefInt (590,1);    {varParametricEnableStateEventing,ResetStatesEvent}
            END;
    
        kObjOnWidgetPrep:    {41}
            BEGIN
                WidgetPrep;
            END; {kObjOnWidgetPrep}
    
        kObjOnObjectUIButtonHit:
            BEGIN
                CASE MsgData OF
                    kRefreshBtnID:
                        BEGIN                
                        END;
                END;
            END; {kObjOnObjectUIButtonHit}
    END; {case}
    SetRField(PIOHan,PIOName, 'IsNewBar', 'FALSE');

END;
RUN(TruckLoadBar);

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