lucioing Posted July 10, 2023 Share Posted July 10, 2023 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 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 Quote Link to comment
Vectorworks, Inc Employee klinzey Posted July 10, 2023 Vectorworks, Inc Employee Share Posted July 10, 2023 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) 1 Quote Link to comment
JBenghiat Posted July 10, 2023 Share Posted July 10, 2023 PTipo will give you the selected value as a string (‘Custom’, ‘10’, ‘20’, etc. ). You then have to use a series of if/then statements to control your code. In VS, there is no way to retrieve the index of the radio button. Quote Link to comment
lucioing Posted July 10, 2023 Author Share Posted July 10, 2023 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. Quote Link to comment
Recommended Posts
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.