I made a Sketchup to CityJSON converter but it has some issues (C# console app)

Hello all,

I made a Skettchup to CityJSON converter, but it has some issues. The problem occurs mainly when surfaces are nested in groups with 3 or more levels deep. Then certain surfaces are offset in wrong direction / rotation, it really depends on the model.

It this a bug of the SDK?

Here is my code;

It’s a C# console app and you need Visual Studio 2022 and .NET 6 to get it to work.

If you think what could be the issue let me know!


I cannot see the code for the Transform.Add method you are using, but in SketchUp’s APIs, when walking the model hierarchy the transformation matrices need to be multiplied together as you dig down.


It also helps to know if the matrix is column major or row major order so that you know if code is manipulating it correctly.

The SUTransformation struct page in the C API documentation explains:

Detailed Description

Represents a 3D (4x4) geometric transformation matrix.

Matrix values are in column-major order. The transformation is stored as:

    -     -
    | R T |
M = | 0 w |
    -     -


  • M is a 4x4 matrix
  • R is a 3x3 sub-matrix. It is the rotation part
  • T is a 3x1 sub-matrix. It is the translation part
  • w is a scalar. It is 1/scale.

By the way … there is little if any commentary in your code !

Hi Dan,

I was actually lookking for that multiply function but could not find it in the C# wrapper that I’m using. I’m using GitHub - moethu/SketchUpNET: SketchUp C# API - A C++/CLI API Wrapper for the Trimble(R) SketchUp(R) C API

When making the code I used some simple selfmade Sketchup models like cubes. And that worked until I used other files.

I found out that when I use transform.GetTransformed(vertex) it helped. But not with other nested groups. So I was now experimenting doing GetTransformed traversing the group.

To do that I maintain a List of Transforms (line 198 of SketchupUtiliy.cs)
Then at line 210 I do GetTransformed using the list of Transforms. From top to down. The returned vertice is then transformed again. This worked better for some models but most fail.

What version were the files ? It looks as though the C# lib you’re using has not yet updated to use the SketchUp v22 SDK.

Yes it does not appear that the author wrapped much of the C API’s transformation functions.
I suppose you could do the wrapping yourself, or use core C# functions to do the matrix multiplication.

Got some sample models and screenshots?

Can you point out the relevant code? It’s not easy to dive into a full project like that.