README
¶
#dxf
DXF(Drawing Exchange Format by Autodesk, Inc) library for golang.
- version: ACAD2000(AC1015)
- format : ASCII
is only supported.
Reference
http://www.autodesk.com/techpubs/autocad/acad2000/dxf/index.htm
Example
package main
import (
"github.com/yofu/dxf"
"github.com/yofu/dxf/color"
"github.com/yofu/dxf/table"
"log"
"math"
)
func main() {
d := dxf.NewDrawing()
d.Header().LtScale = 100.0
d.AddLayer("Toroidal", dxf.DefaultColor, dxf.DefaultLineType, true)
d.AddLayer("Poloidal", color.Red, table.LT_HIDDEN, true)
z := 0.0
r1 := 200.0
r2 := 500.0
ndiv := 16
dtheta := 2.0 * math.Pi / float64(ndiv)
theta := 0.0
for i := 0; i < ndiv; i++ {
d.ChangeLayer("Toroidal")
d.Circle(0.0, 0.0, z+r1*math.Cos(theta), r2-r1*math.Sin(theta))
d.ChangeLayer("Poloidal")
c, _ := d.Circle(r2*math.Cos(theta), r2*math.Sin(theta), 0.0, r1)
dxf.SetExtrusion(c, []float64{-1.0 * math.Sin(theta), math.Cos(theta), 0.0})
theta += dtheta
}
err := d.SaveAs("torus.dxf")
if err != nil {
log.Fatal(err)
}
}
Installation
$ go get github.com/yofu/dxf
License
MIT
Author
Yoshihiro FUKUSHIMA
Documentation
¶
Overview ¶
Package dxf is a DXF(Drawing Exchange Format) library for golang. ACAD2000(AC1015), ASCII format is only supported. http://www.autodesk.com/techpubs/autocad/acad2000/dxf/index.htm
Index ¶
- Variables
- func ColorIndex(cl []int) color.ColorNumber
- func FromFile(fn string) (*drawing.Drawing, error)
- func FromReader(r io.Reader) (*drawing.Drawing, error)
- func FromStringData(d string) (*drawing.Drawing, error)
- func IndexColor(index uint8) []uint8
- func NewDrawing() *drawing.Drawing
- func Open(filename string) (*drawing.Drawing, error)
- func Parse3DFace(d *drawing.Drawing, data [][2]string) (entity.Entity, error)
- func ParseAppID(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func ParseArc(d *drawing.Drawing, data [][2]string) (entity.Entity, error)
- func ParseBlock(d *drawing.Drawing, data [][2]string) error
- func ParseBlockRecord(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func ParseBlocks(d *drawing.Drawing, line int, data [][2]string) error
- func ParseCircle(d *drawing.Drawing, data [][2]string) (entity.Entity, error)
- func ParseClasses(d *drawing.Drawing, line int, data [][2]string) error
- func ParseDimStyle(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func ParseEntities(d *drawing.Drawing, line int, data [][2]string) error
- func ParseEntity(d *drawing.Drawing, data [][2]string) (entity.Entity, error)
- func ParseEntityFunc(t string) (func(*drawing.Drawing, [][2]string) (entity.Entity, error), error)
- func ParseHeader(d *drawing.Drawing, line int, data [][2]string) error
- func ParseLayer(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func ParseLine(d *drawing.Drawing, data [][2]string) (entity.Entity, error)
- func ParseLtype(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func ParseLwPolyline(d *drawing.Drawing, data [][2]string) (entity.Entity, error)
- func ParseObjects(d *drawing.Drawing, line int, data [][2]string) error
- func ParsePoint(d *drawing.Drawing, data [][2]string) (entity.Entity, error)
- func ParseStyle(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func ParseTable(d *drawing.Drawing, data [][2]string, index int, ...) error
- func ParseTables(d *drawing.Drawing, line int, data [][2]string) error
- func ParseText(d *drawing.Drawing, data [][2]string) (entity.Entity, error)
- func ParseUCS(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func ParseView(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func ParseViewport(d *drawing.Drawing, data [][2]string) (table.SymbolTable, error)
- func SetExtrusion(e Extruder, d []float64)
- type Extruder
Constants ¶
This section is empty.
Variables ¶
var ( DefaultColor = color.White DefaultLineType = table.LT_CONTINUOUS )
Default values.
Functions ¶
func ColorIndex ¶
func ColorIndex(cl []int) color.ColorNumber
ColorIndex converts RGB value to corresponding color number.
func FromReader ¶
Main logic to create a drawing
func FromStringData ¶
Create drawing from string
func IndexColor ¶
IndexColor converts color number to RGB value.
func Parse3DFace ¶
Parse3DFace parses 3DFACE entities.
func ParseAppID ¶
ParseAppID parses APPID tables.
func ParseBlock ¶
ParseBlock parses each BLOCK, which starts with "0\nBLOCK\n" and ends with "0\nENDBLK\n".
func ParseBlockRecord ¶
ParseBlockRecord parses BLOCK_RECORD tables.
func ParseBlocks ¶
ParseBlocks parses BLOCKS section.
func ParseCircle ¶
ParseCircle parses CIRCLE entities.
func ParseClasses ¶
ParseClasses parses CLASSES section.
func ParseDimStyle ¶
ParseDimStyle parses DIMSTYLE tables.
func ParseEntities ¶
ParseEntities parses ENTITIES section.
func ParseEntity ¶
ParseEntity parses each entity.
func ParseEntityFunc ¶
ParseEntityFunc returns a function for parsing acoording to entity type string.
func ParseHeader ¶
ParseHeader parses HEADER section.
func ParseLayer ¶
ParseLayer parses LAYER tables.
func ParseLtype ¶
ParseLtype parses LTYPE tables.
func ParseLwPolyline ¶
ParseLwPolyline parses LWPOLYLINE entities.
func ParseObjects ¶
ParseObjects parses OBJECTS section.
func ParsePoint ¶
ParsePoint parses POINT entities.
func ParseStyle ¶
ParseStyle parses STYLE tables.
func ParseTable ¶
func ParseTable(d *drawing.Drawing, data [][2]string, index int, parser func(*drawing.Drawing, [][2]string) (table.SymbolTable, error)) error
ParseTable parses each TABLE, which starts with "0\nTABLE\n" and ends with "0\nENDTAB\n".
func ParseTables ¶
ParseTables parses TABLES section.
func ParseViewport ¶
ParseViewport parses VPORT tables.
func SetExtrusion ¶
SetExtrusion sets new coord acoording to given direction.
Types ¶
type Extruder ¶
type Extruder interface { CurrentDirection() []float64 SetDirection([]float64) CurrentCoord() []float64 SetCoord([]float64) }
Extruder represents an entity with code 210, 220, 230 like Circle.
210: Extrusion direction (optional; default = 0, 0, 1) X value 220, 230: Y and Z values of extrusion direction (optional)
Directories
¶
Path | Synopsis |
---|---|
BLOCK section
|
BLOCK section |
CLASSES section
|
CLASSES section |
Color Number
|
Color Number |
Package drawing defines Drawing struct for DXF.
|
Package drawing defines Drawing struct for DXF. |
ENTITIES section
|
ENTITIES section |
example
|
|
DXF Output Formatter
|
DXF Output Formatter |
Geometrical Functions
|
Geometrical Functions |
Handler interface
|
Handler interface |
HEADER section
|
HEADER section |
OBJECTS section
|
OBJECTS section |
TABLES section
|
TABLES section |