[GRASS5] v.in.dxf

Hi,

I've committed v.in.dxf in CVS and it now supports z coordinate import, which
means v.in.dxf3d is not required to build a 3d vector file. The label import
feature in the previous version is not yet supported. Don't forget to run
v.build after v.in.dxf. In addition, v.surf.idw can read in z values from a 3d
vector.

Huidae Cho

Thanks very much. This will be a great help. Hopefully, label support can be
added soon.

Michael
__________________________________________
Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Huidae Cho <grass4u@gmail.com>
Date: Fri, 24 Mar 2006 17:51:12 -0600
To: <grass5@grass.itc.it>, <grasslist@baylor.edu>
Subject: [GRASS5] v.in.dxf

Hi,

I've committed v.in.dxf in CVS and it now supports z coordinate import, which
means v.in.dxf3d is not required to build a 3d vector file. The label import
feature in the previous version is not yet supported. Don't forget to run
v.build after v.in.dxf. In addition, v.surf.idw can read in z values from a
3d
vector.

Huidae Cho

On 3/25/06, Huidae Cho <grass4u@gmail.com> wrote:

Hi,

I've committed v.in.dxf in CVS and it now supports z coordinate import, which
means v.in.dxf3d is not required to build a 3d vector file. The label import
feature in the previous version is not yet supported.

        fclose(layers[count].Map->dig_fp.file);
        layers[count].Map->dig_fp.file =
            G_fopen_modify(buf, GRASS_VECT_COOR_ELEMENT);

What was the intention?
BTW, vector structure members should never be accessed directly
in modules, use Vect_ functions.

Don't forget to run v.build after v.in.dxf.

I see Vect_build(layers[count].Map, stderr) in create_layers.c
and that builds topology.

It seems that you import each DXF layer as separate vector map?
I think that it would be better to import everything in one map
with more layers. You can assign layer to each line with cat.

   Vect_cat_set (Cats, layer_number, category );

Note that DWG/DXF files usually contain many layers, it is realy impractical
to import a single DXF as 60 GRASS maps.
It would also simplify the v.in.dxf code as you don't need to handle many
vector maps.

Radim

In addition, v.surf.idw can read in z values from a 3d
vector.

Huidae Cho

Actually, the current v.in.dxf is not a rewrite version, but a port from GRASS
5.x, so what I did is only to make it run with 6.x. That being said, I didn't
have enough time to improve it.

On Mon, Mar 27, 2006 at 10:18:37AM +0200, Radim Blazek wrote:

On 3/25/06, Huidae Cho <grass4u@gmail.com> wrote:
> Hi,
>
> I've committed v.in.dxf in CVS and it now supports z coordinate import, which
> means v.in.dxf3d is not required to build a 3d vector file. The label import
> feature in the previous version is not yet supported.

        fclose(layers[count].Map->dig_fp.file);
        layers[count].Map->dig_fp.file =
            G_fopen_modify(buf, GRASS_VECT_COOR_ELEMENT);

What was the intention?
BTW, vector structure members should never be accessed directly
in modules, use Vect_ functions.

According to the comment, the original version opened layers with
G_fopen_append() and needed to open it again with G_fopen_modify() to add head
info.

> Don't forget to run v.build after v.in.dxf.

I see Vect_build(layers[count].Map, stderr) in create_layers.c
and that builds topology.

That's what I added after the first posting.

It seems that you import each DXF layer as separate vector map?
I think that it would be better to import everything in one map
with more layers. You can assign layer to each line with cat.

   Vect_cat_set (Cats, layer_number, category );

Note that DWG/DXF files usually contain many layers, it is realy impractical
to import a single DXF as 60 GRASS maps.
It would also simplify the v.in.dxf code as you don't need to handle many
vector maps.

I agree with you on that. The module should import all layers automatically
regardless of whether or not users know the names of the layers that they want.
Selecting specific layers should be an option, not a default behaviour.

Huidae Cho

Radim

> In addition, v.surf.idw can read in z values from a 3d
> vector.
>
> Huidae Cho
>
>

At 10:48, lunedì 27 marzo 2006, Huidae Cho has probably written:

I didn't have enough time to improve it.

It would be great if someone could do it.
pc

--
Paolo Cavallini
email+jabber: cavallini@faunalia.it
www.faunalia.it
Piazza Garibaldi 5 - 56025 Pontedera (PI), Italy Tel: (+39)348-3801953

On 3/27/06, Huidae Cho <grass4u@gmail.com> wrote:

> fclose(layers[count].Map->dig_fp.file);
> layers[count].Map->dig_fp.file =
> G_fopen_modify(buf, GRASS_VECT_COOR_ELEMENT);
>
> What was the intention?
> BTW, vector structure members should never be accessed directly
> in modules, use Vect_ functions.

According to the comment, the original version opened layers with
G_fopen_append() and needed to open it again with G_fopen_modify() to add head
info.

I recommend to remove that.

