Home › Forums › General discussions › Need help with editable hotspots.
Tagged: Hotspot, GLOB_MODPAR_NAME, GLOB_FEEDBACK_MODE
- This topic has 6 replies, 2 voices, and was last updated 6 years ago by Mats Knutsson.
-
AuthorPosts
-
-
December 18, 2018 at 11:33 #4410Mats KnutssonParticipant
Hi,
In the plan view I want to drag “Diameter” of circular shapes.
I didn’t manage to solve the programming with Diameter so I resorted to Radius which is also how ArchiCAD defines circles and that worked from a programming point of view.
This morning I had a new go at it because I really want to drag the diameter instead of the radius.But…I must have done something wrong since it doesn’t work out for me. I’ve tried different ways but the one shown below should work…at least according to my stupid self. Radius=Diameter/2… bot computer says NO…. I have no idea how to solve this and am grateful for help.
Regards,
MatsAttachments:
-
December 18, 2018 at 13:56 #4412Péter BaksaKeymaster
Hi,
editable hotspots work only with parameters, not variables.
The solution is to use a hidden parameter that is edited by the hotspot. In your example add a parameter named rsp.
Now you have to update any changes the user makes in dsp to rsp, in the parameter script:rsp = dsp / 2 parameters rsp = rsp
But when rsp is edited by the hotspots, you will need to change dsp. This can be done with the GLOB_MODPAR_NAME global variable:
if GLOB_MODPAR_NAME = "rsp" then dsp = rsp * 2 parameters dsp = dsp else rsp = dsp / 2 parameters rsp = rsp endif
If you want, you can show the value of dsp during hotspot editing:
hotspot2 rsp, 0, 4, rsp, 2, dsp
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE-
December 19, 2018 at 13:53 #4422Mats KnutssonParticipant
Thanks but I don’t get it. I think I need it coded to understand. Is the “if”-part supposed to be also in the Parameter script? I tried several things but ended up with the same behaviour as before…that is dragging the radius…which would be just perfect if I didn’t want the diameter 🙂
-
-
December 19, 2018 at 14:32 #4423Péter BaksaKeymaster
So you want that the center of the circle moves with dragging the diameter?
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE-
December 19, 2018 at 21:42 #4424Mats KnutssonParticipant
No. Center should stay put. The objects are lamps and they are defined by their diameter.
-
December 20, 2018 at 08:45 #4425Péter BaksaKeymaster
OK, then I need to explain where to put the code fragments I wrote.
Use your 2D code as in the picture top part, and in the parameter list add a parameter dsp, hide the parameter rsp.
To the param script insert:if GLOB_MODPAR_NAME = "rsp" then dsp = rsp * 2 parameters dsp = dsp else rsp = dsp / 2 parameters rsp = rsp endif
and in 2D script replace your 4th (non-blank) line with
hotspot2 rsp, 0, 4, rsp, 2, dsp
During dragging the hotspot, the radius line will be shown, but the parameter value in the tracker will be the diameter. You can show the diameter using:
if GLOB_FEEDBACK_MODE then line2 -rsp, 0, rsp, 0
Péter Baksa
Library Platform, Software Engineer
GRAPHISOFT SE -
December 20, 2018 at 20:46 #4426Mats KnutssonParticipant
Works like charm Peter. Thanks!!! Now I’ll try to understand it. Hopefully I still have the gdl cookbok and handbook somewhere in my basement.
-
-
-
-
AuthorPosts
- The forum ‘General discussions’ is closed to new topics and replies.