Jump to content
Developer Wiki and Function Reference Links ×

How do I get the handle of a window in a wall?


Recommended Posts

I'm new to vectorsript and am trying to create a script that will change the attributes of selected windows in walls. I've tried using FSActLayer but it only seems to work on windows NOT inserted into walls.

I have cobbled together the following script based on a previous message board post but, without the ability to grab the handles of selected windows, it changes ALL of the windows in the file.

PROCEDURE WdwSill5_5;

PROCEDURE ChangeSill(h :HANDLE);

BEGIN

SetRField(h, 'Window', 'IncludeSill', 'TRUE');

SetRField(h, 'Window', 'TrimUnderSill', 'TRUE');

SetRField(h, 'Window', 'TrimUnderStool', 'TRUE');

SetRField(h, 'Window', 'SillLip', '1');

SetRField(h, 'Window', 'SillKeep', '6.25');

SetRField(h, 'Window', 'SillHeight', '1.5');

SetRField(h, 'Window', 'SillDepth', '7.25');

SetRField(h, 'Window', 'SillExt', '3.5');

SetRField(h, 'Window', 'StoolLip', '1');

SetRField(h, 'Window', 'StoolNose', '1.75');

ResetObject(h);

END;

BEGIN

ForEachObject(ChangeSill, (INSYMBOL & INVIEWPORT & (PON='Window')));

END;

Run(WdwSill5_5);

Can someone out there please help me make this work on selected windows?

Thanks.

Link to comment

Bill,

???When in doubt, tunnel in. Not being well versed on the WALL object, I wrote this script to quickly dig around inside. There are probably better ways to get what you want, but this style of script always yields interesting results.

???There are two statements that do the heavy lifting. One is FIn3D() which almost always cracks the door on container objects, and the WALL is definitely a container. The second one is GetName(GetRecord(H, NumRecords(H))) which returns the name of the PIO being pointed to by handle H. PIOs always have a record attached and the last record (which could be the only record) has the same name as the PIO.

???To speed things up, get rid of the WAIT(1) statement and the "ELSE ..." on the previous line. There is no need to do anything to objects that don't meet your search criteria.

???So, the bottom line, is get a handle to a Wall, look inside for selected PIOs, operate.

HTH,

Raymond

PS - Hold that thought. I'll be right back...

PROCEDURE WalkThroughWalls;
{ 8 July 2012 - RJMullin }
{ Poke around inside a WALL (type = 68) and see what pops up. }
{ Watch the Message Window for the anatomy of the wall. }
VAR
H :Handle;
I, ObjType :Integer;
BEGIN
H := FSActlayer;
ObjType := GetTypeN(H);
if (ObjType = 68) then begin		{ It's a WALL }
	I := 0;				{ counter for objs in the WALL }
	H := FIn3D(H);			{ first object in the WALL }
	while (H <> nil) do begin
		I := I + 1;
		ObjType := GetTypeN(H);
		if (ObjType = 86) & Selected(H) then begin	{ it's a PIO & it's selected }
			message(I, '  ', GetName(GetRecord(H, NumRecords(H))))

			{*** Do your stuff here ***}

		end
		else message(I, '   Object Type = ', ObjType);
		wait(1);
		H := nextobj(H);			{ get next object in WALL }
	end;		{ while }
end
else message('Object Type = ', ObjType);
sysbeep;
END;
Run(WalkThroughWalls);

Link to comment

Here's a more modular approach. The function "FSPIOinWall" can be used any time you need a handle to Selected PIOs in a wall. The code that follows just shows an example of a way to use it, as in counting windows. This is a very simple example as it will only count windows in one wall.

Now I'm waiting for Pat to find that single function call that makes these gyrations completely unnecessary.

HTH,

Raymond

PROCEDURE CountWindowsInWall;
{ 8 July 2012 - RJMullin }
{ Count the number of selected Windows in a wall. }
{ Watch the Message Window for the answer. }
VAR
H :Handle;
I :Integer;


function FSPIOinWall(H :Handle) :Handle;
{ Return a handle to the First Selected PIO in a Wall. }
{ If handle H is not a WALL, return NIL. }
Var
	PIOHand :Handle;

	function SelectedPIO(H :Handle) :Boolean;
	{ Find 1st handle then quit looking. }
	Begin
		if Selected(H) & (GetTypeN(H) = 86) then
			PIOHand := H;
		SelectedPIO := PIOHand <> nil;	{ quit when true }
	End;		{ SelectedPIO }

Begin		{ FSPIOinWall }
	PIOHand := nil;
	if (GetTypeN(H) = 68) then begin	{ It's a WALL }
		H := FIn3D(H);			{ first object in the WALL }
		ForEachObjectInList(SelectedPIO, 2, 0, H);
	end;		{ if }
	FSPIOinWall := PIOHand;
End;		{ FSPIOinWall }


BEGIN
ClrMessage;
H := FSActLayer;
if (H <> nil) then begin
	I := 0;		{ Window counter }
	if (GetTypeN(H) = 68) then begin	{ it's a WALL }
		H := FSPIOinWall(H);		{ *** This is the call *** }

		{ ?? THE REST IS FLUFF ?? }
		while (H <> nil) do begin
			if (GetName(GetRecord(H, NumRecords(H))) = 'Window') then
				I := I + 1;
			H := NextSObj(H);
		end;		{ while }

		if (I = 1) then 
			message ('There is ', I, ' selected window in this wall.')
		else message ('There are ', I, ' selected windows in this wall.');
	end
	else message('This is not a wall.');
	SysBeep;
end;		{ if }

END;
Run(CountWindowsInWall);

Link to comment

Raymond,

I was actually thinking of GetPickObjectInfo.

I don't have time to fight with this today, but the way I would go about this is to make an array of the selected objects, get their locations and then step through those locations to get the SubHd object to do the changes.

I don't know if that would really work or not, but that would be my first approach.

Pat

Link to comment

Can someone out there please help me make this work on selected windows?

I think you were on the right track but missing the code for selected windows as in the following:

ForEachObject(ChangeSill, ((PON='Window') & (SEL=TRUE)));

you can further restrict the criteria by including only the selected windows in a layer.

ForEachObject(ChangeSill, ((L='Layer Name') & (PON='Window') & (SEL=TRUE)));

Link to comment

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