예제 #1
0
        public StringBuilder ExportSelectedForACAD()
        {
            StringBuilder sb = new StringBuilder();

            GeometricEntity selection;

            if (this.SelectedVolume != null)
            {
                selection = this.SelectedVolume;
            }
            else
            {
                selection = this.SelectedPolygon;
            }

            if (selection == null)
            {
                return(sb);
            }

            // save linetypes and layers in their respective tables
            string selected_layer_name = selection.EntityLayer.EntityName.Replace('.', '_');

            selected_layer_name = selected_layer_name.Replace(" ", "__");
            List <string> names = new List <string> {
                selected_layer_name
            };
            List <SharpDX.Color> colors = new List <Color> {
                selection.EntityLayer.EntityColor
            };

            DXFUtils.AddLineTypeAndLayerDefinitionsToExport(ref sb, names, colors);

            // save the entities
            sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString());           // 0
            sb.AppendLine(DXFUtils.SECTION_START);                                  // SECTION
            sb.AppendLine(((int)EntitySaveCode.ENTITY_NAME).ToString());            // 2
            sb.AppendLine(DXFUtils.ENTITY_SECTION);                                 // ENTITIES

            selection.AddToACADExport(ref sb, selected_layer_name, selected_layer_name + DXFUtils.LAYER_HIDDEN_SUFFIX);

            sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString());           // 0
            sb.AppendLine(DXFUtils.SECTION_END);                                    // ENDSEC

            // mark the end
            sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString());       // 0
            sb.AppendLine(DXFUtils.EOF);                                        // EOF

            return(sb);
        }
예제 #2
0
        public StringBuilder ExportEntitiesForACAD()
        {
            StringBuilder sb = new StringBuilder();

            // save linetypes and layers in their respective tables
            Dictionary <Layer, string> layer_names         = this.GetFlatLayerQualifiedNameList();
            Dictionary <Layer, string> layer_names_conform = new Dictionary <Layer, string>();

            foreach (var entry in layer_names)
            {
                string name   = entry.Value.Replace('.', '_');
                string name_1 = name.Replace(" ", "__");
                layer_names_conform.Add(entry.Key, name_1);
            }

            List <string>        names  = layer_names_conform.Values.ToList();
            List <SharpDX.Color> colors = layer_names_conform.Keys.Select(x => x.EntityColor).ToList();

            DXFUtils.AddLineTypeAndLayerDefinitionsToExport(ref sb, names, colors);

            // save the entities
            sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString());           // 0
            sb.AppendLine(DXFUtils.SECTION_START);                                  // SECTION
            sb.AppendLine(((int)EntitySaveCode.ENTITY_NAME).ToString());            // 2
            sb.AppendLine(DXFUtils.ENTITY_SECTION);                                 // ENTITIES

            List <GeometricEntity> GEs = this.GetFlatGeometryList();

            foreach (GeometricEntity ge in GEs)
            {
                if (ge.Visibility == EntityVisibility.ON)
                {
                    ge.AddToACADExport(ref sb, layer_names_conform[ge.EntityLayer], layer_names_conform[ge.EntityLayer] + DXFUtils.LAYER_HIDDEN_SUFFIX);
                }
            }

            sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString());           // 0
            sb.AppendLine(DXFUtils.SECTION_END);                                    // ENDSEC

            // mark the end
            sb.AppendLine(((int)EntitySaveCode.ENTITY_START).ToString());       // 0
            sb.AppendLine(DXFUtils.EOF);                                        // EOF

            return(sb);
        }