sle7en7 Posted July 17, 2015 Author Share Posted July 17, 2015 Thanks Pat, have a good one. Quote Link to comment
Benjamin Weill Posted July 17, 2015 Share Posted July 17, 2015 I'm sorry, I'm a bit a layman when it comes to scripting. How do I actually attach this script to a record format? Having part of a record format populate from a coordinate (specifically the Y coordinate) of a symbol has been something I've wanted for a while. Unfortunately, I don't know what the steps are between reading this script on the forums and having it work. Thanks!! Quote Link to comment
Pat Stanford Posted July 17, 2015 Share Posted July 17, 2015 You don't attach the script to the record. Unfortunately. When you run the script it will take the coordinated and store the data you specify in a field in the record. You can then access that data from the OIP and/or a worksheet. If you move the object and don't rerun the script then the data in the record will be out of date, but you will not have any way of know that. A good place to start to learn more about Vectorscript is this article over in the Vectroscript Resource Share forum: https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=93218#Post93218 Regards, Pat Quote Link to comment
Jake DeGroot Posted July 9, 2016 Share Posted July 9, 2016 This has been a super useful thread. Thanks, guys! I am adapting Pat's script from https://techboard.vectorworks.net/ubbthreads.php?ubb=showflat&Number=212682#Post212682 and it's working great as long as the symbols are loose on the drawing. How can I modify it so it would work even if the symbols are nested within another symbol? Quote Link to comment
Jake DeGroot Posted July 9, 2016 Share Posted July 9, 2016 Never mind! Answered my own question: ForEachObject(MyProc,(R IN [MyRec]) AND INSYMBOL); Thanks again! Quote Link to comment
nippaz Posted April 26, 2018 Share Posted April 26, 2018 On 7/6/2015 at 3:32 PM, Pat Stanford said: What you don't say is the requirements for using the script. 1. You must have a record in the file named "COORDINATE" in the file. 2. That record must have fields named "x coodinate" and "y coodinate" 3. The record must be attached to each object to want to locate prior to running the script. 4. All the script does is move the X and Y coordinates (insertion point) of the object into the COORDINATE record. Anything else you do with them from there is separate. So, you formatting of the output of the data will depend on how you are using the record data. A good first step would be to edit the Coordinate format and make sure the x and y fields are defined as Numbers and formatted as Dimensions (click the Format button). The format of the display should then automatically flow from the Unit settings of the file. If you are using a worksheet make sure the column (or cells) displaying the data is/are also formatted as Dimension. Two other hints: 1. For a script with this few lines, I would hard code the Record and Field names rather than assigned them to variables. Yes if you have to edit the names you have to change them in two places rather than one, but to me it makes the script easier to understand. 2. I would try to make Record and Field names a single string without the spaces. i.e. x_coordinate rather than x coordinate. There are places where a single "word" can be used without the surrounding quotes necessary when you have spaces. Here is a script that actually runs. There is no default fields for X and Y in MyRec, so it can't get the data. You have to use some sort of command to query the object and get that data and store it not the record. In this case I chose GetSymLoc, but depending on the object type you have that might or might not get you the point you are interested in. Procedure Set_CoordinateField; const MyRec = 'COORDINATE'; My_Xcoordinate = 'x coordinate'; My_Ycoordinate = 'y coordinate'; var Item_X, Item_Y:Real; Procedure MyProc(H2:Handle); Begin GetSymLoc(H2,Item_X,Item_Y); SetRField(H2,MyRec,My_Xcoordinate,Num2StrF(Item_X)); SetRField(H2,MyRec,My_Ycoordinate,Num2StrF(Item_Y)); End; Begin ForEachObject(MyProc,((R IN [MyRec]))); End; Run(Set_CoordinateField); In my attempt to learn this exactly, @sle7en7 @Pat Stanford would either of you mind explaining 'MyRec'? I can't locate it as a function. The Line Procedure MyProc(H2:Handle); - again here, what's MyProc? What does H2 refer to? and why is 'Handle' important? I'm just trying to understand the use of the arguments. @Pat Stanford you mention "1. For a script with this few lines, I would hard code the Record and Field names rather than assigned them to variables. Yes if you have to edit the names you have to change them in two places rather than one, but to me it makes the script easier to understand." What do you mean by Hard Coding 'Record and Field' names rather than assigning them variables? I apologize for the newb question. 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.