We value your input! Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey
2022-02-23 07:59 PM
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?
Solved! Go to Solution.
2022-02-24 03:45 PM - last edited on 2022-02-28 10:31 PM by Laszlo Nagy
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
2022-02-24 02:19 AM - edited 2022-02-24 02:22 AM
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 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2022-02-24 02:48 AM - last edited on 2022-02-28 10:31 PM by Laszlo Nagy
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
2022-02-24 03:03 AM - edited 2022-02-24 03:36 AM
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 | Help Those Help You - Add a Signature |
Self-taught, bend it till it breaks | Creating a Thread |
Win11 | i9 10850K | 64GB | RX6600 | Win10 | R5 2600 | 16GB | GTX1660 |
2022-02-24 03:13 AM
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.
2022-02-24 03:45 PM - last edited on 2022-02-28 10:31 PM by Laszlo Nagy
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
2022-02-24 06:56 PM
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.
2022-02-25 08:56 AM - edited 2022-02-25 01:14 PM
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
2022-02-25 09:31 AM
@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 ...
Search for ... Use of real types can result in precision problems
and you will see more posts.
Barry.
2022-02-25 09:33 AM
Oops... didn't have my coffee yet when I typed this.