Pat Stanford Posted August 19, 2008 Share Posted August 19, 2008 This is the latest version of a script that is discussed in several other threads. This script creates a worksheet listing all of the possible fields of the first selected PIO on the active layer. It does not work on objects in walls, you will have to put a sample object directly on the layer. The text in column B is exactly what needs to be pasted into a database header cell (preceeded by an equals sign "=") to put the formula into that column. This version has been modified to individually quote the record name and field name so names with spaces will work properly. It also now display the default field name if not localized name is available. A menu item version (put it in your user datafolder (see below)) is available for download at: http://vectortasks.com/VWFreebies/VWFreebies.html On Windows, C:\Documents and Settings\username\Application Data\Nemetschek\VectorWorks\xx\Plug-Ins, where xx represents the current VectorWorks version number, and username refers to the name of the current user logged into the computer On Macintosh, /Users/username/Library/Application Support/VectorWorks/xx/Plug-Ins, where xx represents the current VectorWorks version number, and username refers to the name of the current user logged into the computer Pat (***** Copy script from here down & paste into a VS Editor window ******) Procedure GetPIORecordFields; {Creates a worksheet showing the display and field names} {for the first selected object on the active layer} {Useful for determining the record.field names required} {for use in a worksheet.} {January 30, 2008} {? 2008, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {Modified 8/19/08 Pat Stanford} {Now puts quotes around both record and field instead of both combined} {Modified 8/19/08 Pat Stanford} {Now displays non-localized field names if no localization} Var H1 ,H2 :Handle; S1,S2,S3,S4,S5 :String; N1,N2 :Integer; WSH :Handle; B1 :Boolean; Begin H1:=FSActLayer; H2:=GetRecord(H1,NumRecords(H1)); {get a handle to the first record} If H2 <> Nil then Begin {If a record exists then create worksheet} S1:=GetName(H2); N1:=NumFields(H2); N2:=1; S3:=''; WSH:=CreateWS(Concat(S1,' ',Date(2,1)),N1+2,2); SetWSPlacement(WSH,200,200,800,700); SetWSColumnWidth(WSH,1,1,200); SetWSColumnWidth(WSH,2,2,200); SetWSCellFormula(WSH,1,1,1,1,Concat('Parameter Fields for PIO: ',S1)); SetWSCellFormula(WSH,3,1,3,1,'Display Name'); SetWSCellFormula(WSH,3,2,3,2,'Cell Formula'); While N2<=N1 Do Begin {populate the worksheet with all the fields} S2:=GetFldName(H2,N2); S3:=Concat(Chr(39),S1,CHR(39),'.',CHR(39),S2,Chr(39)); SetWSCellFormula(WSH,N2+3,2,N2+3,2,S3); B1:=GetLocalizedPluginParameter(S1,S2,S4); if S4='' then S5:=S2 else S5:=S4; SetWSCellFormula(WSH,N2+3,1,N2+3,1,S5); N2:=N2+1; end; ShowWS(WSH,True); SetTopVisibleWS(WSH); end; End; Run(GetPIORecordFields); (***** Stop copying here *****) 3 Quote Link to comment
gmm18 Posted August 20, 2008 Share Posted August 20, 2008 This is great, thanks Pat. Quote Link to comment
Yancka Posted August 20, 2008 Share Posted August 20, 2008 (edited) Pat, tried the new script on Space object, now worksheet shows only 2 Record.Field instances where Display Name is present. Otherwise - works perfect!! Janis Edited August 20, 2008 by Yancka 1 Quote Link to comment
Pat Stanford Posted August 20, 2008 Author Share Posted August 20, 2008 I can't replicate that here. I created a space object and ran the menu command (copied and pasted from the script) and I got all the display names. Glad you like it! Pat 2 Quote Link to comment
Pat Stanford Posted October 29, 2008 Author Share Posted October 29, 2008 Here is an updated version of the script, tested in VW2009. It now includes an extra column that lists the field type. Very useful for figuring out why you can't multiple your space.roomnumber field by a constant Enjoy. Pat (***** Copy script from here down & paste into a VS Editor window ******) Procedure GetPIORecordFields; {Creates a worksheet showing the display and field names} {for the first selected object on the active layer} {Useful for determining the record.field names required} {for use in a worksheet.} {Updated October 29, 2008} {Now includes the field type for each field} {January 30, 2008} {? 2008, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {Modified 8/19/08 Pat Stanford} {Now puts quotes around both record and field instead of both combined} {Modified 8/19/08 Pat Stanford} {Now displays non-localized field names if no localization} Var H1 ,H2 :Handle; S1,S2,S3,S4,S5,S6 :String; N1,N2, N3 :Integer; WSH :Handle; B1 :Boolean; Begin H1:=FSActLayer; H2:=GetRecord(H1,NumRecords(H1)); {get a handle to the first record} If H2 <> Nil then Begin {If a record exists then create worksheet} S1:=GetName(H2); N1:=NumFields(H2); N2:=1; S3:=''; WSH:=CreateWS(Concat(S1,' ',Date(2,1)),N1+2,3); SetWSPlacement(WSH,200,200,800,850); SetWSColumnWidth(WSH,1,1,200); SetWSColumnWidth(WSH,2,2,200); SetWSCOlumnWidth(WSH,3,3,200); SetWSCellFormula(WSH,1,1,1,1,Concat('Parameter Fields for PIO: ',S1)); SetWSCellFormula(WSH,3,1,3,1,'Display Name'); SetWSCellFormula(WSH,3,2,3,2,'Cell Formula'); SetWSCellFormula(WSH,3,2,3,2,'Field Type'); While N2<=N1 Do Begin {populate the worksheet with all the fields} S2:=GetFldName(H2,N2); S3:=Concat(Chr(39),S1,CHR(39),'.',CHR(39),S2,Chr(39)); SetWSCellFormula(WSH,N2+3,2,N2+3,2,S3); B1:=GetLocalizedPluginParameter(S1,S2,S4); if S4='' then S5:=S2 else S5:=S4; SetWSCellFormula(WSH,N2+3,1,N2+3,1,S5); N3:=GetFldType(H2,N2); Case N3 of 1: S6:='Integer'; 2: S6:='Boolean'; 3: S6:='Number-General'; 4: S6:='Text'; 5: S6:='Number-decimal'; 6: S6:='Number-decimal w/commas'; 7: S6:='Number-scientific'; 8: S6:='Number-fractional'; 9: S6:='Number-dimension'; 10: S6:='Number-angle'; 11: S6:='Number-date/time'; 14: S6:='Number-dimension area'; 15: S6:='Number-dimension volume'; Otherwise S6:='Some Numeric Format'; End; SetWSCellFormula(WSH,N2+3,3,N2+3,3,S6); N2:=N2+1; end; ShowWS(WSH,True); SetTopVisibleWS(WSH); end; End; Run(GetPIORecordFields); (***** Stop copying here *****) Quote Link to comment
Mr.D Posted November 19, 2008 Share Posted November 19, 2008 This seems like a really useful tool, but I cannot figure out how to use it... I placed the .vsm in the plug-in folder. I copied and pasted the text in the VS Editor. Then I am lost... Can anybody help? Also, explain to an intermediate use what this tool actually does... Thanks! Quote Link to comment
Pat Stanford Posted November 19, 2008 Author Share Posted November 19, 2008 OK, What it actually does: If a PIO instances is the first selected object, it creates a worksheet. The worksheet contains all of the fields in the PIO parameter record. This includes items that NNA may not want you to see. It gives you the "Display Name" or what shows up in the Object Info Palette. It gives you the "Formula" this is the record.field format required to get the data in a database section of a worksheet. the "formula" is set up so that you can copy and pate that cell directly and have it work in a database header row. Finally it gives you the object "Type" (integer, text, boolean, real, etc.) Why would you want to use this? If you are trying to use informaiton about PIOs in a worksheet, this can help you determine exactly what the required formula is. OR by looking at the Type field, you can see why your math is not working (like the Area field in Space objects in VW12 that was a Text field instead of a number). How do you install it? There are two ways to install and use the script. 1. Create a Script Palette and a Vectorscript. a. In a VW file, go to the Resource Browser and Select Create New Resource: New Vectorscript. b. Either select an existing scrip palette or create a new one. c. Name the script. The Script Editor should open a blank script. d. copy and paste the script from above in to the Script Editor and click OK. e. To run the script, double click it from the script palette. 2. Create a Plug-in menu command. a. In a VW file, to to the Tools Menu, Scripts, Vectorscript Plug-in Editor b. Click New, put in a Name for the PIO and make sure the Command button is selected. Click OK. c. Click the Script button and paste the script from above into the editor window and click OK. d. Click the Done button. e. Edit your workspace to add the command. f. Select the new command from the menu to run the script. Option 1 is best if you only need to do this for a single file. Option 2 is better if you find this command useful and are going to use it often. Regards, Pat Quote Link to comment
Mr.D Posted November 19, 2008 Share Posted November 19, 2008 PERFECT!!! This IS a great tool. Thank you for the very helpful reply! Best Quote Link to comment
Pat Stanford Posted December 11, 2008 Author Share Posted December 11, 2008 Here is the latest version. The last one displaed the wrong values for PIO field types. Poor QA/QC on my part. Procedure GetPIORecordFields; {Creates a worksheet showing the display and field names} {for the first selected object on the active layer} {Useful for determining the record.field names required} {for use in a worksheet.} {Corrected December 11, 2008} {Now shows correct field types} {Updated October 29, 2008} {Now includes the field type for each field} {January 30, 2008} {? 2008, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {Modified 8/19/08 Pat Stanford} {Now puts quotes around both record and field instead of both combined} {Modified 8/19/08 Pat Stanford} {Now displays non-localized field names if no localization} Var H1 ,H2 :Handle; S1,S2,S3,S4,S5,S6 :String; N1,N2, N3 :Integer; WSH :Handle; B1 :Boolean; Begin H1:=FSActLayer; H2:=GetRecord(H1,NumRecords(H1)); {get a handle to the first record} If H2 <> Nil then Begin {If a record exists then create worksheet} S1:=GetName(H2); N1:=NumFields(H2); N2:=1; S3:=''; WSH:=CreateWS(Concat(S1,' ',Date(2,1)),N1+2,3); SetWSPlacement(WSH,200,200,800,850); SetWSColumnWidth(WSH,1,1,200); SetWSColumnWidth(WSH,2,2,200); SetWSCOlumnWidth(WSH,3,3,200); SetWSCellFormula(WSH,1,1,1,1,Concat('Parameter Fields for PIO: ',S1)); SetWSCellFormula(WSH,3,1,3,1,'Display Name'); SetWSCellFormula(WSH,3,2,3,2,'Cell Formula'); SetWSCellFormula(WSH,3,2,3,2,'Field Type'); While N2<=N1 Do Begin {populate the worksheet with all the fields} S2:=GetFldName(H2,N2); S3:=Concat(Chr(39),S1,CHR(39),'.',CHR(39),S2,Chr(39)); SetWSCellFormula(WSH,N2+3,2,N2+3,2,S3); B1:=GetLocalizedPluginParameter(S1,S2,S4); if S4='' then S5:=S2 else S5:=S4; SetWSCellFormula(WSH,N2+3,1,N2+3,1,S5); N3:=GetFldType(H2,N2); Case N3 of 1: S6:='Integer'; 2: S6:='Boolean'; 3: S6:='Real'; 4: S6:='Text'; 7: S6:='Real - Coordinate Displacement'; 8: S6:='Text - Popup Menu Item'; 9: S6:='Text - Radio Button'; 10: S6:='Real - Coodinate X Location'; 11: S6:='Real - Coordinate Y Location'; 14: S6:='Static Text'; Otherwise S6:='Some Numeric Format'; End; SetWSCellFormula(WSH,N2+3,3,N2+3,3,S6); N2:=N2+1; end; ShowWS(WSH,True); SetTopVisibleWS(WSH); end; End; Run(GetPIORecordFields); Pat Quote Link to comment
HOUCAD Posted July 13, 2009 Share Posted July 13, 2009 Does this not work for spaces? When I try to run this I get something about custom bound set and not any space.fields. Quote Link to comment
Pat Stanford Posted October 4, 2010 Author Share Posted October 4, 2010 Update!! I have been using this in VW2011 and it appears that you can no longer just select a cell in the record/field worksheet and copy/paste it into a different worksheet. I think the problem has to do with Unicode. Instead, select the cell and copy/paste from the formula bar at the top of the worksheet. I don't currently have a solution for this. Quote Link to comment
Pat Stanford Posted March 2, 2011 Author Share Posted March 2, 2011 In a later build of VW2011 it appears they have fixed the copy/paste bug. You can now (at least as of SP2) just select a field in a worksheet and copy and paste into a different worksheet. Quote Link to comment
billtheia Posted June 23, 2011 Share Posted June 23, 2011 Hi Pat. The script does not appear to work for doors or windows in VW2011. Quote Link to comment
Pat Stanford Posted June 23, 2011 Author Share Posted June 23, 2011 I just tried it (again) in VW2011 on both a door and a windows and it seems to work fine. Do you have the latest version (see my post of 12/11/2008 above)? When you try to run the script what happens? Are you sure you only have one door or one window selected when you try to run the script? Quote Link to comment
billtheia Posted June 23, 2011 Share Posted June 23, 2011 Yes, I have the latest VS and I'm using VW2011SP3. I've tried it on two different drawing files with the same results. I get a worksheet with only a single entry, "Parameter Fields for PIO: none". The script seems to work on other PIOs. I've tried it on a stair object and it worked just fine. Quote Link to comment
Pat Stanford Posted June 23, 2011 Author Share Posted June 23, 2011 Try a new blank document with only a door or window and the script in it. It will give the same field information in any file. Or send me that file (up to 30MB to the address in my signature) and I will take a look. Quote Link to comment
billtheia Posted June 24, 2011 Share Posted June 24, 2011 The first try was with a blank document. Here's a file. Quote Link to comment
Pat Stanford Posted June 24, 2011 Author Share Posted June 24, 2011 Try a window or door that is not inserted in a wall. It works with a Window. It does not work with a Window in Wall. Check our the third sentence of the first post of the thread ;-) Quote Link to comment
billtheia Posted June 24, 2011 Share Posted June 24, 2011 Aha. Thanks for showing me the light. Quote Link to comment
maarten. Posted June 27, 2011 Share Posted June 27, 2011 Hi Pat Nice script! With GetPickObjectInfo, you can get the handle of an object inside a wall. Ofcourse, it will no longer work on the selected object but the user has to click on an object to get the information. Not sure if that's what the user wants... ... Var H1 ,H2, H3 :Handle; S1,S2,S3,S4,S5,S6 :String; N1,N2, N3, tmpN :Integer; WSH :Handle; B1 :Boolean; x,y :Real; Begin GetPt(x,y); IF GetPickObjectInfo(x,y,H1,H3,tmpN) THEN Begin IF H3<>NIL THEN H1:=H3; H2:=GetRecord(H1,NumRecords(H1)); {get a handle to the first record} .... Quote Link to comment
Pat Stanford Posted June 28, 2011 Author Share Posted June 28, 2011 maarten, Thanks for the handler. I did not include that due to pure lazyness. That and the fact that I know how to use it with selected objects ;-) The code has been released for general use. You are welcome to modify a version for your use or to modify it and post it back for general use. Quote Link to comment
Christian Fekete Posted August 4, 2016 Share Posted August 4, 2016 Thank you Pat, I copied the script into VW and Voila! worked the first time, no issue. EXACTLY what I was looking for, thank you very much for sharing this invaluable script. Sincerely Quote Link to comment
Pat Stanford Posted May 18, 2017 Author Share Posted May 18, 2017 Here is an updated version of the script that fixes a bug of net setting the table large enough in VW2017. Procedure GetPIORecordFields; {Creates a worksheet showing the display and field names} {for the first selected object on the active layer} {Useful for determining the record.field names required} {for use in a worksheet.} {Updated May 2017} {Fixed bug with table not having enought cells in VW2017} {Corrected December 11, 2008} {Now shows correct field types} {Updated October 29, 2008} {Now includes the field type for each field} {January 30, 2008} {© 2008, Coviana, Inc - Pat Stanford pat@coviana.com} {Licensed under the GNU Lesser General Public License} {Modified 8/19/08 Pat Stanford} {Now puts quotes around both record and field instead of both combined} {Modified 8/19/08 Pat Stanford} {Now displays non-localized field names if no localization} Var H1 ,H2 :Handle; S1,S2,S3,S4,S5,S6 :String; N1,N2, N3 :Integer; WSH :Handle; B1 :Boolean; Begin H1:=FSActLayer; H2:=GetRecord(H1,NumRecords(H1)); {get a handle to the first record} If H2 <> Nil then Begin {If a record exists then create worksheet} S1:=GetName(H2); N1:=NumFields(H2); N2:=1; S3:=''; WSH:=CreateWS(Concat(S1,' ',Date(2,1)),N1+3,3); SetWSPlacement(WSH,200,200,800,850); SetWSColumnWidth(WSH,1,1,200); SetWSColumnWidth(WSH,2,2,200); SetWSCOlumnWidth(WSH,3,3,200); SetWSCellFormula(WSH,1,1,1,1,Concat('Parameter Fields for PIO: ',S1)); SetWSCellFormula(WSH,3,1,3,1,'Display Name'); SetWSCellFormula(WSH,3,2,3,2,'Cell Formula'); SetWSCellFormula(WSH,3,2,3,2,'Field Type'); While N2<=N1 Do Begin {populate the worksheet with all the fields} S2:=GetFldName(H2,N2); S3:=Concat(Chr(39),S1,CHR(39),'.',CHR(39),S2,Chr(39)); SetWSCellFormula(WSH,N2+3,2,N2+3,2,S3); B1:=GetLocalizedPluginParameter(S1,S2,S4); if S4='' then S5:=S2 else S5:=S4; SetWSCellFormula(WSH,N2+3,1,N2+3,1,S5); N3:=GetFldType(H2,N2); Case N3 of 1: S6:='Integer'; 2: S6:='Boolean'; 3: S6:='Real'; 4: S6:='Text'; 7: S6:='Real - Coordinate Displacement'; 8: S6:='Text - Popup Menu Item'; 9: S6:='Text - Radio Button'; 10: S6:='Real - Coodinate X Location'; 11: S6:='Real - Coordinate Y Location'; 14: S6:='Static Text'; Otherwise S6:='Some Numeric Format'; End; SetWSCellFormula(WSH,N2+3,3,N2+3,3,S6); N2:=N2+1; end; ShowWS(WSH,True); SetTopVisibleWS(WSH); end; End; Run(GetPIORecordFields); 4 Quote Link to comment
Andy Broomell Posted November 4, 2017 Share Posted November 4, 2017 Does this work with Light objects? Can't seem to get it to work with those. Quote Link to comment
Pat Stanford Posted November 5, 2017 Author Share Posted November 5, 2017 No it does not work on Light objects. Apparently, lights are not PIOs. There are no data records attached to lights. Even though from how they interact with the OIP they look like it, they are not PIOs. What do you want to do with the lights? I might still be able to help. 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.