Archicad C++ API
About Archicad add-on development using the C++ API.

How to get the mesh information from Archicad

Anonymous
Not applicable
Hi,

I am a beginner for developing archicad 3D converter. My wonder is how to get the mesh information from Archicad. Besides, how about the transformation matrix? And how can I triangulate the polygons gotten from the body stucture?

I have a glimpse at the api document, but found little about what I metioned above. ; (

Could you please give me some hints?
13 REPLIES 13
Ralph Wessel
Mentor
There are two possible ways to approach this.
  • 1. ModelerAPI - This is by far the easiest way to access information about the 3D model, but there doesn't seem to be documentation for it anywhere. However, you can deduce the meaning of most of it fairly easily. Look in the devkit at Support/Modules/GSModelDevLib

    2. ACAPI_Element_Get3DInfo - This has documentation with the other API docs, but is a bare C interface. It's very comprehensive though
Ralph Wessel BArch
Anonymous
Not applicable
Ralph wrote:
There are two possible ways to approach this.
  • 1. ModelerAPI - This is by far the easiest way to access information about the 3D model, but there doesn't seem to be documentation for it anywhere. However, you can deduce the meaning of most of it fairly easily. Look in the devkit at Support/Modules/GSModelDevLib

    2. ACAPI_Element_Get3DInfo - This has documentation with the other API docs, but is a bare C interface. It's very comprehensive though
Thank you. I have read about these APIs. But what I want is to fetch the mesh information, that is to say, the coordinates of the vertex on the mesh, the index of vertex in the triangles and the transformation matrix. I have found the ACAPI_3D_GetComponent may solve these problems. But I get quite confused here.

Could you please help me solve these problems if it is convenient?

1. transformation matrix. I get the transformation matrix in component3D.body.tranmat. However, It is a little bit different from what I used to think. It seems that every body has its own vertex data and the tansformation matrix. But in a render machine, there should be some instances of one mesh, each instance with its own transformation matrix. So I was wondering whether there is something like 'instance' or how to get the origin mesh.

2. triangles. I can get the polygon indice using API_GetComponent3D. However, what I want is triangle not polygon. But I thought there might not be an API to convert the polygons indice gotten from the API_GetComponent3D into triangle.


Thanks a lot.
Ralph Wessel
Mentor
scandi wrote:
what I want is to fetch the mesh information, that is to say, the coordinates of the vertex on the mesh, the index of vertex in the triangles and the transformation matrix
1. transformation matrix. I get the transformation matrix in component3D.body.tranmat. However, It is a little bit different from what I used to think. It seems that every body has its own vertex data and the tansformation matrix. But in a render machine, there should be some instances of one mesh, each instance with its own transformation matrix. So I was wondering whether there is something like 'instance' or how to get the origin mesh.
2. triangles. I can get the polygon indice using API_GetComponent3D. However, what I want is triangle not polygon. But I thought there might not be an API to convert the polygons indice gotten from the API_GetComponent3D into triangle.
Archicad's 3D engine doesn't present data in a conventional way. There are broad similarities with lists of bodies, faces, edges and vertices. But faces can be complex polygons with concavity and even overlaid 'hole' faces. It doesn't present a triangle-based mesh through the API. The closest you can get is to use ACAPI_3D_DecomposePgon to break faces into simpler convex polygons, but these are not triangles either.

Extracting the date you require from the 3D components is a bit long-winded. Each body has a transformation matrix and lists indices of faces, edges and vertices – all of which may be shared with other bodies. So in effect different bodies may share data in common but have a different transformation matrix. I recommend using ModelerAPI because it save you from having to code all that detail.
Ralph Wessel BArch
Anonymous
Not applicable
Ralph wrote:
scandi wrote:
what I want is to fetch the mesh information, that is to say, the coordinates of the vertex on the mesh, the index of vertex in the triangles and the transformation matrix
1. transformation matrix. I get the transformation matrix in component3D.body.tranmat. However, It is a little bit different from what I used to think. It seems that every body has its own vertex data and the tansformation matrix. But in a render machine, there should be some instances of one mesh, each instance with its own transformation matrix. So I was wondering whether there is something like 'instance' or how to get the origin mesh.
2. triangles. I can get the polygon indice using API_GetComponent3D. However, what I want is triangle not polygon. But I thought there might not be an API to convert the polygons indice gotten from the API_GetComponent3D into triangle.
Archicad's 3D engine doesn't present data in a conventional way. There are broad similarities with lists of bodies, faces, edges and vertices. But faces can be complex polygons with concavity and even overlaid 'hole' faces. It doesn't present a triangle-based mesh through the API. The closest you can get is to use ACAPI_3D_DecomposePgon to break faces into simpler convex polygons, but these are not triangles either.

Extracting the date you require from the 3D components is a bit long-winded. Each body has a transformation matrix and lists indices of faces, edges and vertices – all of which may be shared with other bodies. So in effect different bodies may share data in common but have a different transformation matrix. I recommend using ModelerAPI because it save you from having to code all that detail.
Thank you.

What I want to get are the data shared by these bodies (i.e. the vertex coordinate, the normals, the vertex indice making up the faces and etc.) and each's transformation matrix. Is there any api about their information?
Ralph Wessel
Mentor
scandi wrote:
What I want to get are the data shared by these bodies (i.e. the vertex coordinate, the normals, the vertex indice making up the faces and etc.) and each's transformation matrix. Is there any api about their information?
Yes, vertices, edges etc are definitely shared between bodies – but I'm not aware of any documentation explaining the algorithm behind it. If an item, e.g. a vertex, is shared between bodies, you will see the same vertex index in both bodies.
Ralph Wessel BArch
Anonymous
Not applicable
Ralph wrote:
scandi wrote:
What I want to get are the data shared by these bodies (i.e. the vertex coordinate, the normals, the vertex indice making up the faces and etc.) and each's transformation matrix. Is there any api about their information?
Yes, vertices, edges etc are definitely shared between bodies – but I'm not aware of any documentation explaining the algorithm behind it. If an item, e.g. a vertex, is shared between bodies, you will see the same vertex index in both bodies.
I think we have some different opinions about "shared". I refer "shared" to the mesh data which is shared by different instances. The instances get their own coordinates by transforming from mesh data. So I was wondering if I could get the mesh data from the APIs. If so, could you please give me some hints?
Ralph Wessel
Mentor
scandi wrote:
I think we have some different opinions about "shared". I refer "shared" to the mesh data which is shared by different instances. The instances get their own coordinates by transforming from mesh data. So I was wondering if I could get the mesh data from the APIs. If so, could you please give me some hints?
As I said earlier, I'm not aware of any documentation that will give you a definitive answer to that question. I am also not a Graphisoft employee, so I don't have deep access into the source code. All I can tell you is things I have observed from the data that may point to the true situation.

I am fairly confident that different instances of the same object with the same parameters reference the same bodies, faces, edges etc. and simply apply a different transformation matrix. Beyond that, I don't know – all you can do is experiment as we have done. Most of what we know about this part of the API has been based on protracted experimentation. There are all kinds of oddities under the bonnet - incomplete or void faces, degenerated polygons, 'magic' uses for the sign of an index etc etc.

What you will definitely not get from the API is a neatly triangulated mesh. I've written export utilities for 3rd-party rendering software in the past, and you'll most likely need to write code to convert the API data to the engine's requirements.
Ralph Wessel BArch
Anonymous
Not applicable
Ralph wrote:
scandi wrote:
I think we have some different opinions about "shared". I refer "shared" to the mesh data which is shared by different instances. The instances get their own coordinates by transforming from mesh data. So I was wondering if I could get the mesh data from the APIs. If so, could you please give me some hints?
As I said earlier, I'm not aware of any documentation that will give you a definitive answer to that question. I am also not a Graphisoft employee, so I don't have deep access into the source code. All I can tell you is things I have observed from the data that may point to the true situation.

I am fairly confident that different instances of the same object with the same parameters reference the same bodies, faces, edges etc. and simply apply a different transformation matrix. Beyond that, I don't know – all you can do is experiment as we have done. Most of what we know about this part of the API has been based on protracted experimentation. There are all kinds of oddities under the bonnet - incomplete or void faces, degenerated polygons, 'magic' uses for the sign of an index etc etc.

What you will definitely not get from the API is a neatly triangulated mesh. I've written export utilities for 3rd-party rendering software in the past, and you'll most likely need to write code to convert the API data to the engine's requirements.
OK. Thanks a lot!
Anonymous
Not applicable
Ralph wrote:
scandi wrote:
I think we have some different opinions about "shared". I refer "shared" to the mesh data which is shared by different instances. The instances get their own coordinates by transforming from mesh data. So I was wondering if I could get the mesh data from the APIs. If so, could you please give me some hints?
As I said earlier, I'm not aware of any documentation that will give you a definitive answer to that question. I am also not a Graphisoft employee, so I don't have deep access into the source code. All I can tell you is things I have observed from the data that may point to the true situation.

I am fairly confident that different instances of the same object with the same parameters reference the same bodies, faces, edges etc. and simply apply a different transformation matrix. Beyond that, I don't know – all you can do is experiment as we have done. Most of what we know about this part of the API has been based on protracted experimentation. There are all kinds of oddities under the bonnet - incomplete or void faces, degenerated polygons, 'magic' uses for the sign of an index etc etc.

What you will definitely not get from the API is a neatly triangulated mesh. I've written export utilities for 3rd-party rendering software in the past, and you'll most likely need to write code to convert the API data to the engine's requirements.
Thanks for your info. I have the same question here, wanting to get triangles from polygons with Archicad API. Just curious is there any ways to do the conversion easily? For example, anyone tried using Libtess2 for it?