> It seems that you import each DXF layer as separate vector map?
> I think that it would be better to import everything in one map
> with more layers. You can assign layer to each line with cat.
>
> Vect_cat_set (Cats, layer_number, category );
>
> Note that DWG/DXF files usually contain many layers, it is realy impractical
> to import a single DXF as 60 GRASS maps.
> It would also simplify the v.in.dxf code as you don't need to handle many
> vector maps.

I agree with you on that. The module should import all layers automatically
regardless of whether or not users know the names of the layers that they want.
Selecting specific layers should be an option, not a default behaviour.

It should be done before stable release (6.2.0).

Radim

On Mon, Mar 27, 2006 at 12:26:58PM +0200, Radim Blazek wrote:

On 3/27/06, Huidae Cho <grass4u@gmail.com> wrote:
> > fclose(layers[count].Map->dig_fp.file);
> > layers[count].Map->dig_fp.file =
> > G_fopen_modify(buf, GRASS_VECT_COOR_ELEMENT);
> >
> > What was the intention?
> > BTW, vector structure members should never be accessed directly
> > in modules, use Vect_ functions.
>
> According to the comment, the original version opened layers with
> G_fopen_append() and needed to open it again with G_fopen_modify() to add head
> info.

I recommend to remove that.

> > It seems that you import each DXF layer as separate vector map?
> > I think that it would be better to import everything in one map
> > with more layers. You can assign layer to each line with cat.
> >
> > Vect_cat_set (Cats, layer_number, category );
> >
> > Note that DWG/DXF files usually contain many layers, it is realy impractical
> > to import a single DXF as 60 GRASS maps.
> > It would also simplify the v.in.dxf code as you don't need to handle many
> > vector maps.
>
> I agree with you on that. The module should import all layers automatically
> regardless of whether or not users know the names of the layers that they want.
> Selecting specific layers should be an option, not a default behaviour.

It should be done before stable release (6.2.0).

Radim

Done in CVS except for layer selection. BTW, why does "d.vect layer=" display
ALL layers? I had to add cats=1-9999999 to see what's in a given layer. Is this
a feature?

d.vect map=mymap layer=4 # is the same as d.vect map=mymap
d.vect map=mymap layer=4 cats=1-99999999 # displays the layer 4

Huidae Cho

On 3/27/06, Huidae Cho <grass4u@gmail.com> wrote:

Done in CVS except for layer selection.

Thanks.

BTW, why does "d.vect layer=" display
ALL layers? I had to add cats=1-9999999 to see what's in a given layer. Is this
a feature?

d.vect map=mymap layer=4 # is the same as d.vect map=mymap
d.vect map=mymap layer=4 cats=1-99999999 # displays the layer 4

Yes, layer=4 should only display the layer 4. I think that evolution was
  d.vect
  d.vect cats=
  d.vect cats= layer=
but d.vect layer= was not implemented.

Radim

Huidae Cho

Is that correct that v.in.dxf works with version R12 only?
We tested with R14 and 2000, and got no results.
pc

At 21:31, lunedì 27 marzo 2006, Huidae Cho has probably written:

Done in CVS except for layer selection. BTW, why does "d.vect layer="
display ALL layers? I had to add cats=1-9999999 to see what's in a given
layer. Is this a feature?

d.vect map=mymap layer=4 # is the same as d.vect map=mymap
d.vect map=mymap layer=4 cats=1-99999999 # displays the layer 4

Huidae Cho

--
Paolo Cavallini
email+jabber: cavallini@faunalia.it
www.faunalia.it
Piazza Garibaldi 5 - 56025 Pontedera (PI), Italy Tel: (+39)348-3801953

v.in.dxf was originally written in 1989, so there is a great chance that it
will not work with a newer version of DXF. If you don't mind, could you please
give me DXFs that you tried so that I can take a look at the format?

Huidae Cho

On Thu, Mar 30, 2006 at 06:19:17PM +0200, Paolo Cavallini wrote:

Is that correct that v.in.dxf works with version R12 only?
We tested with R14 and 2000, and got no results.
pc

At 21:31, lunedì 27 marzo 2006, Huidae Cho has probably written:
>
> Done in CVS except for layer selection. BTW, why does "d.vect layer="
> display ALL layers? I had to add cats=1-9999999 to see what's in a given
> layer. Is this a feature?
>
> d.vect map=mymap layer=4 # is the same as d.vect map=mymap
> d.vect map=mymap layer=4 cats=1-99999999 # displays the layer 4
>
> Huidae Cho
--
Paolo Cavallini
email+jabber: cavallini@faunalia.it
www.faunalia.it
Piazza Garibaldi 5 - 56025 Pontedera (PI), Italy Tel: (+39)348-3801953

_______________________________________________
grass5 mailing list
grass5@grass.itc.it
http://grass.itc.it/mailman/listinfo/grass5

Is that correct that v.in.dxf works with version R12 only?

No. I don't know if it will work with anthing newer than R10.
Do you have it working with a R12 file?

We tested with R14 and 2000, and got no results.

You will need v.in.dwg for those.

see http://grass.itc.it/pipermail/grassuser/2006-March/033407.html
     https://intevation.de/rt/webrt?serial_num=2451

Hamish

