Developer forum
Showing results for 
Search instead for 
Did you mean: 

Undefined material type in model ?

I am testing a couple of things using the sample projet found here:

I use the modeler API to enumerate the materials from the model. I call Material::GetType() to obtain the material type, which are supposed to be a value from this enum:
	enum Type {
		General		= 0,
		Simple		= 1,
		Matte		= 2,
		Metal		= 3,
		Plastic		= 4,
		Glass		= 5,
		Glowing		= 6,
		Constant	= 7
Oddly, I also encountere some material types of value 20, which are not part of the enum.

Is the enum in the header out of date?

What is the material type of value 20?

Replying to my own question here. After a lot of digging.

It turns out the enum found in ModelerAPI::Material is incorrect. There are more material types than the ones listed in the enum (values 0..7).

The actual value types for materials are GDL types, as described here:

To wit, a material in a GDL script is defined as such:

surface_red, surface_green, surface_blue
[, ambient_ce, diffuse_ce, specular_ce, transparent_ce,
shining, transparency_attenuation
[, specular_red, specular_green, specular_blue,
emission_red, emission_green, emission_blue, emission_att]]
[, fill_index [, fillcolor_index, texture_index]]

and where "n" is the number of parameters in the DEFINE MATERIAL command:

name: name of the surface.
type: type of the surface. The actual number (n) of parameters that define the surface is different, depending on the type.
The meaning of the parameters and their limits are explained in the examples’ comments.
0: general definition, n=16,
1: simple definition, n=9 (extra parameters are constants or calculated from given values),
2-7: predefined surface types, n=3.
The three values are the RGB components of the surface color. Other parameters are constants or calculated from the color.
2: matte,
3: metal,
4: plastic
5: glass,
6: glowing,
7: constant,
10: general definition with fill parameter, n=17,
11: simple definition with fill parameter, n=10,
12-17: predefined surface types with fill parameter, n=4,
20: general definition with fill, color index of fill and index of texture parameters, n=19,
21: simple definition with fill, color index of fill and index of texture parameters, n=12,
22-27: predefined surface types with fill, color index of fill and index of texture parameters, n=6.
20-27: Special meanings for types 20-27: If the pen number is zero, vectorial hatches will be generated with the active pen.

Zero value for a texture or fill index allows you to define surfaces without a vectorial hatch or texture.

Viktor Kovacs
Graphisoft Alumni
Graphisoft Alumni
You are right, the GetType function can return any values from the GDL command. The type parameter greater than 7 defines not only the type of the material, but the behavior of the GDL command as well. For example type 20 means that the command need to specify only fill, color index of fill and index of texture parameters. The documentation also says that it creates a general material, so I think in this case you should use general.

Just out of curiosity: what are you planning to use material type for? A use case would help us to make this interface more clear if needed.

Well, I am writing an archicad exporter to a realtime visualisation environment, and I need to map the behavior of the materials to what amounts to some kind of simplified PBR shader.

Ultimately I would like to reuse the C4D material properties for this, but for now I am trying to mimic the basic renderer. See below for what it looks like now.

Still looking?

Browse more topics

Back to forum

See latest solutions

Accepted solutions

Start a new discussion!