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

Is there a way to suppress warning messages in a GDL script?

Eric Bobrow
Enthusiast
I am creating an object that will show samples of all the materials defined in a project.

To do this, I plan to use a simple loop statement that increments an index value, then tests to see if a material exists for that index using the statement:
n=REQUEST ("Name_of_material", index, name)
I tried this, and can see that variable n is 0 when there is no material with that index, while it is 1 when a material exists.

However, when the index is not associated with a material, a warning dialog comes up stating "Material not found at line 2 in 3D script of..."

Is there a way to suppress this warning message? I know that a user can turn off error messages in general, and then will only get a single message stating "there were errors", but that's not acceptable in this case.

Alternatively, is there a way to automatically fill an array with a list of index values for materials, similar to the special request available for a list of font names?
15 REPLIES 15
Eric Bobrow
Enthusiast
Juha -

I tried your code, and was only partly successful. It does not generate an error message, but the value the script assigns for the pict[1] cell does not seem to be picked up properly.

I set the initial value for pict[1] to be "abc", then in the script assigned it to the value returned in the variable file_name.

When assigning this using the "parameters" option (as you suggested):
parameters pict[1]= file_name
the value is not picked up.

I verified this using the following line:
print "pict value= ", pict[1], ", ", file_name
which results in this message:
pict value= abc, Terracotta roof tile
When I take off the "parameters" option:
pict[1]= file_name
then the script generates an error (like it did earlier):
String type expression required at line 11 in the 2D script of file AMT Material Matrix.gsm.
As a last resort, I tried using both lines (the two variations of the pict[1]= statement, one with "parameters" and the other without), and still couldn't get it to work.

So, I am at a loss. If you have any ideas, please let me know!

Eric
Anonymous
Not applicable
Hello Eric,

I wonder if you have the code in the master script? At least the
first part;

!--master script
n=REQUEST{2} ("Material_info", "Testing Material", "gs_mat_texture", file_name, w, h, mask, alpha) 
parameters pict[1]= file_name 
DEFINE IMAGE_FILL "Testing" pict[1], 255, 255, 255, 255, 255, 255, 255, 255, w, h, 0, 0 

The second part can be in the master or 2D script

!--master or 2D script
set IMAGE_FILL "Testing" 
poly2_ 4, 1+2+4+8, 
   0, 0, 0, 
   a, 0, 0, 
   a, b, 0, 
   0, b, 0 
I tested again and works nicely here.

Best Regards, Juha
Eric Bobrow
Enthusiast
Juha -

Thank you for your suggestions. Based on your idea, I created an object that draws an Image Fill in 2D based on the texture image file for any material chosen parametrically. I then adapted my original matrix part to call the new object repeatedly, once for each material swatch sample.

Unfortunately, although the new object will draw appropriate textures when placed on the floor plan, when it is called from the matrix object, the parameters assignment statement isn't working. I don't know if this is a bug, or if it is a limitation in the way that PARAMETERS statements work in the master script. (I tried placing some or all of the code into the Parameter Script, but couldn't get it to work at all.)

Here is my Master Script, which has a print statement included for testing purposes:
n=REQUEST{2} ("Material_info", materialtype, "gs_mat_texture", file_name, w, h, mask, alpha)
parameters pict[1]= file_name
print "materialtype=",materialtype," file_name=",file_name,", pict[1]=",pict[1]
DEFINE IMAGE_FILL "newimagefill" pict[1], 255, 255, 255, 255, 255, 255, 255, 255, w, h, 0, 0 
When I ran a small loop with my matrix object, which called the simple object once for each material, I got the following report:
materialtype= 73 file_name=Brick Common Flemmish alpha, pict[1]=Brick Running alpha
materialtype= 72 file_name=Brick English alpha, pict[1]=Brick Running alpha
materialtype= 70 file_name=Brick Surface alpha, pict[1]=Brick Running alpha
materialtype= 71 file_name=Stucco alpha, pict[1]=Brick Running alpha
materialtype= 74 file_name=Tiles Wall alpha, pict[1]=Brick Running alpha
You can see that each time the object was called, it received a different materialtype as a parameter from the matrix object. The file_name variable successfully picks up the proper texture file name, however the pict[1] string array variable is somehow not being set even though I am using the parameters statement as you did in the Master Script.

If you send me a private message with your email address, I'll send you a copy of the two GDL parts for you to see for yourself!
ztaskai
Graphisoft Alumni
Graphisoft Alumni
Hi Eric,

This bug was there in AC13 but not in AC12. I guess no one uses this in production. We tested it thoroughly when the command came to be, but now I see that we don't have a daily test for this one. So you're the first one to report it.

Thanks for bringing this to our attention and sorry again for the annoyance!

Regs,
Zsolt Táskai
ArchiCAD Development - GDL Team
AC13, AC14 and upwards...
Anonymous
Not applicable
Hello Eric,

Thanks for the email and the posted objects. Here is a general
piece of code where the textures react correctly. I stored the fill
and texture names in the "pict" parameter table and picked them
for 2D plan from there. Seems to work.

I post it here just in case someone finds it useful, therefore I added
some comments too.



As before a string type parameter "pict" is needed, it is made
a table with two columns -> pict[1][1]


This is a master script:


!--stretching the table
for xx=1 to 255
	parameters pict[xx][1]="", pict[xx][2]=""
next xx

!--looping thru materials
for xx=1 to 255
	test= REQUEST{2}("Material_info", xx, "gs_mat_surface_rgb", r, g, b)

	if test then!<--we have a material with index xx

		dummy= REQUEST("Name_of_material", xx, name) 
		file_name= ""
		n=REQUEST{2} ("Material_info", name, "gs_mat_texture", file_name, w, h, mask, alpha)
		nr= nr+1

		if file_name#"" then!<--we have a material with a texture --- store the fill name and the texture name, define image fill

			fill_name= name
			parameters pict[nr][1]= fill_name, pict[nr][2]= file_name
			DEFINE IMAGE_FILL pict[nr][1] pict[nr][2], 255, 255, 255, 255, 255, 255, 255, 255, w, h, 0, 0

		else!<--we have a material but no texture --- store just the fill name

			parameters pict[nr][1]= name, pict[nr][2]= ""

		endif
	endif
next xx



!--just limiting a stretching hotspot values
values "A" range[1,nr] step 1, 1


This is a 2D script:


hotspot2 0, 0
hotspot2 a, 0

!--looping thru stored materials
for xx= 1 to vardim1(pict)

	if pict[xx][2]#"" then!<--we have an image fill

		set IMAGE_FILL pict[xx][1]!<--get the mage fill name
		poly2_ 4, 1+2+4+8,
			0,   0, 1,
			1,   0, 1,
			1,	-1, 1,
			0,	-1, 1

  		!--texture matrix transformation  
		if dx<a-1 then
			add2 1, 0
			dx= dx+1
		else
			add2 -a+1, -1
			dx= 0
		endif
		nt=nt+1

	endif

next xx
del nt


Best Regards, Juha
Eric Bobrow
Enthusiast
Thank you!
I haven't had a chance to test it out, but it looks great.
Eric