GDL
About building parametric objects with GDL.

Moving part of an objet with a hotspot

Anonymous
Not applicable
I am trying to put in place an objet that has a 3D form and 2D éléments, the red lines (please see images). I would like to allow the user to move manually the 2D lines in red. The 2D red lines are on itself an objet that is called into the final object.

I have managed to use the ADD2 and allow to enter a distance but I would prefer to let the user freely move that part of the objet (the 3D doesn't move).

So far this is the code that I have to call the 2D lines and move it by the ADD2 command. How could I change so to have a point to manually drag the red lines?

Thank you in advance.

ADD2 0,-AF5_A
        gosub "symbole 2D"

            end

"symbole 2D":
call    "AF1",
    PARAMETERS A = 0.187450297757, B = 0.176699818365, ZZYZX =            1,
        AC_show2DHotspotsIn3D =      1, ac_bottomlevel =            1,
        ac_toplevel =            0, use_stored_environment =      0,
        lineTypeAttribute_1 = lineTypeAttribute_1, penAttribute_1 = penAttribute_5,
        penAttribute_2 = penAttribute_6, penAttribute_3 = penAttribute_7
del          2
pen     penAttribute_6
hotspot2 -1.027559348263E-16, 0.04500000948274
hotspot2 -1.192886700985E-16, -0.04500000948182
hotspot2 -1.110223024625E-16, 1.110223024625E-16
hotspot2       -0.012, 1.37906053464E-9

11 REPLIES 11
Anonymous
Not applicable
You will have to check the GDL Reference Manual for Hotspots, graphical editing.
If you need to graphically control the symbol position in X and Y axis, you will have to create two parameters for X and Y. Like this:
! Top X
hotspot2 0, pointDistY, unID, pointDistX, 1+128		!BASE (hidden)
unID = unID + 1
hotspot2 -1, pointDistY, unID, pointDistX, 3		!REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistX, 2	!MOVING
unID = unID + 1

! Top Y
hotspot2 pointDistX, 0, unID, pointDistY, 1+128		!BASE (hidden)
unID = unID + 1
hotspot2 pointDistX, -1, unID, pointDistY, 3		!REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistY, 2	!MOVING
unID = unID + 1
Anonymous
Not applicable
Thanks Paulo for pointing me on the right direction.

I have added to the script. I end out with 2 new hotspots but they stretch the object in X and not just move it.
I read the web page you linked and as far I understood the script in your answer is indicated for this kind of stretching action with a 3 point set, is that the case?

I also noticed that when I create the final objet : a 3D form plus the 2D symbol object, the hotspots end out changing both elements despite being a part of the 2D objet script. Meaning: the 3D form is also stretched.

(I did create two parameters pointDistY and pointDistX.)

This is the 2D symbol script this far. I would appreciate some more imput. Thank you in advance.
!
!   Nom     : AF6.gsm
!   Date     : mardi, 13 octobre 2020, sem42
!   Version  : 23.00
!   Ecrit par ARCHICAD 
!

mul2     A/0.187450, B/0.176700
add2     0.05098826905808, 0.2189775023075
drawindex      10
pen     penAttribute_1
hotspot2 -0.0007097591905634, -0.09255619380979
pen     penAttribute_2
set line_type lineTypeAttribute_1
poly2_b{5}       7,      1,      0,      3,      1,      0, 
                   0,            0,            1,            0,            0,            1,            0, 
        -0.0007097591905705, -0.1428347036773,      1, 
        -0.0007097591905634, -0.09255619380979,    900, 
                   0,         -180,   4001, 
        -0.0007097591905563, -0.04227768394227,      1, 
        -0.0007097591905634, -0.09255619380979,    900, 
                   0,         -180,   4001, 
        -0.0007097591905705, -0.1428347036773,      1
poly2_b{5}       3,      1,      0,      3,      1,      0, 
                   0,            0,            1,            0,            0,            1,            0, 
        0.1364620286997, -0.1853160783561,      1, 
        0.08905403801306, -0.2189775023075,      1, 
        0.02734142743587, -0.1320628527151,      1

unID = 1
hotspot2 0, 0, unID, A, 1+256		!BASE (editable)
unID = unID + 1
hotspot2 -1, 0, unID, A, 3		!REFERENCE
unID = unID + 1
hotspot2 A, 0, unID, A, 2		!MOVING
unID = unID + 1

! Top X
hotspot2 0, pointDistY, unID, pointDistX, 1+128		!BASE (hidden)
unID = unID + 1
hotspot2 -1, pointDistY, unID, pointDistX, 3		!REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistX, 2	!MOVING
unID = unID + 1

! Top Y
hotspot2 pointDistX, 0, unID, pointDistY, 1+128		!BASE (hidden)
unID = unID + 1
hotspot2 pointDistX, -1, unID, pointDistY, 3		!REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistY, 2	!MOVING
unID = unID + 1
Barry Kelly
Moderator
If you want to move the 2D symbol, the the hotspots go in the parent object before you call the 2D symbol.

So in your example....

! Top X
hotspot2 0, pointDistY, unID, pointDistX, 1+128		!BASE (hidden)
unID = unID + 1
hotspot2 -1, pointDistY, unID, pointDistX, 3		!REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistX, 2	!MOVING
unID = unID + 1

! Top Y
hotspot2 pointDistX, 0, unID, pointDistY, 1+128		!BASE (hidden)
unID = unID + 1
hotspot2 pointDistX, -1, unID, pointDistY, 3		!REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistY, 2	!MOVING
unID = unID + 1

ADD2 0+pointDistX,-AF5_A+pointDistY
        gosub "symbole 2D"

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Anonymous
Not applicable
Hi Barry, thanks for your help.

First, could you please tell me how to add the script line number ? I don't see the line numbers so I have to count sometimes...

I ended out with the possibility to move the 3D form instead of the symbol. I've tried to change the order of the actions in the script and this is the best I could do as seen on the before and after images attached.

There are also two hotspots apparently: one moves the form the other deforms. I wish I had only one.
Also there is this reference to one old objet AF5 on this line and I am not sure if I should replace it with the name of the parent objet or the 2D objet....
ADD2 0+pointDistX,-AF5_A+pointDistY
I would appreciate if you could take a look at the new script. I am not sure if it's clear that first I created the 2D object and then selected it plus the form to create the final (parent) object.

-------

This is the 2D script in the parent object:

!
!   Nom     : AF 9.gsm
!   Date     : mercredi, 14 octobre 2020, sem42
!   Version  : 23.00
!   Ecrit par ARCHICAD 
!

mul2     A/0.232874, B/0.187450
add2     -0.6585512900043, 0.975161330242
drawindex      10
pen     penAttribute_1
set line_type lineTypeAttribute_1
add2     5.60870331016, 11.36672783119
rot2               90
call    "objet 2d partiel",
    PARAMETERS A = 0.1874502977578, B = 0.1766998183652, ZZYZX =            1,
        AC_show2DHotspotsIn3D =      1, ac_bottomlevel =            1,
        ac_toplevel =            0, use_stored_environment =      0,
        lineTypeAttribute_1 = lineTypeAttribute_2, penAttribute_1 = penAttribute_2,
        penAttribute_2 = penAttribute_3
del          2
add2     0.6685512900043, -0.9683215099236
rot2               90



unID = 1
hotspot2 0, 0, unID, A, 1+256        !BASE (editable)
unID = unID + 1
hotspot2 -1, 0, unID, A, 3        !REFERENCE
unID = unID + 1
hotspot2 A, 0, unID, A, 2        !MOVING
unID = unID + 1





! Top X
hotspot2 0, pointDistY, unID, pointDistX, 1+128        !BASE (hidden)
unID = unID + 1
hotspot2 -1, pointDistY, unID, pointDistX, 3        !REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistX, 2    !MOVING
unID = unID + 1

! Top Y
hotspot2 pointDistX, 0, unID, pointDistY, 1+128        !BASE (hidden)
unID = unID + 1
hotspot2 pointDistX, -1, unID, pointDistY, 3        !REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistY, 2    !MOVING
unID = unID + 1



ADD2 0+pointDistX,-AF5_A+pointDistY
  

call    "objet 3d partiel",
    PARAMETERS A = 0.09000019122113, B = 0.01000000000001, ZZYZX = 0.09000001896616,
        AC_show2DHotspotsIn3D =      1, ac_bottomlevel =            1,
        ac_toplevel =            0, use_stored_environment =      0,
        fillAttribute_1 = fillAttribute_1, lineTypeAttribute_1 = lineTypeAttribute_2,
        materialAttribute_1 = materialAttribute_1, penAttribute_1 = penAttribute_4,
        penAttribute_2 = penAttribute_5, penAttribute_3 = penAttribute_6,
        penAttribute_4 = penAttribute_3, buildingMatAttribute_1 = buildingMatAttribute_1
del          2
Barry Kelly
Moderator
afaria wrote:
First, could you please tell me how to add the script line number ? I don't see the line numbers so I have to count sometimes...

You can't see the line numbers in the GDL editor.
However, place your cursor in any line and press CTRL+L and you will see the line number of that line.
You can then type any line number and ENTER and you will be taken to that line.


Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Barry Kelly
Moderator
You have the hotspot for the X & Y position (pointDistX & pointDistY).
These are two hotspots but scripted so they work as one and move in both the x & y direction.

If you want to move the 2D object, use the hotspot scripts, then ADD2 pointDistX, pointDistY.
Then call the 2D object.
Then DEL one to remove the ADD2 transformation - placing you back at the same position you started at.
Always try to return to the origin.

If you want to move the 3D object (or at l should say the 2D view of the 3D object) then you would place the hotspots script, ADD2 pointDistX, pointDistY, and then call the 3D object and DEL 1.
Don't forget if you are moving the placement of the 3D object in the 2D script, you should also move it in the 3D script so they match.

afaria wrote:
Also there is this reference to one old objet AF5 on this line and I am not sure if I should replace it with the name of the parent objet or the 2D objet....

ADD2 0+pointDistX,-AF5_A+pointDistY

The -AF5_A I got from your original code.
You were ADDing a distance before you placed your object.
I kept it the same and add the hotspot distances to it, so it would remain at the distance -AF5_A when the hotspot values are zero.
If you don't want it you can take it out.


The editable hotspot referencing A is the one stretching the size of the object.
If you don't want it, remove it.


you basic code to place the 3D object and then have a moveable 2D object should be something like ...

CALL 3D_object

! Top X
hotspot2 0, pointDistY, unID, pointDistX, 1+128 !BASE (hidden)
unID = unID + 1
hotspot2 -1, pointDistY, unID, pointDistX, 3 !REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistX, 2 !MOVING
unID = unID + 1

! Top Y
hotspot2 pointDistX, 0, unID, pointDistY, 1+128 !BASE (hidden)
unID = unID + 1
hotspot2 pointDistX, -1, unID, pointDistY, 3 !REFERENCE
unID = unID + 1
hotspot2 pointDistX, pointDistY, unID, pointDistY, 2 !MOVING
unID = unID + 1

ADD2 0+pointDistX,pointDistY

CALL 2D_object

DEL 1

Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Anonymous
Not applicable
Hi Barry,

Thank you very much for your help. The objects are done. Things I will try to do later: texts should be always readable (if the final object is turned) and adjust to scale, and I still dont understand how to manage the point into which the 2D object is placed the first time.

Also, as of yesterday I had only two objects: one parent and one linked. I understood from you last answer that indeed I should have 3: one parent and two linked.

Again, thank you very much.
Barry Kelly
Moderator
afaria wrote:
Things I will try to do later: texts should be always readable (if the final object is turned) and adjust to scale

Do a search in this forum and you will find a few post relating to this problem.

afaria wrote:
Also, as of yesterday I had only two objects: one parent and one linked. I understood from you last answer that indeed I should have 3: one parent and two linked.

I was just going by what you had in your script sample.
You have the parent object and it calls the 2D (call "objet 2d partiel") which I assume is the circle and lines.
And then you call the 3D object (call "objet 3d partiel") which I asume is the box (as it is in the 2D script it will display the 2D view of that 3D object).
So it just depends if you want to move the lines or the box.
You place the hotspot commands and the ADD2 before the CALL for the object you want to move.
Then DEL 1 after the call to undo the move and place you cursor back to where it was before.


Barry.
One of the forum moderators.
Versions 6.5 to 27
i7-10700 @ 2.9Ghz, 32GB ram, GeForce RTX 2060 (6GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Anonymous
Not applicable
Yes. sooner or later I will try to tackle the text orientation and scale.
Thank you !

Didn't find the answer?

Check other topics in this Forum

Back to Forum

Read the latest accepted solutions!

Accepted Solutions

Start a new conversation!