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

GDL
About building parametric objects with GDL.
SOLVED!

need to clean lines of tube and merge tube+revolve

A_ Smith
Expert
Hi, everyone.
I'm trying to make an object with a clean 3D look.
I can't figure out what status code and mask I should use to make the object like on the image. I need two versions:
a) obj with all lines, except rounded edges (image 1). Images 2, 3 are just an attempt to make it work.
b) without any lines in 3D (image 4, though 2D should stay with lines).

c) Another problem - when I place close to each other (same position) tube and revolve some line appears (image5). It's behaving strangely - I mean it's everywhere, unlike when one part (revolve) is higher than the other (tube). The grouping has no effect. That's why I decided to make half of the cross-section for the tube command and "double path" (image6). That strange line disappears, but the surface itself looks not good.
x1 = 0.500*0.01:	y1 = 0.500*0.01		!*0.01 - just to make it smaller
x2 = 0.750*0.01:	y2 =-0.250*0.01		! for closer look in 3D
					y3 =-0.375*0.01		! on line between tube and revolve
					y4 =-0.500*0.01
R=0.125*0.01

path_x1 =-1*0.01 : 	path_y1 = 0 :	path_z1 = 0
path_x2 = 0 :		path_y2 = 0 :	path_z2 = 0
path_x3 = 1*0.01 :	path_y3 = 0 :	path_z3 = 0
path_x4 = 2*0.01 :	path_y4 = 0 :	path_z4 = 0.5*0.01
path_x5 = 3*0.01 :	path_y5 = 0 :	path_z5 = 0.5*0.01
path_x6 = 4*0.01 :	path_y6 = 0 :	path_z6 = 0.5*0.01

res=24
resol res
stepi=360/res
matWhite = 60
penRed = 20
showText = 1

pen penRed
material matWhite

gosub "tube shape"
	add path_x5, path_y5, path_z5
	rotz 180
	roty -90
gosub "revolve shape"
	del 3

	addx path_x5*2
gosub "half tube double path"
	del 1

if showText then
	gosub "defStyle"
	add 0, -x2*2, y4
	text 0,0, "tube + revolve" 
	addx path_x5*2
	text 0,0, "half tube, double path"
	del 2
endif

end	!___________________________________________END_________________________________________

"tube shape":
	!status for cross-section of tube command
	si=1	!0 is good WHEN angle=0, else IF lines on the rounded edges are present...
			!1 remove lines on the edges, but some other lines are missing
			!2 too much lines

	!cross-section
	put x1, 			y1, 			si			
	put x1, 			y2, 			si			
	put x2, 			y2, 			si

	for i=90 to -90 step -stepi					! to make it the same as for revolve, where si isn't available
	put	x2 + R*cos(i), y3 + R*sin(i), 	si		! that's why i didn't use centerpoint (900) plus arc (4000)
	next i
	put x2, 			y4, 			si			
	put -x2, 			y4, 			si			
	for i=270 to 90 step -stepi					! to make it the same as for revolve, where si isn't available
	put -x2 + R*cos(i), y3 + R*sin(i), 	si
	next i
	put -x2, 			y2, 			si			
	put -x1, 			y2, 			si			
	put -x1, 			y1, 			si			
	put x1, 			y1, 			-1			

	!path of cross-section
	put path_x1, path_y1, path_z1, 0
	put path_x2, path_y2, path_z2, 0	!changed 45 degrees to 0 - to look the same as "half tube double path"
	put path_x3, path_y3, path_z3, 0	!same
	put path_x4, path_y4, path_z4, 0
	put path_x5, path_y5, path_z5, 0
	put path_x6, path_y6, path_z6, 0

	mask = 1 + 2*1 + 16*0 + 32*0 + 64*0 + 128*0	!first
	m=6		! number of the path nodes
	n=(nsp-m*4)/3
	tube n, m, mask, get (n*3), get(nsp)
	!prism_ n, 0.01, get(n*3)
return



