thandxfini.py :  » Business-Application » ThanCad » thancad-0.0.9 » thansupport » thandxfemu » Python Open Source

Home
Python Open Source
1.3.1.2 Python
2.Ajax
3.Aspect Oriented
4.Blog
5.Build
6.Business Application
7.Chart Report
8.Content Management Systems
9.Cryptographic
10.Database
11.Development
12.Editor
13.Email
14.ERP
15.Game 2D 3D
16.GIS
17.GUI
18.IDE
19.Installer
20.IRC
21.Issue Tracker
22.Language Interface
23.Log
24.Math
25.Media Sound Audio
26.Mobile
27.Network
28.Parser
29.PDF
30.Project Management
31.RSS
32.Search
33.Security
34.Template Engines
35.Test
36.UML
37.USB Serial
38.Web Frameworks
39.Web Server
40.Web Services
41.Web Unit
42.Wiki
43.Windows
44.XML
Python Open Source » Business Application » ThanCad 
ThanCad » thancad 0.0.9 » thansupport » thandxfemu » thandxfini.py
# -*- coding: iso-8859-7 -*-
##############################################################################
# ThanCad 0.0.9 "DoesSomething": 2dimensional CAD with raster support for engineers.
# 
# Copyright (c) 2001-2009 Thanasis Stamos,  August 23, 2009
# URL:     http://thancad.sourceforge.net
# e-mail:  cyberthanasis@excite.com
# 
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation; either version 2 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU General Public License for more details (www.gnu.org/licenses/gpl.html).
# 
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
##############################################################################

"""\
ThanCad 0.0.9 "DoesSomething": 2dimensional CAD with raster support for engineers.

This package emulates the dxf library in ThanCad.
"""

from os.path import splitext
from math import fabs

from thandxflin import ThanDxfLin
from thandxfsym import ThanDxfSym
from thandxfdra import ThanDxfDra
from thandxfgeo import ThanDxfGeo
from thandxfatt import ThanDxfAtt

from thandxfext import thanCadCodes



class ThanDxfEmu(ThanDxfLin, ThanDxfSym, ThanDxfDra,
                    ThanDxfGeo, ThanDxfAtt):
    "Class to create drawings directly into .dxf files."

    def __init__(self, extensions=0):
        "Initialisation of class."

  ThanDxfLin.__init__(self)
  ThanDxfSym.__init__(self)
  ThanDxfDra.__init__(self)
  ThanDxfGeo.__init__(self)
  ThanDxfAtt.__init__(self)

  self.__tabExist = 0
        self.__blocks   = 0
        self.__entities = 0
  self.thanExt = extensions


    def thanDxfPlots(self, uDxf1=None):
        "User initialisation 1."

        self.thanDxfPlots1(uDxf1)
        self.thanDxfTableDef (' ', 0)

#-------STYLE header-------------------------------------------------

        self.thanDxfTableDef ('STYLE', 1)
        self.thanDxfCrTstyle ('GRSTYLE', 'Times New Roman Greek')

#-------LINETYPE header-------------------------------------------------

        self.thanDxfTableDef ('LTYPE', 2)
        self.thanDxfCrLtype ('DOTR',    '..........', [0.0,  -0.06])
        self.thanDxfCrLtype ('DASHED2', '- - - - ',   [0.25, -0.125])

#-------ENTITIES follow--------------------------------------------

        self.thanDxfTableDef ('ENTITIES', 1)
  self.thanDxfSetTstyle("GRSTYLE")

    def thanDxfPlots1 (self, uDxf1=None):
        "Initialisation 2."
        self._imp = uDxf1

        self.thanDxfSetLayer('P1')
        self.thanDxfSetLtype ('BYLAYER')
        self.thanDxfSetColor (0)
  self.thanDxfSetTstyle("STANDARD")

        self.thanMode  = 2
        self.thanDelay = 100
        self.thanXar   = 0.0
        self.thanYar   = 0.0
        self.thanZar   = 0.0
        self.thanXfac  = 1.0
        self.thanYfac  = 1.0
        self.thanZfac  = 1.0
        self.thanFact  = 1.0
        self.thanPXnow = 0.0
        self.thanPYnow = 0.0
        self.thanPZnow = 0.0
        self.thanPXar  = 0.0
        self.thanPYar  = 0.0
        self.thanPZar  = 0.0
