# \[?\] Export a 3D model from Mathematica?

**URL:** <https://community.wolfram.com/t/export-a-3d-model-from-mathematica/12541>\
**Category:** Questions\
**Tags:** image-processing, mathematica, graphics-and-visualization, import-and-export\
**Created:** [May 30, 2018, 5:07pm UTC](https://community.wolfram.com/t/export-a-3d-model-from-mathematica/12541 "2018-05-30T17:07:47Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![ebartell](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@ebartell](https://community.wolfram.com/u/ebartell)\
**Post date:** [May 30, 2018, 5:07pm UTC](https://community.wolfram.com/t/export-a-3d-model-from-mathematica/12541/1 "2018-05-30T17:07:47Z")

</div>

I’m trying to export a scatterplot that has been translated into a series of cuboids. x in this example is a very long array of ones and zeroes.

```
vals = ArrayReshape[x, {12, 512, 26}, 0];
pts = Position[vals, 1];
y = Graphics3D[Translate[{Red, Cuboid[]}, pts]]

```

This code ran with my array produces the image down at the bottom. I’d like to export that into a format such as .3ds or .obj so I can use it across multiple 3D modeling platforms, but whenever I run the following code:

```
 Export["test.3ds", y]

```

I get this error: “Export::nodta: Graphics3D contains no data that can be exported to the 3DS format.”\

In a bit of a rut trying to figure out what I’m doing wrong here. I’ve been looking for the past few days, and couldn’t find anything that helped me. I’m pretty new to Mathematica, so I’m sure there’s just something I’m missing. Any help would be appreciated, thanks!

 ![test.png](https://global.discourse-cdn.com/wolfram/original/3X/2/7/27b532929cc5f3b8d70274f460b98dbd8bf51e05.png)

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [June 1, 2018, 1:24pm UTC](https://community.wolfram.com/t/export-a-3d-model-from-mathematica/12541/2 "2018-06-01T13:24:33Z")

</div>

Hi

A simpler case:

```
pts = {{1, 1, 1}, {3, 3, 3}};
test = Graphics3D[Translate[Cuboid[], pts]]
Export["test.3ds", test]

(* Fail !!! *)

```

Probably Mathematica at first discretize graphics primitives and then export to file,but It can’t discretize because is not implemented yet.

I found in Help Documentation **possible issues** examples:

```
BoundaryDiscretizeGraphics[Graphics3D[{Cone[], Cuboid[]}]]
(*Fail *)
DiscretizeGraphics[Graphics3D[{Cone[], Cuboid[]}]]
(* Fail *)

```

and in our example:

```
DiscretizeGraphics[test]
(* Fail -> EmptyRegion[3]*)

```

It is possible that in the next version of **Mathematica 12.0** , these incompatibilities will be corrected. I hope.  
Is there any way workaround? I don’t know.

Regards,MI.

---

<div class="post-metadata">

**Author:** ![ebartell](https://avatars.discourse-cdn.com/v4/letter/e/d07c76/32.png) [@ebartell](https://community.wolfram.com/u/ebartell)\
**Post date:** [June 1, 2018, 4:42pm UTC](https://community.wolfram.com/t/export-a-3d-model-from-mathematica/12541/3 "2018-06-01T16:42:23Z")

</div>

Thanks for the post, Mariusz. That makes a lot more sense now.

Is there any format for exporting in Mathematica that is supported, or would it be for the best for me to seek an alternative CAD software?

---

<div class="post-metadata">

**Author:** ![henrikschachner](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/henrikschachner/32/32119_2.png) [@henrikschachner](https://community.wolfram.com/u/henrikschachner)\
**Post date:** [June 1, 2018, 7:09pm UTC](https://community.wolfram.com/t/export-a-3d-model-from-mathematica/12541/4 "2018-06-01T19:09:45Z")

</div>

From the [documentation on 3ds](http://reference.wolfram.com/language/ref/format/3DS.html), it simply states that

> Export to the 3DS format supports the following graphics primitives: GraphicsComplex, Cuboid, Cylinder, and Sphere.

so it basically should work. The problem seems to be the `Translate` command, because

```
Export["test.3ds", Graphics3D[Translate[Cuboid[{0,0,0}], {{0,0,0}}]]]

```

does not work, but this is equivalent to

```
Export["test.3ds", Graphics3D[Cuboid[]]]

```

which does work. Consequently you could do it like so:

```
pts = RandomReal[{-10, 10}, {100, 3}];
y = Graphics3D[{Red, Cuboid /@ pts}];
Export["test.3ds", y]

```

But in any case Mathematica knows a lot of respective [3D Geometry & Modeling Formats](http://reference.wolfram.com/language/guide/3DGeometryAndModelingFormats.html).

Regards – Henrik

---

<div class="post-metadata">

**Author:** ![mariuszi28cg](https://yyz1.discourse-cdn.com/wolfram/user_avatar/community.wolfram.com/mariuszi28cg/32/308_2.png) [@mariuszi28cg](https://community.wolfram.com/u/mariuszi28cg)\
**Post date:** [June 1, 2018, 7:29pm UTC](https://community.wolfram.com/t/export-a-3d-model-from-mathematica/12541/5 "2018-06-01T19:29:12Z")

</div>

Hi

With [help this site](https://mathematica.stackexchange.com/questions/101302/why-do-i-sometimes-get-errors-when-exporting-3d-graphics-which-have-been-transla/101306?noredirect=1#comment457943_101306) I found workaround:

```
  x = {RandomInteger[1, 20], RandomInteger[1, 20], RandomInteger[1, 20]};
  vals = ArrayReshape[x, {12, 512, 26}, 0];
  pts = Position[vals, 1];
  test = Graphics3D[Translate[PolyhedronData["Cube", "GraphicsComplex"], pts], Boxed -> False, SphericalRegion -> True]

  ClearAll[normify, xfcoords, ixfcoords];
  normify[Translate[g_, v : {__?NumericQ}]] := 
    normify[Translate[g, {v}]];
  normify[Translate[g_, v_?MatrixQ]] := 
    xfcoords[g, TranslationTransform[#]] & /@ v;
  normify[g_] := g;
  
  SetAttributes[xfcoords, Listable];
  xfcoords[g_, xf_] := ixfcoords[g, xf];
  ixfcoords[(obj : GraphicsComplex | Polygon | Line | Point)[coords_, rest___], xf_] := obj[xf[coords], rest];
  ixfcoords[g_, xf_] := g;
 
  normaltest = normify //@ test

  Export["test1.3ds", normaltest]

```

It’s only work with Graphics primitives such as:

```
   PolyhedronData[All]

```

Regards, MI