"revolve shape":
	si=1
	put y1, 0, si
	put y1, x1, si
	put y2, x1, si
	put y2, x2, si
	for i=90 to -90 step -stepi
	put y3 + R*sin(i), x2 + R*cos(i), si
	next i
	put y4, x2, si
	put y4, 0, si
	
	j1=0:	j2=0:	j3=1:	j4=1:	j5=0
	j6=0:	j7=0:	j8=0:	j9=0
	revolve nsp/3, 180, j1 + j2*2 + j3*4 + j4*8 + j5*16 + j6*32 + j7*64 + j8*128 + j9*256, get(nsp)
!	prism_ nsp/3, 0.0001, get(nsp)
return




"half tube double path":
group "smoothness"
!status for cross-section of tube command
si=1

	!cross-section
	n=0
	put 0, 				y1, 			si: n=n+1			
	put 0, 				y2, 			si: n=n+1			
	put x2-x1, 			y2, 			si: n=n+1

	for i=90 to -90 step -stepi					
	put	x2-x1 + R*cos(i), y3 + R*sin(i), 	si: n=n+1
	next i
	put x2-x1, 			y4, 			si	: n=n+1		
	put -x1, 			y4, 			si	: n=n+1		
	put -x1, 			y1, 			si	: n=n+1		
	put 0,	 			y1, 			-1	: n=n+1		

	!path of cross-section
	put path_x1, path_y1, path_z1, 0
	put path_x2, path_y2, path_z2, 0	!removed angle=45 or its becoming too complicated
	put path_x3, path_y3, path_z3, 0	!to find same coordinates backwards (at least for me)
	put path_x4, path_y4, path_z4, 0
	put path_x5, path_y5, path_z5, 0
	for i=90 to -90.1 step -1
	put path_x5 + x1*cos(i), path_y5-x1 + x1*sin(i), path_z5, 0	!x1 - radius
	next i
	put path_x5, path_y5 - x1*2, path_z5, 0	
	put path_x4, path_y4 - x1*2, path_z4, 0	
	put path_x3, path_y3 - x1*2, path_z3, 0
	put path_x2, path_y2 - x1*2, path_z2, 0
	put path_x1, path_y1 - x1*2, path_z1, 0


	mask = 1 + 2*1 + 16*0 + 32*0 + 64*0 + 128*0	!first
	m=(nsp-n*3)/4		! number of the path nodes

	tube n, m, mask, get (n*3), get(nsp)
	!prism_ n, 0.01, get(n*3)
endgroup
!abc=addgroup ("smoothness","smoothness")
!placegroup abc	!very strange starting surface... and still 3D looks not clean
placegroup "smoothness"
return

"defStyle":
	define style "style1" "arial", 1, 8, 0
	set style "style1"
return
AC 22, 24 | Win 10
1 ACCEPTED SOLUTION

Accepted Solutions
Solution
Peter Baksa
Graphisoft
Graphisoft
Hi,

about longitudinal edges (image 1): si is not visibility, more like a sharp / curved edge status. 0 makes sharp edges, 1 renders like a smooth surface. The status for curved faces have to be given at the starting point of the face:
si = 1
put x1, 			y1, 			0
put x1, 			y2, 			0
put x2, 			y2, 			si

put x2,				y3,			900
put 0,				-180,			4000 + si

put -x2, 			y4, 			si
put -x2,			y3,			900
put 0,				-180,			4000 + si

put -x1, 			y2, 			0
put -x1, 			y1, 			0
put x1, 			y1, 			-1



put		-1*0.01,	0, 0,		30,
		0,		0, 0,		30,
		1*0.01,		0, 0,		30,
		2*0.01,		0, 0.5*0.01,	0,
		3*0.01,		0, 0.5*0.01,	0,
		4*0.01,		0, 0.5*0.01,	0

tube 11, 6, 1+2+16+32+64,
	get(11 * 3),
	get(6 * 4)
