Jump to content
Developer Wiki and Function Reference Links ×

Is there a way to determine a door's or a window's real push-opening angle?


zgobolos

Recommended Posts

I need to know the real angle - like east is 0, north is 90, and so on ... - of doors and windows but I need only the one angle in which you step through a door in "push mode". I need to extract the same info for windows. I checked the door and window plug in objects' parameter list but I didn't find any clue.

I hope you understand.

Link to comment

The angle you are after is a property of the wall in which the window or door has been inserted to.

From the Window's point of view: it lives in the World of the Wall. When the angle of the Wall changes, the Window just inherits the rotation.

A good point anyway! I must explore the possibility of calculating the (solar) orientation of my non-US windows...

Link to comment

Many thanks for the answer but I'm reluctant to believe it has anything to do with the wall's angle. I guess I just simply wasn't clear enough.

So let's consider I have a wall in 45 degrees. Or 225 but it doesn't matter. There is a door or window in it. Let's say a door. The door can be opened four ways. If you stand in front of the door pointing your face to the door in the north-west direction - or in other words on the right side of the wall facing the door - you can push-open it two ways - the other two ways are pull-open.

I'm not sure I can ask the right question, but the answer is 135 degrees. It doesn't matter in which direction the door opens, but it opens in 135 degrees not in 315. One can place the door flipped and the opening angle in this case would be 315 degrees, but in this case you would stand on the left side of the wall if you want to push-open the door.

So this is what I want to know ... the opening angle not against the wall or any items on the drawing but the real word coordinate system where the East means 0 degrees.

Sorry but I'm not native english, I'm struggling with difficult explanations :)

Edited by zgobolos
Link to comment

I don't think there's a direct way to get the info you want, but maybe this will help.

The problem is that you need to get the Handle of your door that's in the wall, but because it's in a wall, you'll get the Handle of the wall instead of the door.

Here's a script from the Dutch VW forum, i rewrote it a little so you'll get the Angle and if the door is flipped or not.

PROCEDURE Example;
VAR
x,y : REAL;
keyhit : INTEGER;
h : HANDLE;
InMu : HANDLE;
BB1,BB2 : POINT;

BEGIN
keyhit:=27;
WHILE NOT keydown(keyhit) DO
BEGIN
	GetPt(x,y);
	h:=PickObject(x,y);
	IF h<>NIL THEN
	BEGIN
{look if the chosen object is a wall}
		IF (GetType(h)=68) THEN
		BEGIN
	{get the handle of the first object in that wall}
			InMu:=FIn3D(h);
			IF InMu<>NIL THEN
			BEGIN
				REPEAT
			{If the object is a Symbol or a pio, then...}
					IF (GetType(InMu)=86) OR (GetType(InMu)=15) THEN
					BEGIN
				{...take the bounding box of that object}
						GetBBox(InMu,BB1.x,BB1.y,BB2.x,BB2.y);
				{if the mouseclick is located in that BBox, then that's the object we need}
						IF (PtInRect(x,y,BB1.x,BB1.y,BB2.x,BB2.y)) THEN h:=InMu;
					END;
					InMu:=NextObj(InMu);
				UNTIL(InMu=NIL);
			END;
		END;

{place the text on the clicked object}
		TextOrigin(x,y);
		CreateText(ConCat(GetSymRot(h),' / ',IsObjectFlipped(h)));
		RedrawAll;
	END;
END;
END;
Run(Example);

(To use it, just activate the script and click on your door, press esc to stop.)

And then you'll get this:

afbeelding1oq7.png

Then with a simple IF (rotation=...) & Flipped THEN Oriantation:='North' you can get the oriantation.

Not completely sure, but i think this would do the trick...

EDIT: Sorry, i see now that you need the angle of the door... Then you need a little bit more.. I'll look for it and let you know if i find something.

Edited by maarten.
Link to comment

Here's a version that should work:

PROCEDURE Example;
VAR
x,y : REAL;
keyhit : INTEGER;
h : HANDLE;
InMu : HANDLE;
BB1,BB2 : POINT;
WallRot : REAL;
SymRot : REAL;
SymFlip : BOOLEAN;
SymAngle : REAL;
BEGIN
keyhit:=27;
WHILE NOT keydown(keyhit) DO
BEGIN
	GetPt(x,y);
	h:=PickObject(x,y);
	IF h<>NIL THEN
	BEGIN
{look if the chosen object is a wall}
		IF (GetType(h)=68) THEN
		BEGIN
	{get the rotation of the wall}
			WallRot:=HAngle(h);

	{get the handle of the first object in that wall}
			InMu:=FIn3D(h);
			IF InMu<>NIL THEN
			BEGIN
				REPEAT
			{If the object is a Symbol or a pio, then...}
					IF (GetType(InMu)=86) OR (GetType(InMu)=15) THEN
					BEGIN
				{...take the bounding box of that object}
						GetBBox(InMu,BB1.x,BB1.y,BB2.x,BB2.y);
				{if the mouseclick is located in that BBox, then that's the object we need}
						IF (PtInRect(x,y,BB1.x,BB1.y,BB2.x,BB2.y)) THEN h:=InMu;
					END;
					InMu:=NextObj(InMu);
				UNTIL(InMu=NIL);
			END;
	{Get the rotation and flip of the symbol/pio}
			SymRot:=GetSymRot(h);
			SymFlip:=IsObjectFlipped(h);
	{calculate the angle}
			IF WallRot<0 THEN WallRot:=WallRot+180;

			IF (SymRot=WallRot) & SymFlip THEN SymAngle:=WallRot-90;
			IF (SymRot=WallRot) & NOT SymFlip THEN SymAngle:=WallRot+90;
			IF (SymRot<>WallRot) & SymFlip THEN SymAngle:=WallRot+90;
			IF (SymRot<>WallRot) & NOT SymFlip THEN SymAngle:=WallRot-90;

			IF SymAngle<0 THEN SymAngle:=360+SymAngle;
	{place the text on the clicked object}
			TextOrigin(x,y);
			CreateText(Num2Str(2,SymAngle));
			RedrawAll;
		END;
	END;
END;
END;
Run(Example);

afbeelding2tl6.png

Link to comment
Many thanks for the answer but I'm reluctant to believe it has anything to do with the wall's angle.

But it has. When a window is inserted in a wall, it "inherits" the angle of the wall. After that you may need to figure out the insertion method & flipping, if relevant.

Each parametric object has an internal coordinate system. Any sub-object is placed in that coordinate system (well, sort of) and in order to determine its angle, one has to use both the parent object's angle and the child object's angle, which is always in relation to the parent.

Nice transformation matrix calculations somewhere for all this to be so easy as it is!

Link to comment

Maarten,

Wow, that's exactly what I was looking for. I'm gonna analyze the code you pasted in tomorrow but the pictures are really promising. I appreciate your effort very much.

Petri,

Thanks for your comments as well. I don't have time today but I'll get deep inside your comments and I will write some prototypes to find out how the parametric objects work in relation to each other and in general. I got a comment in another thread about getting inside the parametric object and analyze the sub-parts.

So I have a lot to learn it seems and I like it.

Thanks very much for all your comments again and best regards,

Zoli

Link to comment

Petri,

I'd like to apologise: yes, the wall's angle is important of course. What I wrote is that it's not important whether the wall's angle is 45 or 215 degrees as the door can be placed into the wall in four ways in terms of the swing direction.

Maarten,

Nice piece of code, thanks again. I would never figure out I need to use bounding boxes and the other stuff in the middle of your snippet.

Thanks guys again, you have solved my showstopper.

Edited by zgobolos
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...