GDL
About building parametric objects with GDL.
SOLVED!

Archicad's GDL lamp is duplicating an element when adding "ROTY"

mendezarcediego
Booster

Help please! I've modified Archicad's "Spotlight Kit 25" Lamp object to rotate along its "Y" axis. But when I rotate it, one of its original elements gets duplicated, as if I made a copy as I was rotating.

 

The object from the screenshot has been rotated 15deg around its "y" axis and 15deg around its "x" axis.

 

FYI: I'm not a programer but I managed to add the new parameter to the interface and all, I just can't get this "duplicated" element to disappear, I'm sure I copy-pasted some code line without really understanding what it does and that is generating this issue. 

 

On a separate note, why can't I rotate around the Y axis by default?

Screen Shot 2022-02-23 at 12.48.23.pngScreen Shot 2022-02-23 at 12.54.31.pngScreen Shot 2022-02-23 at 12.48.47.png

AC26–5002 INT FULL/ Win 11 Pro 22621.1992 / Intel i9-13900KF 24C (8P-16E) 3.00 - 5.80 GHz / 64 GB 5600 MHz DDR5 / Nvidia RTX A4500 20GB, Dual 2560x1440.
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
julienK
Advocate

You are duplicating the code that generates the geometry. All you need to add is the additional transformation. Add/edit these 5 lines in the original code.

 

roty rotAngleY                           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
rotx rotAngleX


if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mulz -1
endif

if iMountType <> 3 and iMountType <> 4 and iMountType <> 5 then
if iMountCover = 3 then
mount_cover_h = 0
else
mount_cover_h = 0.04
if iMountCover = 1 then gosub "MOUNTCOVER_1"
if iMountCover = 2 then gosub "MOUNTCOVER_2"
endif
endif

if iMountType = 1 then
gosub "MOUNT_1"
endif
if iMountType = 2 then
gosub "MOUNT_2"
endif
if iMountType = 3 then
gosub "MOUNT_3"
endif
if iMountType = 4 then
gosub "MOUNT_4"
endif
if iMountType = 5 then
gosub "MOUNT_5"
endif
if iMountType = 6 then
gosub "MOUNT_6"
endif
if iMountType = 7 then
gosub "MOUNT_7"
endif
if iMountType = 8 then
gosub "MOUNT_8"
endif
if iMountType = 9 then
gosub "MOUNT_9"
endif
if iMountType = 10 then
gosub "MOUNT_10"
endif
if iMountType = 11 then
gosub "MOUNT_11"
endif

if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
del 1
endif



actrot_x = 90

! ==============================================================================
! Spots & Light Cone
! ==============================================================================

_sumDistZ = 0

for actsp=1 to numSpots

actspotangle_h = spotangle_h[actsp]
actspotangle_v = spotangle_v[actsp]

add xSpotPos[actsp], ySpotPos[actsp], zSpotPos[actsp]
if GLOB_CONTEXT = 23 or GLOB_CONTEXT = 24 then
if (iSpotOrientation = 3) or (iSpotOrientation = 2 and actsp = 1) then
resol 32
pen penSpotPosition
model wire
circle hotspotdist
rotz -actspotangle_h
roty 90
arc hotspot2dist, 0, 90
del 2
model solid
resol gs_resol
endif
endif

pen gs_cont_pen

rotx actrot_x

if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
addy 0.5
muly -1
endif
gosub actspot
if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
del 2
endif

gosub "LIGHTCONE"
del 2

 

 

View solution in original post

20 REPLIES 20
Lingwisyer
Guru

The code section just above your highlighted bit looks the same? Is that the original part that you copied? Should you not just be adding the Y rotation to the start of that section rather than copying it? What are the goSUBs (I do not have access to 25...)? My guess is that "Mount" are the various rail options, so since you have copied the section, you have one being generated by the previous, and one from your rotation.

 

 

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660 

I did change the Y rotation on that new section, I have no idea what "goSUB" does. I don't know how to save as an earlier version. Let's see if I can paste all the code in several attachments. Here's that section of that added code meanwhile, along with the section I copied it from:

 

! --- Rotación en el eje X (original section I copied from)---

rotx rotAngleX

if bProject2D & ABS(rotAngleX) < EPS then
mulz -1
endif

