Jump to content
Sign in to follow this  
Robert Anderson

Script to report on all records attached to an object

Recommended Posts

Select an object in the drawing that has records attached (this can be a PIO or any object) and run this script. Then click on the drawing and you'll have an on-drawing report of all the records attached to the object. (I use this script all the time -- it's probably more practically useful than instructive, but there are things to learn in here, also.)

OK, I've got this forum up and rolling with some useful and hopefully instructive stuff. Let's see some other scripters' work....

PROCEDURE RecordReporter;
CONST
p_str = 'p';
int_type_str = '\INTEGER\';
bool_type_str = '\BOOLEAN\';
text_type_str = '\TEXT\';
popup_type_str = '\TEXT-Popup\';
radio_type_str = '\TEXT-Radio\';
const_type_str = '\TEXT-Static Label\';
ngenl_type_str = '\NUMBER-General\';
ndim_type_str = '\NUMBER-Dimension\';
nxcoor_type_str = '\NUMBER-X coordinate\';
nycoor_type_str = '\NUMBER-Y coordinate\';
ndec_type_str = '\NUMBER-Decimal\';
ndeccomma_type_str = '\NUMBER-Decimal w/ commas\';
nsci_type_str = '\NUMBER-Scientific\';
nfrac_type_str = '\NUMBER-Fraction\';
nang_type_str = '\NUMBER-Angle\';
ndate_type_str = '\NUMBER-Date/Time\';
err_str_noselect = 'ERROR: Nothing selected. Select an object with a record or records attached and run this script again.';

VAR
hobj,hrec:HANDLE;
str:DYNARRAY[] OF CHAR;
x,y:REAL;
i,j,k,l:INTEGER;
objname:STRING;

FUNCTION UScore(in_str:STRING):STRING;
VAR
strlen,i:INTEGER;
outstring:STRING;
test:BOOLEAN;

BEGIN
outstring := '';
strlen := len(in_str);
FOR i := 1 TO strlen DO
	BEGIN
	test := (copy(in_str,i,1) = ' ');
	IF test
		THEN outstring := concat(outstring,'_')
		ELSE outstring := concat(outstring,copy(in_str,i,1));
	END;
UScore := outstring;
END;

BEGIN
hobj := fsactlayer;
IF hobj <> NIL THEN
BEGIN
str := '';
FOR j := 1 to numrecords(hobj) DO BEGIN
	hrec := getrecord(hobj,j);
	IF (j = numrecords(hobj)) THEN objname := getname(hrec);
	IF (str<>'') THEN str := concat(str,chr(13));
	str := concat(str,num2str(0,j),'.');
	str := concat(str,getname(hrec));
	FOR i:= 1 TO NumFields(hrec) DO BEGIN
		str := concat(str,chr(13));
		str := concat(str,'    ');
		str := concat(str,num2str(0,j),'.',num2str(0,i),'?');
		str := concat(str,GetFldName(hrec,i));
		IF ((gettype(hobj)=86)&(j = numrecords(hobj))) {PIO format record}
		THEN CASE getfldtype(hrec,i) OF
			1: str := concat(str,int_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			2: str := concat(str,bool_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			3: str := concat(str,ngenl_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			4: str := concat(str,text_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			7: str := concat(str,ndim_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			8:	BEGIN
				str := concat(str,popup_type_str);
				k := numCustomObjectChoices(objname, concat(p_str,UScore(GetFldName(hrec,i))));
				FOR l := 1 TO k DO
					str := concat(str,getCustomObjectChoice(objname,concat(p_str,UScore(GetFldName(hrec,i))),l),',');
				END;
			9: str := concat(str,radio_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			10: str := concat(str,nxcoor_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			11: str := concat(str,nycoor_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			14: str := concat(str,const_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			END {of CASE}
		ELSE CASE getfldtype(hrec,i) OF
			1: str := concat(str,int_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			2: str := concat(str,bool_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			3: str := concat(str,ngenl_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			4: str := concat(str,text_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			5: str := concat(str,ndec_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			6: str := concat(str,ndeccomma_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			7: str := concat(str,nsci_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			8: str := concat(str,nfrac_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			9: str := concat(str,ndim_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			10: str := concat(str,nang_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			11: str := concat(str,ndate_type_str,getrfield(hobj,getname(hrec),GetFldName(hrec,i)));
			END; {of CASE}
		END;
	END;
getpt(x,y);
textorigin(x,y);
CreateText(str);
SetTextJust(lnewobj,1);
END ELSE alrtdialog(err_str_noselect);
END;
RUN(RecordReporter);

Edited by Robert Anderson

Share this post


Link to post

Thanks for this one Robert. A tour-de-force of concatenation and case!

One note: It seems that the script has been pasted twice into this code window. I copied it all and pasted to a document script but it wouldn't run. Took a minute or two to see what was wrong. No likey run in middle.

Share this post


Link to post

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.

Sign in to follow this  

 

7150 Riverwood Drive, Columbia, Maryland 21046, USA   |   Contact Us:   410-290-5114

 

© 2018 Vectorworks, Inc. All Rights Reserved. Vectorworks, Inc. is part of the Nemetschek Group.

×
×
  • Create New...