Jump to content

Worksheet of PIO Fields


Recommended Posts

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 *****)

  • Like 3
Link to comment
  • 2 months later...

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 *****)

Link to comment
  • 3 weeks later...

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!

Link to comment

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

Link to comment
  • 4 weeks later...

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

Link to comment
  • 7 months later...
  • 1 year later...

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.

Link to comment
  • 4 months later...
  • 3 months later...

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.

Link to comment

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

Link to comment
  • 5 years later...
  • 9 months later...

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);

 

  • Like 4
Link to comment
  • 5 months later...

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