Jump to content
Sam Jones

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
 

Share this post


Link to post

You want Move3D().  (Double check the function name)  SetHeight is for objects with width and height parameters, like a rectangle.

Share this post


Link to post

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.

Share this post


Link to post

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
 

Share this post


Link to post

"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 {??}.

Share this post


Link to post

Move3DObj() is definitely the one to use. Call it right after EndXtrd; I use this extensively in exactly the same context.

Share this post


Link to post

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.

 

Share this post


Link to post
20 minutes ago, Sam Jones said:

But the IsNewCustomObject flag always seems to get cleared before last reset event.

 

What do you mean by this?  Are you looking at multiple reset events?  If so, it would only be true on the first one. 

Share this post


Link to post

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.

 

 

Share this post


Link to post

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. 

Share this post


Link to post

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

Share this post


Link to post

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.

Share this post


Link to post

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);

Share this post


Link to post

Hav you tried my suggestion yet?  

 

IF IsNewCustomObject('Load Bar') THEN BEGIN
	SetObjectVariableInt( PIOHan, 803, 2 );
	Move3DObj(PIOHan, 0, 0, 36);
END;

 

Share this post


Link to post

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.


 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...