Cookie_NZ Posted January 25 Share Posted January 25 Hi all, I'm working on a project where we'd like to set the Z height of lighting devices from a worksheet. I made a worksheet with a 'Lighting Device.Z Location' column. But I can't seem to alter this value in the worksheet. Am I doing something wrong, or is this field not editable from a worksheet for some reason? Example file attached. Cheers, Cookie Bulb height.vwx Quote Link to comment
Vectorworks, Inc Employee TomWhiteLight Posted January 25 Vectorworks, Inc Employee Share Posted January 25 Hi Cookie, I don't believe this field is editable. Unless anyone else knows otherwise. I always thought that worksheets can currently be used to edit the data associated with a device but to make objects move via XYZ co-ordinates was not allowed. But food for thought. Quote Link to comment
Pat Stanford Posted January 25 Share Posted January 25 @Cookie_NZ I guess it is your lucky day. I don't want to be working on what I should be working on. Copy and paste the following script into a new blank Vectorscript from the Resource Manager. I recommend you name it MoveZ, but use what you want. Use a database header row formula of =RunScriptEdit('MoveZ') [or whatever you name it] Now when you type the new value into the database subrow cell for the object it will move the object to that height. Ask if not clear. Procedure MoveZ; {©2023 Pat Stanford - pat@coviana.com} {licensed under the Boost Software License 1.0} {https://github.com/boostorg/boost/blob/master/LICENSE_1_0.txt} {TL/DR Use as you want, attribution for source, No warranty} {Example Worksheet Script to allow moving a lighting device in the} {Z direction by entering a new Z value into a worksheet database cell} {The formula for the daatabase header row is =RunScript('MoveZ')} {Replace 'MoveZ' with whatever name you give the script.} VAR H1:Handle; R1,R2:Real; S1:String; B1:Boolean; N1:Integer; BEGIN H1:=WSScript_GetObject; If GetPrefInt(170)=1 then N1:=12 Else N1:=1; If WSScript_GetEdit(S1) THEN BEGIN If WSScript_GetEditObj(0, H1) THEN BEGIN If ValidNumStr(S1, R1) THEN BEGIN B1:=ValidNumStr(GetRField(H1,'Lighting Device','Z Location'),R2); Move3DObj(H1, 0,0,(R1-R2)); R1:=R1/N1; {Check for Feet/Inches and adjsut output} WSScript_SetResReal(R1); End; End; End Else BEGIN B1:=ValidNumStr(GetRField(H1,'Lighting Device','Z Location'),R2); R2:=R2/N1; WSScript_SetResReal(R2); End; End; Run(MoveZ); 3 Quote Link to comment
Sam Jones Posted January 25 Share Posted January 25 This is super cool. I love putting the RunScript command into the database row header. Quote Link to comment
Cookie_NZ Posted January 26 Author Share Posted January 26 Hi @Pat Stanford bless you for your procrastination! Although I think I've fallen at the last hurdle. I've added the script to the file and =RunScript('MoveZ') formula to the worksheet. But I can't edit the 'MoveZ' row data. (Get a 'ping' error sound when I try). If you get a moment, would you mind taking a look at the attached file and let me know what I've stuffed up in the process? @TomWhiteLight Interesting that XYZ data cannot be edited from a worksheet. Do you know if this is a technical limitation, or a design philosophy choice? Cheers, Cookie Bulb height (MoveZ).vwx Quote Link to comment
Pat Stanford Posted January 26 Share Posted January 26 1. Open the script in the Script Editor (easiest way is to right click on it from the Resource Manager). Click the Gear Icon at the top left. Does that give you an error message? If so, tell me what that message is so I can help troubleshoot. Maybe DM me the file you have the script in so I can take a look. 2. If the script compiles ok did you get a dialog box asking for permission to run the scripts? If not, it is likely that you saw that at some point and clicked the Never button. Unfortunately, the only way I know of to reset this is to reset all of the error messages from the VW Preferences. Session tab, Reset Saved Settings button at the top right. Quote Link to comment
Cookie_NZ Posted January 27 Author Share Posted January 27 Hi Pat, I've DMed you the file. Script compiles ok: I've tried 'Execute' & 'Always Execute'. Same behaviour. Cheers, Cookie Quote Link to comment
Pat Stanford Posted January 27 Share Posted January 27 This was my fault. I provided the wrong worksheet function. Since this script allows you to edit the value of the cell you need to use =RunScriptEdit('MoveZ') I have edited the original post with the correct information. 🤦♂️🤷♂️ Sorry. 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.