#        self.thanDotxcm = 513.0 / 23.5
#        self.thanDotycm = 347.0 / 17.0
        self.thanDotxcm = 180.0 / 2.539970
        self.thanDotycm = 180.0 / 2.539970

        self.thanDotmin = 1.0 / self.thanDotxcm

  self.thanDxfSetPlineWidth(0.0, 0.0)
#        self.thanDxfPlot(1/dotxcm, 0, -3)
#        self.thanDxfCls()

    def thanDxfTableDef(self, tableName, iTableEntries):
        """Specifies that a table follows or section entities.

        tableName:     Name of table to be created (STYLE, LAYER, LTYPE)
        iTableEntries: Number of elements of each table. For example, If we have 4 layers
                 then ay TableName LAYER, iTableEntries=4.
           If iTableEntries==4 an initialisation is performed.
        """

        if iTableEntries == 0:
#            self.thanDxfWrEntry(0, 'SECTION')                 # SECTION initialisation
#            self.thanDxfWrEntry(2, 'TABLES')                  # TABLES
            self.__tabExist = 0
            self.__blocks   = 0
            self.__entities = 0
        elif self.__entities:
            print 'thanTableDef(): Table definitions must precede ENTITIES.'
      sys.exit(1)
        elif tableName == 'ENTITIES':
      if self.__tabExist and not self.__blocks: pass #self.thanDxfWrEntry(0, 'ENDTAB')
#            self.thanDxfWrEntry(0, 'ENDSEC')
#            self.thanDxfWrEntry(0, 'SECTION')
#            self.thanDxfWrEntry(2, 'ENTITIES')
            self.__entities = 1
        elif tableName == 'BLOCKS':                        # TABLE start
            if self.__blocks:
          print 'thanTableDef(): Blocks already defined!'
    sys.exit(1)
            if self.__tabExist: pass #self.thanDxfWrEntry(0, 'ENDTAB')
#            self.thanDxfWrEntry(0, 'ENDSEC')
#            self.thanDxfWrEntry(0, 'SECTION')
#            self.thanDxfWrEntry(2, 'BLOCKS')
            self.__blocks = 1
            self.__tabExist = 1
        else:
            if self.__blocks:
          print 'ThanTableDef(): Table defs must precede blocks.'
    sys.exit(1)
            if self.__tabExist: pass #self.thanDxfWrEntry(0, 'ENDTAB')
#            self.thanDxfWrEntry(0, 'TABLE')
#            self.thanDxfWrEntry(2, tableName)
#            self.thanDxfWrEntry(70, iTableEntries)
            self.__tabExist = 1

    def thanDxfCrLayer(self, name, color=7, linetype="continuous", off=False,
                       frozen=False, locked=False, noplot=False, lineweight=0.0, **kw):
        """Creates a layer entry in the dxf file.

        name  :  layer name
        color :  layer color
        linetype :  layer Linetype
  lineweight: The thickness of the "pen" that the layer is
              plotted with (mm)

        TABLE LAYER
         62:  5 (or positive) : layer on
             -5 (or negative) : layer off
         70:  flags: bit 0: if set layer is frozen (the layer is NOT drawn on the monitor)
                            if flags & 1: it is frozen
                     bit 2: if set layer is locked (its elements can not be altered)
                            if flags & 4: it is locked
        4  : layer locked
        370: 106 :  lineweight 1.06 mm
              60 :             0.60 mm
              -3 :             Autocad's default lineweight (who knows what this means!)
        290: 0   : no plot is on (the layer is NOT plotted)
                   If code 290 is absent, then no plot is off (the layer is plotted)
        Any other attribute not defined above are ignored.
  """
        self._imp.thanSetLay(name, color)

    def thanDxfCrLtype (self, linName, linDescr, rElems):
        """Creates a line type entry in the dxf file.

        linName    : Line type name
        linDescr   : Line type description
        rElems     : Line elements
  """
  pass

    def thanDxfCrTstyle(self, fName, fFontFileName):
        """Creates a text style entry in the dxf file.

        fName        : Text Style name
        fFontFileName: Font filename. If it has ".shx" extension, then it is
                 defined as complex linestyle.
  """
        pass

    def thanDxfCrBlock(self, bFileName):
        """Creates a block entry in the dxf file.

  The block definition in the dxf file must not include
  code 5 (handle), because Intellicad has trouble with it
  (it may be either Intellicad's dxfin bug, or Autocad's
  dxfout bug.
  ThanCad is indifferent (it does not support blocks yet ;) )."""
        pass
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.