func (d *Drawing) Point(x, y, z float64) (*entity.Point, error) {
	p := entity.NewPoint()
	p.Coord = []float64{x, y, z}
	p.SetLayer(d.CurrentLayer)
	d.AddEntity(p)
	return p, nil
}
Point creates a new POINT at (x, y, z).
package drawing
import (
	"bytes"
	"errors"
	"fmt"
	"io"
	"os"
	"github.com/yofu/dxf/block"
	"github.com/yofu/dxf/class"
	"github.com/yofu/dxf/color"
	"github.com/yofu/dxf/entity"
	"github.com/yofu/dxf/format"
	"github.com/yofu/dxf/handle"
	"github.com/yofu/dxf/header"
	"github.com/yofu/dxf/object"
	"github.com/yofu/dxf/table"
)
type Drawing struct {
	FileName     string
	Layers       map[string]*table.Layer
	Groups       map[string]*object.Group
	Styles       map[string]*table.Style
	CurrentLayer *table.Layer
	CurrentStyle *table.Style
	formatter    format.Formatter
	Sections     []Section
	dictionary   *object.Dictionary
	groupdict    *object.Dictionary
	PlotStyle    handle.Handler
	savebuff *bytes.Buffer
}
func New() *Drawing {
	d := new(Drawing)
	d.Layers = make(map[string]*table.Layer)
	d.Layers["0"] = table.LY_0
	d.Groups = make(map[string]*object.Group)
	d.CurrentLayer = d.Layers["0"]
	d.Styles = make(map[string]*table.Style)
	d.Styles["STANDARD"] = table.ST_STANDARD
	d.CurrentStyle = d.Styles["STANDARD"]
	d.formatter = format.NewASCII()
	d.formatter.SetPrecision(16)
	d.Sections = []Section{
		header.New(),
		class.New(),
		table.New(),
		block.New(),
		entity.New(),
		object.New(),
	}
	d.dictionary = object.NewDictionary()
	d.addObject(d.dictionary)
	wd, ph := object.NewAcDbDictionaryWDFLT(d.dictionary)
	d.dictionary.AddItem("ACAD_PLOTSTYLENAME", wd)
	d.addObject(wd)
	d.addObject(ph)
	d.groupdict = object.NewDictionary()
	d.addObject(d.groupdict)
	d.dictionary.AddItem("ACAD_GROUP", d.groupdict)
	d.PlotStyle = ph
	d.Layers["0"].SetPlotStyle(d.PlotStyle)
	return d
}
func (d *Drawing) saveFile(filename string) error {
	w, err := os.Create(filename)
	if err != nil {
		return err
	}
	defer w.Close()
	_, err = d.WriteTo(w)
	return err
}
func (d *Drawing) Save() error {
	if d.FileName == "" {
		return errors.New("filename is blank, use SaveAs(filename)")
	}
	return d.saveFile(d.FileName)
}
func (d *Drawing) SaveAs(filename string) error {
	d.FileName = filename
	return d.saveFile(filename)
}
func (d *Drawing) setHandle() {
	h := 1
	for _, s := range d.Sections[1:] {
		s.SetHandle(&h)
	}
	d.Sections[0].SetHandle(&h)
}
func (d *Drawing) Header() *header.Header {
	return d.Sections[0].(*header.Header)
}
func (d *Drawing) Layer(name string, setcurrent bool) (*table.Layer, error) {
	if l, exist := d.Layers[name]; exist {
		if setcurrent {
			d.CurrentLayer = l
		}
		return l, nil
	}
	return nil, fmt.Errorf("layer %s doesn't exist", name)
}
func (d *Drawing) AddLayer(name string, cl color.ColorNumber, lt *table.LineType, setcurrent bool) (*table.Layer, error) {
	if l, exist := d.Layers[name]; exist {
		if setcurrent {
			d.CurrentLayer = l
		}
		return l, fmt.Errorf("layer %s already exists", name)
	}
	l := table.NewLayer(name, cl, lt)
	l.SetPlotStyle(d.PlotStyle)
	d.Layers[name] = l
	d.Sections[2].(table.Tables).AddLayer(l)
	if setcurrent {
		d.CurrentLayer = l
	}
	return l, nil
}
func (d *Drawing) ChangeLayer(name string) error {
	if l, exist := d.Layers[name]; exist {
		d.CurrentLayer = l
		return nil
	}
	return fmt.Errorf("layer %s doesn't exist", name)
}
func (d *Drawing) Style(name string, setcurrent bool) (*table.Style, error) {
	if s, exist := d.Styles[name]; exist {
		if setcurrent {
			d.CurrentStyle = s
		}
		return s, nil
	}
	return nil, fmt.Errorf("style %s doesn't exist", name)
}
func (d *Drawing) AddStyle(name string, fontname, bigfontname string, setcurrent bool) (*table.Style, error) {
	if s, exist := d.Styles[name]; exist {
		if setcurrent {
			d.CurrentStyle = s
		}
		return s, fmt.Errorf("style %s already exists", name)
	}
	s := table.NewStyle(name)
	s.FontName = fontname
	s.BigFontName = bigfontname
	d.Styles[name] = s
	d.Sections[TABLES].(table.Tables)[table.STYLE].Add(s)
	if setcurrent {
		d.CurrentStyle = s
	}
	return s, nil
}
func (d *Drawing) LineType(name string) (*table.LineType, error) {
	lt, err := d.Sections[TABLES].(table.Tables)[table.LTYPE].Contains(name)
	if err != nil {
		return nil, fmt.Errorf("linetype %s", err.Error())
	}
	return lt.(*table.LineType), nil
}
func (d *Drawing) AddLineType(name string, desc string, ls ...float64) (*table.LineType, error) {
	lt, _ := d.Sections[TABLES].(table.Tables)[table.LTYPE].Contains(name)
	if lt != nil {
		return lt.(*table.LineType), fmt.Errorf("linetype %s already exists", name)
	}
	newlt := table.NewLineType(name, desc, ls...)
	d.Sections[TABLES].(table.Tables)[table.LTYPE].Add(newlt)
	return newlt, nil
}
func (d *Drawing) Entities() entity.Entities {
	return d.Sections[ENTITIES].(entity.Entities)
}
func (d *Drawing) AddEntity(e entity.Entity) {
	d.Sections[4] = d.Sections[4].(entity.Entities).Add(e)
}