Export method creates corrupted file?

when I run

Sketchup.active_model.export("exported_cad.dwg")

the resulting file appears to be corrupted and fails future import with the following error description…

Some imported geometry is extremely far from the
model origin. If you experience any instability with
your SketchUp model, please delete that geometry
from your .dwg/.dxf file and import again.

I have checked the source file and it has no Geo-location set. I cleared it.

I have tried export with or without option flags, with various option tag settings, and with or without relative paths,

I have been able to successfully export from the Ruby Console with the same code. The problem only occurs when run from a script.

Can you post the skp model created by the script ?

Its actually an Autocad file but here it is…
DEMO1.dwg (26.9 KB)

Your 1st post indicated it came from a SketchUp export ?

I also tried to import it (into SketchUp) and it failed.

I do not have AutoCAD so I cannot inspect the DWG.

It crashed LibreCAD when I tried to load it.

Do you have a text callout objects in the SketchUp model before export to DWG ?

I tried to look at the dwg using dwgsee, and it seems to be blank? As @DanRathbun has mentioned, if you can share the SketchUp model on which you ran your script we could investigate better.

Oh, I thought you were talking about the file created…

Here is the source file which is basically a template with our typical layers and some dummy objects.

z_export_tests.skp (339.8 KB)

And here is the script I am working on.

z_export.rb (4.2 KB)

We don’t use AutoCAD either but we have to provide CAD files to our consults that need to be pretty remedial 2D versions of our 3-D models in SketchUp.

Exporting 2D views in SketchUp currently does not honor the layers in the file. Only 3-D exports do that.

Therefore to create what we need we currently have to go to each view and manually export 2D versions of up to 10 views to create corresponding DWG files. Then we place all the 2D DWG files in one sketchup file and finally use the 3D exporter to save the another DWG file which will have layers the consultants can use. Uggg!

The script is supposed to automate the process. It’s actually working pretty good except for the fact that the exports screwy.

And the API lacks this feature support …


Have you tried sending the model to LayOut and exporting the DWG from there ?
LayOut has much better DWG export support.

BTW, are you ensuring that the camera is in parallel projection before the 2D exports ?

I know but strangely, when I manually export a view from Ruby Console, I get a 2D result. I figured it was actually a 3d export that just looked “close” because all views are orthographic

which addresses your other note…

Yes, they are.

And finally…

I good idea also but unfortunately, Layout does not respect the layers (actually Tags now) of the sketchup objects themselves, only the layers that the Views are placed on in Layout. So if you had a Sketchup Model with objects on various layers (tags) but the view in Layout is on the layer “VIEWPORT” then all the CAD geometry comes in on a “VIEWPORT” layer.

Yeah, I thought I was crazy because I could not reproduce the 2D CAD export. But indeed, if I execute export with no second argument (in other words with no options flags)…

Sketchup.active_model.export("temp.dwg")

I get a 2D CAD file!

Oh! I did not realize this. I had thought otherwise. This is not good. Not at all.