Question

How to detect if a cad file is 2d/3d?

  • 1 June 2015
  • 6 replies
  • 111 views

Hello All: 

 

I am creating a workspace that translates an Autocad .dwg cad file into an xml. The workspace works fine. One of the validation I would like to do on the cad file in the workspace is to check if the input cad (.dwg) file is a 3d or 2d file. I know how to check the dimension of each of the cad layers using DimensionExtractor transformer. But I want to check whether the cad file itself is in 2D or 3D. I have been researching all of the Autocad Reader Feature Type Propoerties. One of the Format Attributes that might be able to give some info on the cad file's raw dimensions is autocad_dim_flag (or autocad_dimension_flag). Unfortunately, I have not stumbled upon  any available documentation on how to extract any dimension (2D or 3D) info from the cad file. Any help/sugggestion is highly appreciated! Thank you!

6 replies

Badge +1
Hi,

 

A few ideas........

 

1. Visual check - view data in Inspector in 3d - view data edge on - data will be a long horizontal line if it's 2d - otherwise it's 3d.

 

2. Expose X,Y and Z attributes of all geometry.

 

Test for any Z attribute not equal to 0 - if any Z attributes are not equal to 0 - data is probably 3d.

 

Strictly speaking, test to see if all data (nodes / vertices) have the same Z value. Use a Statistics Calculator and a GroupBy on the Z attribute. There should only be 1 Z value (probably 0). If you have >1 Z value - data is 2d, otherwise it's 3d (or badly drawn 2d !!!).

 

...............

 

Hope this helps

 

Howard L'

 

 
Badge +1
*** EDIT TO ORIGINAL ANSWER - ORIGINAL REPLY WRITTEN TOO QUICKLY !!! ***

 

(Safe - can we please have an edit button to correct typos / replies etc ???)

 

.........................

 

Hi,

 

A few ideas........

 

1. Visual check - view data in Inspector in 3d - view data edge on (ie in elevation).

 

You will see a long horizontal line if data is in 2d - otherwise it's in 3d (or badly drawn 2d !!!)

 

...................

 

2. Expose X,Y and Z attributes of all data.

 

Test for any Z attribute not equal to 0 - if any Z attributes are not equal to 0 - data is probably 3d.

 

Strictly speaking, test to see if all data (nodes / vertices) have the same Z value. Use a Statistics Calculator and a GroupBy on the Z attribute.

 

If you have 1 Z value (probably 0) - data is 2d

 

If you have >1 Z value - data is 3d or badly drawn 2d - see visual check above.

 

...............

 

Hope this helps

 

Howard L'
Thanks for the reply Howard. I will try your suggestion and inform about the results. Thank you!
Hi Howard,

 

I tried your method and it produces result but my intial tests seem to indicate that the cad files I am testing, all seem to have issues with some layers having some 2D features while others coming up as 3D (so to use your logic explained above they will all produce a result of badly drawn 2D). I will try a couple of more ideas here. Thanks!
Badge +1
It's not all necessarily badly drawn 2d !!!

 

Especially if you've got quite a lot of 2d AND 3d data in one file.

 

.............

 

Check data in Inspector and look for other clues eg Layer Names.

 

You may have some data eg buildings / roads in 2d...

 

...but all height related data in 3d eg contours, spot heights, levels

 

..............

 

Transformers u may find helpful:

 

AttributeFilter  - useful to help split out layer names for example

 

2d Forcer - ensures everything is 2d (if that's what u require)

 

...............

 

Hope this helps

 

Howard L'
Thanks Howard! Much appreciated!

Reply