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

GDL
About building parametric objects with GDL.
SOLVED!

Is a easy way to transform a POLY2_B into a sequence of HOTLINES?

Otavio Augusto
Enthusiast

Hello again!

I'm making a object of some complex 2D symbols and i would like to be able to select the object by the lines wich are drawned, i know that we use the HOTLINE2 command to make this dream come true.

But my problem is that the drawing is to complex for me to just write the hotlines, or the POLY2_B myself, So i'm drawing what i need to show in 2D and saving it like an object to use the poly2_b auto scripted. But by that, i dont have a consistant way to write te hotlines.

Is there a way to do that easly?

Cause i even tryied to make the chat gpt and gemini to translate the poly2_b cordinates to HOTLINES, it works almost perfectly, but it skips a line... like, the way that i taught GPT it writes a HOTLINE perfectly, but the next one that it writes is a line that is not connected. The request that i did for GPT is the following:

 

The codes are in GDL language, a language specific to the Archicad program, and it is based on and closely related to BASIC.

Here's the translation of your instructions:

Next, I need to create a series of commands called HOTLINE2. This command is written by the following expression:

HOTLINE2 x1, y1, x2, y2, unID

where x1 is the initial position on the X plane of a line, x2 is the final position of the line on the X plane, y1 is the initial position on the Y plane of the same line, and y2 is the final position of the line on the Y plane. The unID expression can be described as 1.

Now I will provide you with a sequence of 211 expressions that contain 3 numbers in each line, separated by ",". The first two numbers in each line correspond to X and Y, respectively. I need you to take these expressions and for every two lines, extract the numbers corresponding to X and Y, identify them as the numbers x1, y1, x2, y2, and place them within the HOTLINE2 x1, y1, x2, y2, 1 expression.

Finally, understand that I do not want an expression that performs this conversion. I want you to present only the results in HOTLINE2 x1, y1, x2, y2, 1 converted from the following sequence of expressions.

 



The drawings that i made, the first  row is the fill element, the second it's for me to see what i draw, the tird is the outline (witch i wanna use as hotlines) and the final row is the internal linesThe drawings that i made, the first row is the fill element, the second it's for me to see what i draw, the tird is the outline (witch i wanna use as hotlines) and the final row is the internal linesthe beggining of the 2D scriptthe beggining of the 2D scriptthe red line is an aproximation of the hotlines that are drawn and converted from the gpt scriptthe red line is an aproximation of the hotlines that are drawn and converted from the gpt script

1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Pertti Paasky
Expert

Hello Otavio

I made this object to do the job. It shows some borderlines.

there must exsist a dictionary type parameter "viivat" in parameters table.

 

The idea is that You Copy all poly2 ~  -commands in the parameters script

write 1st line:

n=0

then replace all  "POLY2_B" (or whatewer You get from AC) with  "n=n+1:put n"

 

write this at the end:

dict viivat
for i= 1 to nsp
n=get(1)
m=get(1)



for k=1 to 12
kysy=get(1)
next k

for p=1 to m
viivat.viiva[n].piste[p].x=get(1)
viivat.viiva[n].piste[p].y=get(1)
viivat.viiva[n].piste[p].z=get(1)
next p

i=i+14+m*3
next i
parameters viivat=viivat
 
2d script: **************************************************************************************
!
! Nimi : Uusi objekti 1.gsm
! Päiväys : tiistai 13. heinäkuuta 2021
! Versio : 24.00
! ARCHICAD -FIN
! pertti,paasky@saunalahti.fi

mul2 A/426.031000, B/258.144000
add2 -374681.378, -6673549.076
drawindex 10
pen penAttribute_1
set line_type lineTypeAttribute_1


if haskey (viivat.viiva) then

for n= 1 to vardim1(viivat.viiva)
for p= 1 to vardim1(viivat.viiva[n].piste)
hotspot2 viivat.viiva[n].piste[p].x,viivat.viiva[n].piste[p].y
next p
next n


for n= 1 to vardim1(viivat.viiva)
for p= 1 to vardim1(viivat.viiva[n].piste)-1
line2 viivat.viiva[n].piste[p].x,viivat.viiva[n].piste[p].y,viivat.viiva[n].piste[p+1].x,viivat.viiva[n].piste[p+1].y
hotline2 viivat.viiva[n].piste[p].x,viivat.viiva[n].piste[p].y,viivat.viiva[n].piste[p+1].x,viivat.viiva[n].piste[p+1].y
next p
next n

endif
del 2
 
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

View solution in original post

3 REPLIES 3
Solution
Pertti Paasky
Expert

Hello Otavio

I made this object to do the job. It shows some borderlines.

there must exsist a dictionary type parameter "viivat" in parameters table.

 

The idea is that You Copy all poly2 ~  -commands in the parameters script

write 1st line:

n=0

then replace all  "POLY2_B" (or whatewer You get from AC) with  "n=n+1:put n"

 

write this at the end:

dict viivat
for i= 1 to nsp
n=get(1)
m=get(1)



for k=1 to 12
kysy=get(1)
next k

for p=1 to m
viivat.viiva[n].piste[p].x=get(1)
viivat.viiva[n].piste[p].y=get(1)
viivat.viiva[n].piste[p].z=get(1)
next p

i=i+14+m*3
next i
parameters viivat=viivat
 
2d script: **************************************************************************************
!
! Nimi : Uusi objekti 1.gsm
! Päiväys : tiistai 13. heinäkuuta 2021
! Versio : 24.00
! ARCHICAD -FIN
! pertti,paasky@saunalahti.fi

mul2 A/426.031000, B/258.144000
add2 -374681.378, -6673549.076
drawindex 10
pen penAttribute_1
set line_type lineTypeAttribute_1


if haskey (viivat.viiva) then

for n= 1 to vardim1(viivat.viiva)
for p= 1 to vardim1(viivat.viiva[n].piste)
hotspot2 viivat.viiva[n].piste[p].x,viivat.viiva[n].piste[p].y
next p
next n


for n= 1 to vardim1(viivat.viiva)
for p= 1 to vardim1(viivat.viiva[n].piste)-1
line2 viivat.viiva[n].piste[p].x,viivat.viiva[n].piste[p].y,viivat.viiva[n].piste[p+1].x,viivat.viiva[n].piste[p+1].y
hotline2 viivat.viiva[n].piste[p].x,viivat.viiva[n].piste[p].y,viivat.viiva[n].piste[p+1].x,viivat.viiva[n].piste[p+1].y
next p
next n

endif
del 2
 
- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

Wow, simply wow! This is amazing Pertti!!!

Thank you very very much, i loved it! Just math and programming, this communit is insane haha

 

But, how can i use the result from it in my object, must i use a call parameter inside mt object or should i input a print command to copy the resulting hotline string, or something else? 

Anyhow, you are amazing!

Thanks again 😉

Hi Otavio.

I see You have several figures in one object.

Every figure has its own polygons wich You have to prepare  by dragging the fill from 2d to 2d script. I would use one dictionary parameter for every figure.

Like this:

dict figures

figures.figure[iFigure].polylines[iPolyline]=...

figures.figure[iHatch].hatches[iHatch]=....

figures.figure[iHotline].hotlines[iHotline]=....

and so on.

 

Every set of poly2 entities must be translated to fit the algorithms by replacing those lines mentioned early.

You can organize this in parameters script.

BR. Pertti

 

- AC-24 FIN - WIN 10 - HP Zbook -
“A winner is just a loser who tried one more time.”
George M. Moore, Jr.

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!