Importing faces rather than triangles


#1

Hello, I’m new to SketchUp SDK and modelling in general. I’m working on an existing piece of code which converts .xml to .skp. The program exports by triangles and I’m wondering if there is a way to export it by faces / meshes instead? Thanks!


#2

What program ?

In the first sentence, you are speaking of import (into SketchUp ?)

In the second sentence, you are speaking of export, but from what ?


#3

Any chance the XML is actually Collada? Can you post a link to an example file?

If it is Collada you should be able to import that straight into SketchUp.


#4

By program I mean the code which converts .xml to .skp - it was written by a previous intern who has left and I’m the new intern working on the code.
And sorry, I meant import by triangles. Import into SketchUp.


#5

You could start here:
http://www.sketchup.com/intl/en/developer/su-api/geometry__input_8h_source.html

Have you studied the two sample projects that come with the SDK ?

EDIT (add): The one that should interest you should be in:
"SDK/samples/C++/xml_to_skp"


#6

Here’s an example. The right block is the original model. The left block is what I get after 2 conversions, i.e. .spk to .xml then back to .spk, just for proof of concept. As you can see, the left block is triangulated. Is there a way to make the end product not triangulated when converting .xml to .skp?


#7

Well look at this simple example. It creates a face using 4 vertices not 3.

http://www.sketchup.com/intl/en/developer/su-api/

And make sure the code is not using this:
http://www.sketchup.com/intl/en/developer/su-api/struct_s_u_mesh_helper_ref.html

Other than that, you need to search for a “Merge Coplanar Faces” feature, example, plugin, etc.


#8

Hi @lin_b ,

My memory is a bit fuzzy but I think we export tessellated faces in the xml exporter. So when you import it back, you get triangulated faces back. These were just SDK examples, that we honestly put together very fast. Complete round-trip model fidelity was not a big priority. And code quality isn’t exactly great either :grinning:

If you modified the code to export the original face vertices, you’d get the original faces back after the import.

I hope that helps.