At 05:10, venerdì 31 marzo 2006 you presumably wrote:

> Is that correct that v.in.dxf works with version R12 only?

No. I don't know if it will work with anthing newer than R10.
Do you have it working with a R12 file?

I confirm: it is working with R12 (still have to check whether anything is
missing, but it seems OK).

> We tested with R14 and 2000, and got no results.

You will need v.in.dwg for those.

Wouldn't it be feasible to upgrade v.in.dxf? Perhaps borrowing some code from
other software, like qcad?

see http://grass.itc.it/pipermail/grassuser/2006-March/033407.html
     https://intevation.de/rt/webrt?serial_num=2451

Hamish

--
Paolo Cavallini
email+jabber: cavallini@faunalia.it
www.faunalia.it
Piazza Garibaldi 5 - 56025 Pontedera (PI), Italy Tel: (+39)348-3801953

> > We tested with R14 and 2000, and got no results.
>
> You will need v.in.dwg for those.

Wouldn't it be feasible to upgrade v.in.dxf? Perhaps borrowing some
code from other software, like qcad?

I see that qcad claims to open dxf 2004, via "dxflib", which is GPL.

http://www.ribbonsoft.com/dxflib.html

Can you open your 2004 files in QCAD cleanly? resave from there in a
compatible format?

> see http://grass.itc.it/pipermail/grassuser/2006-March/033407.html
> https://intevation.de/rt/webrt?serial_num=2451

Hamish

Hi,
is the latest GRASS CVS has v.in.dxf.
No more recompiling with source code.!!
If answer is YES… is great.
Similarly for E00 imports when will they be part of GRASS CVS ??
Sooner the better. Cheers to all the GRASS developers.
Ravi Kumar

Michael Barton michael.barton@asu.edu wrote:

Thanks very much. This will be a great help. Hopefully, label support can be
added soon.

Michael


Michael Barton, Professor of Anthropology
School of Human Evolution and Social Change
Arizona State University
Tempe, AZ 85287-2402

phone: 480-965-6213
fax: 480-965-7671
www: http://www.public.asu.edu/~cmbarton

From: Huidae Cho


Yahoo! Messenger with Voice. PC-to-Phone calls for ridiculously low rates.

is the latest GRASS CVS has v.in.dxf.
No more recompiling with source code.!!
If answer is YES.. is great.

Yes. But note you probably will only be able to load older versions of
DXF (ie no newer than AutoCAD ver. 9 or 10). For anything newer you will
still need to use v.in.dwg or help the Free software world to reverse
engineer the propritary format.

To convert newer DXF to older DXF see the Lx-Viewer project:
  http://lx-viewer.sourceforge.net
but I see that uses "an ammended version of the GPL v2 so that we can
link to the OpenDWG libraries." shrug.

note code to descramble AutoCAD 2004 DWG header info is here:
http://www.opendesign.com/about/faq.htm#encrypted

copied here for educational purposes:
"The data starting at location 0x80 of the DWG file can be decrypted by
exclusive or'ing with the number sequence produced by the following
code:

OdUInt8* p = data.asArrayPtr();
OdUInt32 sz = 0x6c;
int randseed = 1;
while (sz--)
{
  randseed *= 0x343fd;
  randseed += 0x269ec3;
  *p++ = (OdUInt8)(randseed >> 0x10);
}

If you don't read C++, this code starts with 1, multiplies it by a
number, adds it to a number, bit-shifts it, saves 8-bits of the result,
and starts again. No, it's not a complex algorithm, but it's enough to
completely scramble a DWG file."

interesting.

see also:
  http://intevation.net/rt/webrt?serial_num=2451&display=History

labels:
look for v.cadlabel in GRASS 5 and
http://grass.itc.it/pipermail/grassuser/1994-April/020692.html
  * note labels now do rotation, maybe the time has come?

Similarly for E00 imports when will they be part of GRASS CVS ??

v.in.e00 is already installed by default. To use you just need to
install avcE00 and E00Compr from http://avce00.maptools.org/avce00/

Debian pakages for both are now in Debian testing and unstable
thanks to Paul Wise and the DebianGIS team.

The situation is no different than needing GDAL to import GDAL/OGR
formats. IIRC, no one has funded E00 support in GDAL/OGR yet, so it
hasn't happened there. Hence the extra dependancy.

Hamish

Hi,

I would like to test the new v.in.dxf as I could need it at the moment. But how can I compile it? Is ist possible to compile only the module or do I have to compile the whole grass. What do I need to compile it (I assume gcc?)?

Or is there already a binary version for cygwin?

Regards

Wolfgang

I would like to test the new v.in.dxf as I could need it at the
moment. But how can I compile it? Is ist possible to compile only the
module or do I have to compile the whole grass. What do I need to
compile it (I assume gcc?)?

You will probably have to compile all of GRASS 6.1-cvs yourself.
In the near future you will be able to add on individual (adapted)
source modules with Benjamin Ducke's GEM. For now, all of GRASS.

Or is there already a binary version for cygwin?

I don't know how often the cygwin CVS binaries get updated.

Hamish