We value your input!
Please participate in Archicad 28 Home Screen and Tooltips/Quick Tutorials survey

Libraries & objects
About Archicad and BIMcloud libraries, their management and migration, objects and other library parts, etc.

Dashed Line om 3d GDL issue

Anonymous
Not applicable
Hello I'm trying to create a dashed line on 3d with GDL but I'm getting many errors with this subroutine that I copied from GDL cookbook, can anyone help me please?

I'm getting Missing Keyword (or smthing like it, I'm translating from french) on line 6 and illegal character on line 28.

I've pasted the code here, if someone can help me I would apreciate it.



!Draw a Dashed Line Segment
getValues = 1
put 0, 0, 0, a, b, zzyzx
gosub “7 Dashed Line”

“7 Dashed Line”:
!Input:
! - Line end points: (x1~7, y1~7, z1~z) and (x2~7, y2~7, z2~7)
! - Dash length: dashLength~7
if getValues then
x1~7 = get(1): y1~7 = get(1): z1~7 = get(1)
x2~7 = get(1): y2~7 = get(1): z2~7 = get(1)
dashLength~7 = get(1)
getValues = 0
endif
!Return: NONE
!Draw a dashed line
!Calculate the line length and direction vectors
ux~7 = x2~7 - x1~7
uy~7 = y2~7 - y1~7
uz~7 = z2~7 - z1~7
L~7 = sqr(ux~7^2 + uy~7^2 + uz~7^2)
ux~7 = ux~7/L~7
uy~7 = uy~7/L~7
uz~7 = uz~7/L~7
!Calculate the length of the first and last dashes
nDashes~7 = int(1 + (L~7 + dashLength~7)/(2*dashLength~7))
extraLength~7 = (nDashes~7*(2*dashLength~7) – dashLength~7) – L~7
startLength~7 = dashLength~7 - extraLength~7/2
!Draw the lines
add x1~7, y1~7, z1~7
lin_ 0, 0, 0,
startLength~7*ux~7, startLength~7*uy~7, startLength~7*uz~7
L1~7 = startLength~7 + dashLength~7
repeat
L2~7 = min(L1~7 + dashLength~7, L~7)
lin_ L1~7*ux~7, L1~7*uy~7, L1~7*uz~7,
L2~7*ux~7, L2~7*uy~7, L2~7*uz~7
L1~7 = L2~7 + dashLength~7
until L1~7 > L~7
del 1
return
7 REPLIES 7
Anonymous
Not applicable
The two things that strike me are:

I have always used line numbers (arbitrarily assigned not actual counted ones) for my GOSUBSs. I am guessing that the string value is not supported. I have never seen this. Is there something in the docs about it? Have you used it elsewhere?

I also have never used the "~" (tilde) character in variable names. Perhaps this is not supported. The "_" (underscore) character is more typical.
Anonymous
Not applicable
Thanks, will try changing them Will tell if it worked
Anonymous
Not applicable
Hello,

Text label for subroutines works from version 10.
I have always used line numbers (arbitrarily assigned not actual counted ones) for my GOSUBSs. I am guessing that the string value is not supported. I have never seen this.
Anonymous
Not applicable
Thanks Guys but Didn't work I still get errors, is there a simple way of doing this?!? I just wanted to add a dashed line to my furniture doors, I tried understanding how the lines on the archicad library worked but didn't get there (doors and windows). If anyone could help me I would really appreciate it!
rocorona
Booster
There are a few things to adjust.
1. all those "~7" are gremlins come out from somewhere, but you have to delete them all (use the search and replace command in the Edit menu).

2. there is a missing PUT command, as you PUT 6 values and try to GET 7.

3. at the line 28 [extraLength = (nDashes*(2*dashLength) - dashLength) - L] the "-" are SIMILAR to the "minus" sign, but are in fact different characters. This can happen when copying from PDF, OCR'd text, or other printed sources. Retype them and the "illegal characters" will became "legal".

4. This is an error I've reported many times, as it is also present on the GDL Manual. You can't use DIFFERENT QUOTE SIGNS as delimiters for strings. This has to be read literally. You are not allowed to use an open-close quote pair. The best is to use the single or double "vertical" quote, usually found on the keyboard. But if you use an open-quote to start the string, you have to use the same open-quote at the end.
To be clear:
'string' ! OK
"string" ! OK
“string“ ! OK
”string” ! OK
“string” ! No, this doesn't work.
(so two of the three examples on page 11 of the GDL User Manual are wrong)

5. There is no END statement before the Subroutine, so the program will run to the RETURN one more time, and you will get the "Return without Gosub" error.
getValues = 1  
put 0, 0, 0, a, b, zzyzx 
DashLength=.1  
put DashLength 
gosub "Dashed Line"  
END 
 
"Dashed Line":  
!Input: ! - Line end points: (x1, y1, z1~z) and (x2, y2, z2)  
        ! - Dash length: dashLength  
if getValues then  
	x1 = get(1): y1 = get(1): z1 = get(1)  
	x2 = get(1): y2 = get(1): z2 = get(1)  
	dashLength = get(1)  
	getValues = 0  
endif  
!Return: NONE !Draw a dashed line  
              !Calculate the line length and direction vectors  
ux = x2 - x1  
uy = y2 - y1  
uz = z2 - z1  
L  = sqr(ux^2 + uy^2 + uz^2)  
ux = ux/L  
uy = uy/L  
uz = uz/L  
!Calculate the length of the first and last dashes  
nDashes     = int(1 + (L + dashLength)/(2*dashLength))  
extraLength = (nDashes*(2*dashLength)-dashLength)-L  
startLength = dashLength - extraLength/2  
!Draw the lines  
add x1, y1, z1  
lin_ 0, 0, 0,  
    startLength*ux, startLength*uy, startLength*uz  
L1 = startLength + dashLength  
repeat  
  L2 = min(L1 + dashLength, L)  
  lin_ L1*ux, L1*uy, L1*uz,  
       L2*ux, L2*uy, L2*uz  
  L1 = L2 + dashLength  
until L1 > L  
del 1  
return 
_________________

--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________
Anonymous
Not applicable
Grazie mille!

That worked perfectly, I'm only learning GDL and I find that it's hard to learn it by books and forums only, I don't have any background on programming so it's a bit harder for me!

Thank you again! By the way did u used the same routine? Cause u solved the issue really fast !
rocorona
Booster
luisfmoreira wrote:
Cause u solved the issue really fast !
I just eliminated errors, as I found them.
Maybe I make so many, in my scripting, that I have become skilled at finding them.
_________________

--Roberto Corona--
www.archiradar.com
AC18 - ITA full on Win10
_________________
_________________

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!