Developer forum
cancel
Showing results for 
Search instead for 
Did you mean: 

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

mendezarcediego
Contributor

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

AC25–4013 INT / MacOS BigSur 11.6 / iMac Pro (2017) / 3,2 GHz 8-Core Intel Xeon W / 32 GB 2666 MHz DDR4 / Radeon Pro Vega 56 8 GB.
1 ACCEPTED SOLUTION

Solution
juliencuadra
Enthusiast

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
Champion

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 7000
Self-taught, bend it till it breaks.

Win10 | E5620 x 2 | 24GB | K2200 RIP PSU
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

 

AC25–4013 INT / MacOS BigSur 11.6 / iMac Pro (2017) / 3,2 GHz 8-Core Intel Xeon W / 32 GB 2666 MHz DDR4 / Radeon Pro Vega 56 8 GB.

Lingwisyer
Champion

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 7000
Self-taught, bend it till it breaks.

Win10 | E5620 x 2 | 24GB | K2200 RIP PSU
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 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

The parameters of ROT are

ROT x, y, z, alpha

a vector to rotate around, not angles in order, and it is an error if you omit some.

Do you know about some legacy command that isn't in the reference guide?

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Solution
juliencuadra
Enthusiast

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
Contributor

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.

AC25–4013 INT / MacOS BigSur 11.6 / iMac Pro (2017) / 3,2 GHz 8-Core Intel Xeon W / 32 GB 2666 MHz DDR4 / Radeon Pro Vega 56 8 GB.

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

 


@juliencuadra 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 25
Dell XPS- i7-6700 @ 3.4Ghz, 16GB ram, GeForce GTX 960 (2GB), Windows 10
Dell Precision 3510 - i7 6820HQ @ 2.70GHz, 16GB RAM, AMD FirePro W5130M, Windows 10

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

Lingwisyer
Champion

From my understanding, the EPS lines will not be the ones giving you the precision error as it only turns up when you use equals. Rounded, it might be equal, but in reality it may not. Hence < EPS is used as it is essentially zero without actually being zero.

AC22-23 AUS 7000
Self-taught, bend it till it breaks.

Win10 | E5620 x 2 | 24GB | K2200 RIP PSU
Win10 | R5 2600 | 16GB | GTX1660

I checked on my pc  and it is indeed the lines with if bProject2D & ABS(rotAngleX)& ABS(rotAngleY) < EPS then that are generating the error.

 

My guess is that since bProject2D is a boolean  and it is evaluated as a number as its value is checked against EPS Archicad treats is as a real number.

and since this line compares a real to a float you get this warning.

 

Probably you wanted to write

 

... ABS(rotAngleX) < EPS & ABS(rotAngleY) < EPS ...

 

& has lower precedence than < so

 

ABS(rotAngleX) & ABS(rotAngleY) < EPS

 

is really

 

(ABS(rotAngleX)) & (ABS(rotAngleY) < EPS)

 

where ABS(rotAngleX) is a real number tested as a boolean, so the warning is legitimate.

Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

Hi Peter, yes I thought it would be evaluated as the first line you wrote.

Since it worked written like this I didn't think twice about it.

Thanks for the clarification.

Sorry for my late response. Thanks for all the help from everyone. I tried your suggestion of using < if bProject2D & (ABS(rotAngleX)) & (ABS(rotAngleY) < EPS) then > but I still get that minor warning, I wonder if I inserted the code incorrectly.

AC25–4013 INT / MacOS BigSur 11.6 / iMac Pro (2017) / 3,2 GHz 8-Core Intel Xeon W / 32 GB 2666 MHz DDR4 / Radeon Pro Vega 56 8 GB.

What you have written above is still wrong. You need to check both rotAngleX & rotAngleY against EPS separately. Effectively what you have is three arguments you want to test against so you should split it into three lines (using the line continue character "\") so its easier to see the logic.

 

Your current logic looks like this:

    if bProject2D \

    & ABS(rotAngleX)  \

    & ABS(rotAngleY)  < EPS then...

 

in extended form this reads as:

    if bProject2D = 1 \

    & ABS(rotAngleX) = 1  \

    & ABS(rotAngleY)  < EPS then...

 

So the "real value" error is coming from the second line.

You need to write this:

    if bProject2D \

    & ABS(rotAngleX)  < EPS  \

    & ABS(rotAngleY)  < EPS then...

 

Which is what Peter described above.

Creator of Cadswift's parametric GDL libraries
Creator of Infinite Openings and Component Catalogues
Push the envelope & watch it bend
website: https://cadswift.com.au/
YouTube: https://www.youtube.com/user/CADSwift/playlists

Lingwisyer
Champion

So the opposite problem? So to get rid of it you would have to split out the bProject2D = 0?

AC22-23 AUS 7000
Self-taught, bend it till it breaks.

Win10 | E5620 x 2 | 24GB | K2200 RIP PSU
Win10 | R5 2600 | 16GB | GTX1660

There is no problem.

The error message is a generic one, it just points out that you use different types at the same time, it's just a warning. In this case it doesn't matter and won't cause any problem.

Generic and annoying as hell... In one of my objects, the only way I have figured out how to get rid of it is to change all of my A = B to B - EPS < A < B + EPS... What is more annoying is that A and B are defined by condition statements earlier in the script, defining them as equal or not so that I can use a single SUB. Just fills my error report with junk...

AC22-23 AUS 7000
Self-taught, bend it till it breaks.

Win10 | E5620 x 2 | 24GB | K2200 RIP PSU
Win10 | R5 2600 | 16GB | GTX1660

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!