if iMountType <> 3 and iMountType <> 4 and iMountType <> 5 then
if iMountCover = 3 then
mount_cover_h = 0
else
mount_cover_h = 0.04
if iMountCover = 1 then gosub "MOUNTCOVER_1"
if iMountCover = 2 then gosub "MOUNTCOVER_2"
endif
endif

if iMountType = 1 then
gosub "MOUNT_1"
endif
if iMountType = 2 then
gosub "MOUNT_2"
endif
if iMountType = 3 then
gosub "MOUNT_3"
endif
if iMountType = 4 then
gosub "MOUNT_4"
endif
if iMountType = 5 then
gosub "MOUNT_5"
endif
if iMountType = 6 then
gosub "MOUNT_6"
endif
if iMountType = 7 then
gosub "MOUNT_7"
endif
if iMountType = 8 then
gosub "MOUNT_8"
endif
if iMountType = 9 then
gosub "MOUNT_9"
endif
if iMountType = 10 then
gosub "MOUNT_10"
endif
if iMountType = 11 then
gosub "MOUNT_11"
endif

if bProject2D & ABS(rotAngleX) < EPS then
del 1
endif

actrot_x = 90

! --- Rotación en el eje Y (added code)---

roty rotAngleY

if bProject2D & ABS(rotAngleY) < EPS then
mulz -1
endif

if iMountType <> 3 and iMountType <> 4 and iMountType <> 5 then
if iMountCover = 3 then
mount_cover_h = 0
else
mount_cover_h = 0.04
if iMountCover = 1 then gosub "MOUNTCOVER_1"
if iMountCover = 2 then gosub "MOUNTCOVER_2"
endif
endif

if iMountType = 1 then
gosub "MOUNT_1"
endif
if iMountType = 2 then
gosub "MOUNT_2"
endif
if iMountType = 3 then
gosub "MOUNT_3"
endif
if iMountType = 4 then
gosub "MOUNT_4"
endif
if iMountType = 5 then
gosub "MOUNT_5"
endif
if iMountType = 6 then
gosub "MOUNT_6"
endif
if iMountType = 7 then
gosub "MOUNT_7"
endif
if iMountType = 8 then
gosub "MOUNT_8"
endif
if iMountType = 9 then
gosub "MOUNT_9"
endif
if iMountType = 10 then
gosub "MOUNT_10"
endif
if iMountType = 11 then
gosub "MOUNT_11"
endif

if bProject2D & ABS(rotAngleY) < EPS then
del 1
endif

actrot_y = 90

 

AC26–5002 INT FULL/ Win 11 Pro 22621.1992 / Intel i9-13900KF 24C (8P-16E) 3.00 - 5.80 GHz / 64 GB 5600 MHz DDR5 / Nvidia RTX A4500 20GB, Dual 2560x1440.
Lingwisyer
Guru

goSUB is a command that links a secondary portion of script. These are usually found at the bottom after the END command.

 

Any clue what bProject2D is? Not quite sure what the following is doing...

if bProject2D & ABS(rotAngleY) < EPS then...

but your ROTy should just go after the original ROTx. This could also be written as

ROT rotAngleX, rotAngleY, 0

Same with your closing additions.

There is no need to duplicate all of the goSUB commands.

 

 

Ling.

AC22-23 AUS 7000Help Those Help You - Add a Signature
Self-taught, bend it till it breaksCreating a Thread
Win10 | R5 2600 | 16GB | GTX1660 

Looking at this quickly, you have duplicated a whole section of code.

That is why it is creating a second lamp (or part of the lamp).

 

Just add the ROTy next to the ROTx and then an extra DEL 1 at the end of the script that next to the one undoing the ROTx.

Don't duplicate all of the GOSUBs which are placing the mount.

 

Depending on whether you have ROTx first or ROTy first will depend on how it rotates in 3D if you use bot parameters.

If you only set a value for one it will only rotate in that one axis.

But if you set values for both, then it will rotate one axis first and then rotate the second axis taking into account the rotation of the first axis - if that makes sense.

This may or not be what you are trying to achieve.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11
Solution
julienK
Advocate

You are duplicating the code that generates the geometry. All you need to add is the additional transformation. Add/edit these 5 lines in the original code.

 

roty rotAngleY                           !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
rotx rotAngleX


if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
mulz -1
endif

