Select to view content in your preferred language

load dxf or dwg files to map

5352
4
12-29-2010 11:31 AM
NancyHernandez
Emerging Contributor
Hello!!

I would like to know how I load dxf or dwg files to map

I have this code in mi XALM file, that open a window where I should select a file to load
[HTML]
  <local:DraggableWindow IsOpen="False" x:Name="agregararchivo"
   Grid.Row="2"
   Margin="20,100"
   VerticalAlignment="Top"
   HorizontalAlignment="Right"
   Padding="0"
   HorizontalContentAlignment="Stretch"
   VerticalContentAlignment="Stretch"
   Title="Agregar Archivo a la Vista">
   <Grid Margin="0" Background="#FFEEE1CF" Height="128"                       HorizontalAlignment="Stretch" Width="440">
    <Grid Margin="8,22,31,46">
     <Rectangle Fill="#FFE0D1BB" Stroke="Black" StrokeThickness="0" Margin="-6,0,-24,0"/>
     <TextBox Margin="32,29,72,11" TextWrapping="Wrap"/>
     <Button HorizontalAlignment="Right" Margin="0,28,-24,8" Width="80" Content="Examinar" Click="Button_Click"/>
     <Button x:Name="btnsubirarchivoagregar" Height="24" HorizontalAlignment="Right" Margin="0,0,-24,-39" VerticalAlignment="Bottom" Width="80" Content="Subir Archivo" Click="btnsubirarchivoagregar_Click"/>
     <TextBlock Margin="8,5,96,0" FontFamily="Verdana" FontSize="16" Text="Carga de Archivos DXF y/o DWG" TextWrapping="Wrap" Height="24" VerticalAlignment="Top"/>
    </Grid>
   </Grid>
  </local:DraggableWindow>
[/HTML]

I want to open a OpenFileDialog to select a file and load

Thanks!!
0 Kudos
4 Replies
JMcNeil
Deactivated User
Nancititla,

Wow that sounds crazy but awesome.  I would love to see the ending for this and get the code.  It seems like if the dxf or dwg files are projected you could turn them into a graphic layer.  Check out this post, the link I posted on this post has code that will show you how to browse and pick up a shapefile and load it. Beware I think it might only work for 2.0 release not sure if it can handle the 2.1 API

http://forums.arcgis.com/threads/20089-Using-custom-data-in-ArcGIS-Silverlight


Here's the code posted on the site to open a dialog box...not sure if you already got past this point or not but I think you could just change the extenstion .shp and .dbf to .dwg and .dwf.  The site also has the dll for download that will take the shape and load into the app.

private void openFileDialog_Click( object sender, RoutedEventArgs e )
        {
            //Create the dialog allowing the user to select the "*.shp" and the "*.dbf" files
            OpenFileDialog ofd = new OpenFileDialog();
            ofd.Multiselect = true;

            if( !( ofd.ShowDialog() ?? false ) )
                return;

            //Get the file info objects for the SHP and the DBF file selected by the user
            FileInfo shapeFile = null;
            FileInfo dbfFile = null;
            foreach( FileInfo fi in ofd.Files )
            {
                if( fi.Extension.ToLower() == ".shp" )
                {
                    shapeFile = fi;
                }
                if( fi.Extension.ToLower() == ".dbf" )
                {
                    dbfFile = fi;
                }
            }

            //Read the SHP and DBF files into the ShapeFileReader
            ShapeFile shapeFileReader = new ShapeFile();
            if( shapeFile != null && dbfFile != null )
            {
                shapeFileReader.Read( shapeFile, dbfFile );
            }
            else
            {
                HtmlPage.Window.Alert( "Please select a SP and a DBF file to proceed." );
                return;
            }

            //Add the shapes from the shapefile into a graphics layer named "shapefileGraphicsLayer"
            //the greaphics layer should be present in the XAML or created earlier
            GraphicsLayer graphicsLayer = MyMap.Layers[ "shapefileGraphicsLayer" ] as GraphicsLayer;
            foreach( ShapeFileRecord record in shapeFileReader.Records )
            {
                Graphic graphic = record.ToGraphic();
                if( graphic != null )
                    graphicsLayer.Graphics.Add( graphic );
            }
        }





Good luck and please share your code if you dial this one in.

J
0 Kudos
NancyHernandez
Emerging Contributor
Thanks for the replay J, 🙂

I'll try your suggest, thanks


The site also has the dll for download that will take the shape and load into the app.


but in the site you say I can't see the dll for download, is there a directly link? or  I need to seek with more detail? 😮 😛 because I think there isn't any links for download dlls, could you help me? Thanks a lot!! 😄
0 Kudos
AliMirzabeigi
Emerging Contributor
Use the following link to download the latest changeset (72193):
http://esrislcontrib.codeplex.com/SourceControl/changeset/changes/72193
0 Kudos
MustaphaKoaik
Esri Contributor
hi there did you reach a solution with ur idea? because iam trying to do the same thing with my application..is there any way to apply this?
0 Kudos