About cross-section edges (image 2, image 4): the missing line will be visible with mask bit 64, as on image3. When bit 64 isn't set it doesn't mean they will be all invisible. When the angle between neighboring triangles is greater than a treshold, a line will appear. It can't be controlled from GDL. A trick to hide all of them is modelling a short TUBE for each path segment:
tube 11, 4, 1+2,
	use(11 * 3),
	-1*0.01,	0, 0,		30,
	0,		0, 0,		30,
	1*0.01,		0, 0,		30,
	2*0.01,		0, 0.5*0.01,	0

tube 11, 4, 1+2,
	use(11 * 3),
	0,		0, 0,		30,
	1*0.01,		0, 0,		30,
	2*0.01,		0, 0.5*0.01,	0,
	3*0.01,		0, 0.5*0.01,	0

tube 11, 4, 1+2,
	use(11 * 3),
	1*0.01,		0, 0,		30,
	2*0.01,		0, 0.5*0.01,	0,
	3*0.01,		0, 0.5*0.01,	0,
	4*0.01,		0, 0.5*0.01,	0
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest

View solution in original post

3 REPLIES 3
Solution
Peter Baksa
Graphisoft
Graphisoft
Hi,

about longitudinal edges (image 1): si is not visibility, more like a sharp / curved edge status. 0 makes sharp edges, 1 renders like a smooth surface. The status for curved faces have to be given at the starting point of the face:
si = 1
put x1, 			y1, 			0
put x1, 			y2, 			0
put x2, 			y2, 			si

put x2,				y3,			900
put 0,				-180,			4000 + si

put -x2, 			y4, 			si
put -x2,			y3,			900
put 0,				-180,			4000 + si

put -x1, 			y2, 			0
put -x1, 			y1, 			0
put x1, 			y1, 			-1



put		-1*0.01,	0, 0,		30,
		0,		0, 0,		30,
		1*0.01,		0, 0,		30,
		2*0.01,		0, 0.5*0.01,	0,
		3*0.01,		0, 0.5*0.01,	0,
		4*0.01,		0, 0.5*0.01,	0

tube 11, 6, 1+2+16+32+64,
	get(11 * 3),
	get(6 * 4)
About cross-section edges (image 2, image 4): the missing line will be visible with mask bit 64, as on image3. When bit 64 isn't set it doesn't mean they will be all invisible. When the angle between neighboring triangles is greater than a treshold, a line will appear. It can't be controlled from GDL. A trick to hide all of them is modelling a short TUBE for each path segment:
tube 11, 4, 1+2,
	use(11 * 3),
	-1*0.01,	0, 0,		30,
	0,		0, 0,		30,
	1*0.01,		0, 0,		30,
	2*0.01,		0, 0.5*0.01,	0

tube 11, 4, 1+2,
	use(11 * 3),
	0,		0, 0,		30,
	1*0.01,		0, 0,		30,
	2*0.01,		0, 0.5*0.01,	0,
	3*0.01,		0, 0.5*0.01,	0

tube 11, 4, 1+2,
	use(11 * 3),
	1*0.01,		0, 0,		30,
	2*0.01,		0, 0.5*0.01,	0,
	3*0.01,		0, 0.5*0.01,	0,
	4*0.01,		0, 0.5*0.01,	0
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
Peter Baksa
Graphisoft
Graphisoft
About image5: that is an OpenGL artifact, it won't appear on renderings or internal engine drawings (section/elevation/3d document).

You wrote a comment in your code about si isn't available for revolve, but it is:
put y1,	x1, 	0
put y2,	x1, 	0
put y2,	x2, 	si
put y3,	x2,	900
put 0,	180,	4000 + si

roty -90
revolve 5, 180, 
	1 + 2 + 4 + 8,
	get(5*3)
del 1
Péter Baksa
Software Engineer, Library as a Platform
Graphisoft SE, Budapest
A_ Smith
Expert
Thanks you so much, Peter Baksa. It's working as I wanted.
Though I need more time to practice with them to understand it clearly.
AC 22, 24 | Win 10