if iMountType <> 3 and iMountType <> 4 and iMountType <> 5 then
if iMountCover = 3 then
mount_cover_h = 0
else
mount_cover_h = 0.04
if iMountCover = 1 then gosub "MOUNTCOVER_1"
if iMountCover = 2 then gosub "MOUNTCOVER_2"
endif
endif

if iMountType = 1 then
gosub "MOUNT_1"
endif
if iMountType = 2 then
gosub "MOUNT_2"
endif
if iMountType = 3 then
gosub "MOUNT_3"
endif
if iMountType = 4 then
gosub "MOUNT_4"
endif
if iMountType = 5 then
gosub "MOUNT_5"
endif
if iMountType = 6 then
gosub "MOUNT_6"
endif
if iMountType = 7 then
gosub "MOUNT_7"
endif
if iMountType = 8 then
gosub "MOUNT_8"
endif
if iMountType = 9 then
gosub "MOUNT_9"
endif
if iMountType = 10 then
gosub "MOUNT_10"
endif
if iMountType = 11 then
gosub "MOUNT_11"
endif

if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
del 1
endif



actrot_x = 90

! ==============================================================================
! Spots & Light Cone
! ==============================================================================

_sumDistZ = 0

for actsp=1 to numSpots

actspotangle_h = spotangle_h[actsp]
actspotangle_v = spotangle_v[actsp]

add xSpotPos[actsp], ySpotPos[actsp], zSpotPos[actsp]
if GLOB_CONTEXT = 23 or GLOB_CONTEXT = 24 then
if (iSpotOrientation = 3) or (iSpotOrientation = 2 and actsp = 1) then
resol 32
pen penSpotPosition
model wire
circle hotspotdist
rotz -actspotangle_h
roty 90
arc hotspot2dist, 0, 90
del 2
model solid
resol gs_resol
endif
endif

pen gs_cont_pen

rotx actrot_x

if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then   !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
addy 0.5
muly -1
endif
gosub actspot
if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
del 2
endif

gosub "LIGHTCONE"
del 2

 

 

mendezarcediego
Booster

Thanks a lot for the help!, in deed that was the problem. One last question, I used your code but I now get a minor warning saying that "Use of real types can result in precision problems

at line 295/343/381/386 in the 3D script of file Spotlight Kit 25 Y.gsm." Should I worry about it? and Can it be fixed? ( I'm not a programmer as you can tell) I read in some other conversation this that when the if statement is correct it shouldn't be a problem but this this was all dealing with numbers.

AC26–5002 INT FULL/ Win 11 Pro 22621.1992 / Intel i9-13900KF 24C (8P-16E) 3.00 - 5.80 GHz / 64 GB 5600 MHz DDR5 / Nvidia RTX A4500 20GB, Dual 2560x1440.

I can't be sure  but since you get 4 errors i'm gonna assume the lines refered to in the error message are the one where you added & ABS(rotAngleY) .

To fix this error make sure on the parameter definition page that the rotAngleY parameter you created is  of type angle.  !changed length to angle (thx barry)

The error is normal and won't have any  incidence outside of the gdl editor,  it won't show anything when you use the objet

 

Capture d’écran 2022-02-25 085115.jpg

 


@julienK wrote:

I can't be sure  but since you get 4 errors i'm gonna assume the lines refered to in the error message are the one where you added & ABS(rotAngleY) .

To fix this error make sure on the parameter definition page that the rotAngleY parameter you created is  of type length.


 

No the angle parameter needs to be an 'angle' type - not length.

 

The error seems to be these lines I think ...

 

if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then

 

I have no idea what 'bProject2D' and I assume 'EPS' is a very small decimal number.

I assume 'bProject2D' is a boolean parameter - i.e. 1 or 0

I think the warning is just saying you are trying to compare a real number and angles that could have any decimal precision with the value of 'EPS".

The probably is not problem - just a warning.

 

See here for one explanation ...

 

https://community.graphisoft.com/t5/Design-forum/Errors-when-loading-objects-from-8-1/m-p/48630?p=24...

 

Search for ... Use of real types can result in precision problems

and you will see more posts.

 

Barry.

One of the forum moderators.
Versions 6.5 to 27
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Lenovo Thinkpad - i7-1270P 2.20 GHz, 32GB RAM, Nvidia T550, Windows 11

Oops... didn't have my coffee yet when I typed this.