We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

3D Rotating Hotspot

JGoode
Expert
Hi,
I am playing with the 3D Rotating hotspots. Is there any way to change the plane which the hotspot rotates around? It is currently horizontal/flat but I want it vertical instead. I have used the example given by graphisoft and used the parameters in the code but I don't know how to manipulate it to do what I'd like it to.

Any help would be much appreciated.


Here is the Graphisoft example code for it.
 unID = 1
! --------------------------------------------------------------------------------
! Center
! --------------------------------------------------------------------------------
hotspot 0, 0, 0, unID, ang, 6     : unID = unID + 1

! --------------------------------------------------------------------------------
! Base
! --------------------------------------------------------------------------------
hotspot 0.2, 0, 0, unID, ang, 4     : unID = unID + 1

! --------------------------------------------------------------------------------
! Moving
! --------------------------------------------------------------------------------
hotspot 0.2 * COS(ang), r * SIN(ang), 0, unID, ang, 5     : unID = unID + 1

! --------------------------------------------------------------------------------
! Reference
! --------------------------------------------------------------------------------
hotspot 0, 0, 0, unID, ang, 7     : unID = unID + 1
ArchiCAD 23

Windows 10
5 REPLIES 5
Bruce
Advisor
First thing: The reference hotspot cannot be the same as the centre hotspot. An imaginary vector drawn from the centre hotspot to the reference hotspot forms your rotation axis...like the axel/hub of a wheel.

To rotate in the vertical plane, the z-axis coord of the moving hotspot needs to be used, and either the x or y coord left at 0.

E.g. to rotate around the x axis, using your parameters, would be:

ROTX ang
HOTSPOT 0, r, 0, unID, ang, 4 : unID=unID+1 ! Base
HOTSPOT 0, r*COS(ang), r*SIN(ang), unID, ang, 5 : unID=unID+1 ! Moving
HOTSPOT 0, 0, 0, unID, ang, 6 : unID=unID+1 ! Centre
HOTSPOT 1, 0, 0, unID, ang, 7 : unID=unID+1 ! Reference
DEL 1

I can’t test this right now, but it should be something like this.
Bruce Walker
Barking Dog BIM YouTube
Mindmeister Mindmap
-- since v8.1 --
AC27 5060 INT Full | Windows 11 64 Pro | 12th Gen Intel i7-12700H 2.30 GHz | 64 Gb RAM | NVIDIA GeForce RTX 3060 32 Gb
JGoode
Expert
Bruce wrote:
First thing: The reference hotspot cannot be the same as the centre hotspot. An imaginary vector drawn from the centre hotspot to the reference hotspot forms your rotation axis...like the axel/hub of a wheel.

To rotate in the vertical plane, the z-axis coord of the moving hotspot needs to be used, and either the x or y coord left at 0.

E.g. to rotate around the x axis, using your parameters, would be:

ROTX ang
HOTSPOT 0, r, 0, unID, ang, 4 : unID=unID+1 ! Base
HOTSPOT 0, r*COS(ang), r*SIN(ang), unID, ang, 5 : unID=unID+1 ! Moving
HOTSPOT 0, 0, 0, unID, ang, 6 : unID=unID+1 ! Centre
HOTSPOT 1, 0, 0, unID, ang, 7 : unID=unID+1 ! Reference
DEL 1

I can’t test this right now, but it should be something like this.
Ahh, it works but not how I want it. I want it to rotate around the Y axis. I've managed to get it to rotate that way, however the hotspot doesn't stay in the correct place. Here is my code now
unID = 1
 HOTSPOT 0.2, 0, 0, unID, ang, 4 : unID=unID+1 ! Base 
 HOTSPOT 0.2*COS(ang), 0, 0.2*SIN(ang), unID, ang, 5 : unID=unID+1 ! Moving 
 HOTSPOT 0, 0, 0, unID, ang, 6 : unID=unID+1 ! Centre 
 HOTSPOT 0, 2, 0, unID, ang, 7 : unID=unID+1 ! Reference 
It rotates around the Y axis but the hotspot doesn't stay in the correct place :S

Thanks very much for your help!
ArchiCAD 23

Windows 10
Bruce
Advisor
1. Shift the unID = 1 declaration into the Master script.
2. In longer scripts, you will need the ROTY -ang command (in my first example) prior to the hotspots to reset the Base hotspot properly - otherwise your hotspot will just follow your geometry, and reset every time
3. It's also handy to limit your ang in the Parameter script so it behaves logically, i.e. VALUES "ang" RANGE [0, 360)
4. The Z coord for the hotspot needs to be negative in this case.

The below script works for me (it's just my quirk to put the unID=unID+1 statement before the HOTSPOT command):




unID=unID+1 : HOTSPOT 0.2, 0, 0, unID, ang, 4 + 128					!Base
unID=unID+1 : HOTSPOT 0.2*COS(ang), 0, -0.2*SIN(ang), unID, ang, 5	!Moving
unID=unID+1 : HOTSPOT 0, 0, 0, unID, ang, 6							!Centre
unID=unID+1 : HOTSPOT 0, 1, 0, unID, ang, 7							!Reference

ROTY ang

BLOCK 1, 1, 1

DEL 1
Bruce Walker
Barking Dog BIM YouTube
Mindmeister Mindmap
-- since v8.1 --
AC27 5060 INT Full | Windows 11 64 Pro | 12th Gen Intel i7-12700H 2.30 GHz | 64 Gb RAM | NVIDIA GeForce RTX 3060 32 Gb
JGoode
Expert
Bruce wrote:
4. The Z coord for the hotspot needs to be negative in this case.
Thanks very much! Out of curiosity, why does the Z coord for the hotspot need to be negative? Very much appreciated!
ArchiCAD 23

Windows 10
Bruce
Advisor
It has to do with the direction of rotation in GDL, combined with the ROTY to rotate the geometry. I still get confused over it, but that's the reason.
Bruce Walker
Barking Dog BIM YouTube
Mindmeister Mindmap
-- since v8.1 --
AC27 5060 INT Full | Windows 11 64 Pro | 12th Gen Intel i7-12700H 2.30 GHz | 64 Gb RAM | NVIDIA GeForce RTX 3060 32 Gb