Jump to content
Developer Wiki and Function Reference Links ×

Simple obj: a container


Recommended Posts

Hi!

I need to create containers, then I wrote a simple vs code.

 

PROCEDURE Container_00;
     
 VAR
    MyStr:STRING;
    s:REAL;
    L_out: REAL;
    L_in: REAL;
    W_out: REAL;
    W_in: REAL;
    H_out: REAL;
    H_in: REAL;

    i:INTEGER;
    btn:STRING;
    r1Handle:HANDLE;
    r2Handle:HANDLE;
    
    
 BEGIN
    SetUnits(0,1,0,25.399999999999999,'mm','mmq');
    
    s:=pSc;
    
    BeginXtrd(0, pHc);
        Rect(0, 0, pLc, pWc);    
        r1Handle:=LNewObj;
    
        Rect(s, s, pLc-s, pWc-s);
        r2Handle:=LNewObj;
   
        ClipSurface(r1Handle, r2Handle);
    
        DelObject(r2Handle);
    EndXtrd;
   

   
 END;
 
 Run(Container_00);

 

 

It does works correctly.

Now, I'd like to set some standard measure, by radio button, as shown below

Schermata2023-07-10alle16_10_38.thumb.png.8168d3994fe25a1069225b82d4a929b3.png

 

but I'm unable to get the choice.

 

First, CASE OF seems not to work with STRING but just INTEGER or CHAR... but I think to manage that.

The only procedure I found is 

 

GetCustomObjectChoice('Container_00', 'Tipo', 1);

 

which returns a STRING 🤔

besides, it doesn't make sense because I HAVE to set which ITEM (1) instead to GET the chosen item...

 

 

PROCEDURE Container_00;
     
 VAR
    MyStr:STRING;
    s:REAL;
    L_out: REAL;
    L_in: REAL;
    W_out: REAL;
    W_in: REAL;
    H_out: REAL;
    H_in: REAL;

    i:INTEGER;
    btn:STRING;
    r1Handle:HANDLE;
    r2Handle:HANDLE;
    
    
 BEGIN
    SetUnits(0,1,0,25.399999999999999,'mm','mmq');
    
    s:=pSc;
    btn:=pTipo;
    
    MyStr:=GetCustomObjectChoice('Container_00', 'Tipo', 1);
    
    

    CASE ???? OF
        1:   { custom size by edit field  }
        BEGIN
            L_out:=pLc;
            W_out:=pWc;
            H_out:=pHc;
        END;
            
        6:
        BEGIN     { any choice with  proper dimension   }   
            L_out:=12000;
            W_out:=2450;
            H_out:=2850;
        END;
        
    End;
    
    BeginXtrd(0, pHc);
        Rect(0, 0, pLc, pWc);    
        r1Handle:=LNewObj;
    
        Rect(s, s, pLc-s, pWc-s);
        r2Handle:=LNewObj;
   
        ClipSurface(r1Handle, r2Handle);
    
        DelObject(r2Handle);
    EndXtrd;
   

   
 END;
 
 
 Run(Container_00);

 

I can't found any example to manage the user choice by btn or menu.

 

Thank you for any help

 

Lucio

 

Link to comment
  • Vectorworks, Inc Employee

It's been a while since I have used a radio button in the OIP. the more standard method is a dropdown but I think it works the same way.

You should just be able to use  btn or pTipo rather than GetCustomObjectChoice() to return the chosen string.
It's better to use the value than get the index of the item in case you ever reorder the list or add a new item.
If you need the index then use GetPluginChoiceIndex('Container_00', 'Tipo',pTipo,ixd)

  • Love 1
Link to comment
21 minutes ago, klinzey said:

It's been a while since I have used a radio button in the OIP. the more standard method is a dropdown but I think it works the same way.

You should just be able to use  btn or pTipo rather than GetCustomObjectChoice() to return the chosen string.
It's better to use the value than get the index of the item in case you ever reorder the list or add a new item.
If you need the index then use GetPluginChoiceIndex('Container_00', 'Tipo',pTipo,ixd)

Thank you very much, klinzey!

It works very fine!

Thank you again!

 

L.

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