1 # ##### BEGIN GPL LICENSE BLOCK #####
3 # This program is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU General Public License
5 # as published by the Free Software Foundation; either version 2
6 # of the License, or (at your option) any later version.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software Foundation,
15 # Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 # ##### END GPL LICENSE BLOCK #####
20 "name": "Import Autocad DXF Format (.dxf)",
21 "author": "Thomas Larsson, Remigiusz Fiedler",
23 "blender": (2, 63, 0),
24 "location": "File > Import > Autocad (.dxf)",
25 "description": "Import files in the Autocad DXF format (.dxf)",
26 "warning": "Under construction! Visit Wiki for details.",
27 "wiki_url": "http://wiki.blender.org/index.php/Extensions:2.6/Py/"
28 "Scripts/Import-Export/DXF_Importer",
29 "tracker_url": "https://projects.blender.org/tracker/index.php?"
30 "func=detail&aid=23480",
31 "support": "OFFICIAL",
32 "category": "Import-Export",
36 Release note by migius (DXF support maintainer) 2011.01.02:
37 Script supports only a small part of DXF specification:
38 - imports LINE, ARC, CIRCLE, ELLIPSE, SOLID, TRACE, POLYLINE, LWPOLYLINE
40 - supports 3d-rotation of entities (210 group)
41 - supports THICKNESS for SOLID, TRACE, LINE, ARC, CIRCLE, ELLIPSE
42 - ignores WIDTH, THICKNESS, BULGE in POLYLINE/LWPOLYLINE
43 - ignores face-data in POLYFACE / POLYMESH
44 - ignores TEXT 2d-rotation
45 - ignores hierarchies (BLOCK, INSERT, GROUP)
47 - ignores COLOR, LINEWIDTH, LINESTYLE
49 This script is a temporary solution.
50 No functionality improvements are planed for this version.
51 The advanced importer from 2.49 will replace it in the future.
54 Place this file to Blender addons directory
55 (on Windows it is %Blender_directory%\2.53\scripts\addons\)
56 The script must be activated in "Addons" tab (user preferences).
57 Access it from File > Import menu.
60 ver 0.1.6 - 2012.01.03 by migius and trumanblending for r.42615
61 - modified for recent changes to matrix indexing
62 ver 0.1.5 - 2011.02.05 by migius for r.34661
63 - changed support level to OFFICIAL
64 - fixed missing last point at building Mesh-ARCs (by pildanovak)
65 - fixed for changes in API and mathutils by campbell
66 ver 0.1.4 - 2011.01.13 by migius
67 - modified for latest API in rev.34300 (by Filiciss Muhgue)
68 ver 0.1.3 - 2011.01.02 by migius
69 - added draw curves as sequence for "Draw_as_Curve"
70 - added toggle "Draw as one" as user preset in UI
71 - added draw POINT as mesh-vertex
72 - added draw_THICKNESS for LINE, ARC, CIRCLE, ELLIPSE, LWPOLYLINE and POLYLINE
73 - added draw_THICKNESS for SOLID, TRACE
74 ver 0.1.2 - 2010.12.27 by migius
75 - added draw() for TRACE
76 - fixed wrong vertex order in SOLID
77 - added CIRCLE resolution as user preset in UI
78 - added closing segment for circular LWPOLYLINE and POLYLINE
79 - fixed registering for 2.55beta
80 ver 0.1.1 - 2010.09.07 by migius
81 - fixed dxf-file names recognition limited to ".dxf"
82 - fixed registering for 2.53beta
83 ver 0.1 - 2010.06.10 by Thomas Larsson
86 __version__
= '.'.join([str(s
) for s
in bl_info
['version']])
91 from math
import sin
, cos
, radians
93 from mathutils
import Vector
, Matrix
107 toggle
= T_Merge | T_NewScene | T_DrawOne | T_ThicON
122 print("Section", self
.type)
123 for datum
in self
.data
:
139 print("Table %s %s %s %s %s %d" % (self
.type, self
.name
, self
.handle
, self
.owner
, self
.subclass
, self
.nEntries
))
145 def __init__(self
, typ
, drawtype
):
147 self
.drawtype
= drawtype
154 self
.linetype_name
= ''
155 self
.linetype_scale
= 1.0
157 #self.normal = Vector((0,0,1))
160 print("Entity %s %s %s %s %s %s %x" %
161 (self
.type, self
.handle
, self
.owner
, self
.subclass
, self
.layer
, self
.color
, self
.invisible
))
163 def build(self
, vn
=0):
166 raise NameError("Warning: can not build - unsupported entity type: %s" % self
.type)
167 return(([], [], [], vn
))
172 raise NameError("Warning: can not draw - unsupported entity type: %s" % self
.type)
176 DxfCommonAttributes
= {
180 48 : 'linetype_scale',
190 # class C3dFace(CEntity):
191 # 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
192 # 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
193 # 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
194 # 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
198 class C3dFace(CEntity
):
200 CEntity
.__init
__(self
, '3DFACE', 'Mesh')
201 self
.point0
= Vector()
202 self
.point1
= Vector()
203 self
.point2
= Vector()
204 self
.point3
= Vector()
207 CEntity
.display(self
)
213 def build(self
, vn
=0):
214 verts
= [self
.point0
, self
.point1
, self
.point2
]
215 if self
.point3
== Vector((0,0,0)) or self
.point2
== self
.point3
:
216 faces
= [(vn
+0, vn
+1, vn
+2)]
219 verts
.append( self
.point3
)
220 faces
= [(vn
+0, vn
+1, vn
+2, vn
+3)]
222 return((verts
, [], faces
, vn
))
225 # class C3dSolid(CEntity):
226 # 1 : 'data', 3 : 'more', 70 : 'version',
229 class C3dSolid(CEntity
):
231 CEntity
.__init
__(self
, '3DSOLID', 'Mesh')
237 # class CAcadProxyEntity(CEntity):
239 # 90 : 'id', 91 : 'class', 92 : 'graphics_size', 93 : 'entity_size', 95: 'format',
240 # 310 : 'data', 330 : 'id1', 340 : 'id2', 350 : 'id3', 360 : 'id4',
243 class CAcadProxyEntity(CEntity
):
245 CEntity
.__init
__(self
, 'ACAD_PROXY_ENTITY', None)
249 # class CArc(CEntity):
250 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
252 # 50 : 'start_angle', 51 : 'end_angle'
257 CEntity
.__init
__(self
, 'ARC', 'Mesh')
258 self
.center
= Vector()
260 self
.start_angle
= 0.0
263 self
.normal
= Vector((0,0,1))
266 CEntity
.display(self
)
268 print("%.4f %.4f %.4f " % (self
.radius
, self
.start_angle
, self
.end_angle
))
270 def build(self
, vn
=0):
271 start
, end
= self
.start_angle
, self
.end_angle
272 if end
> 360: end
= end
% 360.0
273 if end
< start
: end
+=360.0
274 # angle = end - start # UNUSED
276 deg2rad
= math
.pi
/180.0
281 w
= dphi
/theCircleRes
286 edges
, faces
= [], []
287 for n
in range(theCircleRes
+ 1):
288 s
= math
.sin(n
*w
+ phi0
)
289 c
= math
.cos(n
*w
+ phi0
)
290 v
= center
+ Vector((r
*c
, r
*s
, 0.0))
293 thic
= self
.thickness
294 t_vector
= Vector((0, 0, thic
))
295 if thic
!= 0 and (toggle
& T_ThicON
):
296 thic_points
= [v
+ t_vector
for v
in points
]
298 thic_points
.extend(points
)
301 points
.extend(thic_points
)
302 faces
= [(v0
+nr
+0,v0
+nr
+1,v0
+pn
+nr
+1,v0
+pn
+nr
+0) for nr
in range(pn
)]
304 self
.drawtype
= 'Mesh'
307 edges
= [(v0
+nr
+0,v0
+nr
+1) for nr
in range(pn
)]
311 if self
.normal
!=Vector((0,0,1)):
312 ma
= getOCS(self
.normal
)
315 points
= [ma
* v
for v
in points
]
316 #print ('arc vn=', vn)
317 #print ('faces=', len(faces))
318 return ((points
, edges
, faces
, vn
))
321 # class CArcAlignedText(CEntity):
322 # 1 : 'text', 2 : 'font', 3 : 'bigfont', 7 : 'style',
323 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
324 # 40 : 'radius', 41 : 'width', 42 : 'height', 43 : 'spacing',
325 # 44 : 'offset', 45 : 'right_offset', 46 : 'left_offset',
326 # 50 : 'start_angle', 51 : 'end_angle',
327 # 70 : 'order', 71 : 'direction', 72 : 'alignment', 73 : 'side',
328 # 74 : 'bold', 75 : 'italic', 76 : 'underline',
329 # 77 : 'character_set', 78 : 'pitch', 79 'fonttype',
331 # 280 : 'wizard', 330 : 'id'
334 class CArcAlignedText(CEntity
):
336 CEntity
.__init
__(self
, 'ARCALIGNEDTEXT', 'Mesh')
339 self
.center
= Vector()
345 self
.right_offset
= 0.0
346 self
.left_offset
= 0.0
347 self
.start_angle
= 0.0
356 self
.character_set
= 0
362 self
.normal
= Vector((0,0,1))
366 # class CAttdef(CEntity):
367 # 1 : 'text', 2 : 'tag', 3 : 'prompt', 7 : 'style',
368 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
369 # 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
370 # 40 : 'height', 41 : 'x_scale',
371 # 50 : 'rotation_angle', 51 : 'oblique_angle',
372 # 70 : 'flags', 71 : 'text_generation_flags',
373 # 72 : 'horizontal_justification', 74 : 'vertical_justification',
376 class CAttdef(CEntity
):
378 CEntity
.__init
__(self
, 'ATTDEF', None)
383 self
.insertion_point
= Vector()
384 self
.alignment_point
= Vector()
387 self
.rotation_angle
= 0.0
388 self
.oblique_angle
= 0.0
390 self
.text_generation_flags
= 0
391 self
.horizontal_justification
= 0.0
392 self
.vertical_justification
= 0.0
393 self
.normal
= Vector((0,0,1))
396 drawText(self
.text
, self
.insertion_point
, self
.height
, self
.x_scale
, self
.rotation_angle
, self
.oblique_angle
, self
.normal
)
400 # class CAttrib(CEntity):
401 # 1 : 'text', 2 : 'tag', 3 : 'prompt', 7 : 'style',
402 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
403 # 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
404 # 40 : 'height', 41 : 'x_scale',
405 # 50 : 'rotation_angle', 51 : 'oblique_angle',
406 # 70 : 'flags', 73 : 'length',
407 # 71 : 'text_generation_flags', 72 : 'horizontal_justification', 74 : 'vertical_justification',
410 class CAttrib(CEntity
):
412 CEntity
.__init
__(self
, 'ATTRIB', None)
418 self
.insertion_point
= Vector()
419 self
.alignment_point
= Vector()
422 self
.rotation_angle
= 0.0
423 self
.oblique_angle
= 0.0
426 self
.text_generation_flags
= 0
427 self
.horizontal_justification
= 0.0
428 self
.vertical_justification
= 0.0
429 self
.normal
= Vector((0,0,1))
432 drawText(self
.text
, self
.insertion_point
, self
.height
, self
.x_scale
, self
.rotation_angle
, self
.oblique_angle
, self
.normal
)
437 # class CBlock(CEntity):
438 # 1 : 'xref', 2 : 'name', 3 : 'also_name',
439 # 10 : 'base_point.x', 20 : 'base_point.y', 30 : 'base_point.z',
440 # 40 : 'size', 41 : 'x_scale',
441 # 50 : 'rotation_angle', 51 : 'oblique_angle',
445 class CBlock(CEntity
):
447 CEntity
.__init
__(self
, 'BLOCK', None)
451 self
.base_point
= Vector()
454 self
.rotation_angle
= 0.0
455 self
.oblique_angle
= 0.0
457 self
.normal
= Vector((0,0,1))
460 CEntity
.display(self
)
461 print("%s %s %s " % (self
.xref
, self
.name
, self
.also_name
))
462 print(self
.base_point
)
469 # class CCircle(CEntity):
470 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
474 class CCircle(CEntity
):
476 CEntity
.__init
__(self
, 'CIRCLE', 'Mesh')
477 self
.center
= Vector()
480 self
.normal
= Vector((0,0,1))
483 CEntity
.display(self
)
485 print("%.4f" % self
.radius
)
487 def build(self
, vn
=0):
488 w
= 2*math
.pi
/theCircleRes
492 edges
, faces
= [], []
494 for n
in range(theCircleRes
):
497 v
= center
+ Vector((r
*c
, r
*s
, 0))
501 thic
= self
.thickness
502 t_vector
= Vector((0, 0, thic
))
503 if thic
!= 0 and (toggle
& T_ThicON
):
504 thic_points
= [v
+ t_vector
for v
in points
]
506 thic_points
.extend(points
)
509 points
.extend(thic_points
)
510 faces
= [(v0
+nr
,v0
+nr
+1,pn
+v0
+nr
+1,pn
+v0
+nr
) for nr
in range(pn
)]
512 faces
[-1] = (v0
+nr
,v0
,pn
+v0
,pn
+v0
+nr
)
513 self
.drawtype
= 'Mesh'
516 edges
= [(v0
+nr
,v0
+nr
+1) for nr
in range(pn
)]
518 edges
[-1] = (v0
+nr
,v0
)
520 if self
.normal
!=Vector((0,0,1)):
521 ma
= getOCS(self
.normal
)
524 points
= [ma
* v
for v
in points
]
525 #print ('cir vn=', vn)
526 #print ('faces=',len(faces))
527 return( (points
, edges
, faces
, vn
) )
530 # class CDimension(CEntity):
531 # 1 : 'text', 2 : 'name', 3 : 'style',
532 # 10 : 'def_point.x', 20 : 'def_point.y', 30 : 'def_point.z',
533 # 11 : 'mid_point.x', 21 : 'mid_point.y', 31 : 'mid_point.z',
534 # 12 : 'vector.x', 22 : 'vector.y', 32 : 'vector.z',
535 # 13 : 'def_point2.x', 23 : 'def_point2.y', 33 : 'def_point2.z',
536 # 14 : 'vector2.x', 24 : 'vector2.y', 34 : 'vector2.z',
537 # 15 : 'vector3.x', 25 : 'vector3.y', 35 : 'vector3.z',
538 # 16 : 'vector4.x', 26 : 'vector4.y', 36 : 'vector4.z',
542 class CDimension(CEntity
):
544 CEntity
.__init
__(self
, 'DIMENSION', None)
548 self
.def_point
= Vector()
549 self
.mid_point
= Vector()
550 self
.vector
= Vector()
551 self
.def_point2
= Vector()
552 self
.vector2
= Vector()
553 self
.vector3
= Vector()
554 self
.vector4
= Vector()
556 self
.normal
= Vector((0,0,1))
562 # class CEllipse(CEntity):
563 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
564 # 11 : 'end_point.x', 21 : 'end_point.y', 31 : 'end_point.z',
565 # 40 : 'ratio', 41 : 'start', 42 : 'end',
568 class CEllipse(CEntity
):
570 CEntity
.__init
__(self
, 'ELLIPSE', 'Mesh')
571 self
.center
= Vector()
572 self
.end_point
= Vector()
577 self
.normal
= Vector((0,0,1))
580 CEntity
.display(self
)
582 print("%.4f" % self
.ratio
)
584 def build(self
, vn
=0):
585 dphi
= (self
.end
- self
.start
)
587 w
= dphi
/theCircleRes
588 r
= self
.end_point
.length
590 a
= self
.end_point
.x
/r
591 b
= self
.end_point
.y
/r
595 edges
, faces
= [], []
596 for n
in range(theCircleRes
):
597 x
= r
*math
.sin(n
*w
+ phi0
)
598 y
= f
*r
*math
.cos(n
*w
+ phi0
)
599 v
= (center
.x
- a
*x
+ b
*y
, center
.y
- a
*y
- b
*x
, center
.z
)
603 thic
= self
.thickness
604 t_vector
= Vector((0, 0, thic
))
605 if thic
!= 0 and (toggle
& T_ThicON
):
606 thic_points
= [v
+ t_vector
for v
in points
]
608 thic_points
.extend(points
)
611 points
.extend(thic_points
)
612 faces
= [(v0
+nr
,v0
+nr
+1,pn
+v0
+nr
+1,pn
+v0
+nr
) for nr
in range(pn
)]
614 faces
[-1] = (v0
+nr
,v0
,pn
+v0
,pn
+v0
+nr
)
615 #self.drawtype = 'Mesh'
618 edges
= [(v0
+nr
,v0
+nr
+1) for nr
in range(pn
)]
620 edges
[-1] = (v0
+nr
,v0
)
624 if thic
!= 0 and (toggle
& T_ThicON
):
626 if self
.normal
!=Vector((0,0,1)):
627 ma
= getOCS(self
.normal
)
630 points
= [ma
* v
for v
in points
]
631 return ((points
, edges
, faces
, vn
))
634 # class CHatch(CEntity):
636 # 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
637 # 41 : 'scale', 47 : 'pixelsize', 52 : 'angle',
638 # 70 : 'fill', 71 : 'associativity', 75: 'style', 77 : 'double',
639 # 78 : 'numlines', 91 : 'numpaths', 98 : 'numseeds',
642 class CHatch(CEntity
):
644 CEntity
.__init
__(self
, 'HATCH', None)
646 self
.point
= Vector()
651 self
.associativity
= 0
657 self
.normal
= Vector((0,0,1))
660 # class CImage(CEntity):
661 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
662 # 11 : 'u_vector.x', 21 : 'u_vector.y', 31 : 'u_vector.z',
663 # 12 : 'v_vector.x', 22 : 'v_vector.y', 32 : 'v_vector.z',
664 # 13 : 'size.x', 23 : 'size.y', 33 : 'size.z',
665 # 14 : 'clip.x', 24 : 'clip.y', 34 : 'clip.z',
666 # 70 : 'display', 71 : 'cliptype',
668 # 280 : 'clipstate', 281 : 'brightness', 282 : 'contrast', 283 : 'fade',
669 # 340 : 'image', 360 : 'reactor'
672 class CImage(CEntity
):
674 CEntity
.__init
__(self
, 'IMAGE', None)
675 self
.insertion_point
= Vector()
676 self
.u_vector
= Vector()
677 self
.v_vector
= Vector()
689 self
.normal
= Vector((0,0,1))
692 # class CInsert(CEntity):
693 # 1 : 'attributes_follow', 2 : 'name',
694 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
695 # 41 : 'x_scale', 42 : 'y_scale', 43 : 'z_scale',
696 # 44 : 'column_spacing', 45 : 'row_spacing',
697 # 50 : 'rotation_angle', 66 : 'attributes_follow',
698 # 70 : 'column_count', 71 : 'row_count',
701 class CInsert(CEntity
):
703 CEntity
.__init
__(self
, 'INSERT', None)
704 self
.attributes_follow
= 1
706 self
.insertion_point
= Vector()
710 self
.column_spacing
= 1.0
711 self
.row_spacing
= 1.0
712 self
.rotation_angle
= 0.0
713 self
.column_count
= 1
715 self
.attributes_follow
= 0
716 self
.normal
= Vector((0,0,1))
719 CEntity
.display(self
)
720 print(self
.insertion_point
)
727 # class CLeader(CEntity):
729 # 10 : ['new_vertex(data)'], 20 : 'vertex.y', 30 : 'vertex.z',
730 # 40 : 'height', 41 : 'width',
731 # 71 : 'arrowhead', 72 : 'pathtype', 73 : 'creation',
732 # 74 : 'hookdir', 75 : 'hookline', 76 : 'numverts', 77 : 'color',
733 # 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
734 # 211 : 'horizon.x', 221 : 'horizon.y', 231 : 'horizon.z',
735 # 212 : 'offset_ins.x', 222 : 'offset_ins.y', 232 : 'offset_ins.z',
736 # 213 : 'offset_ann.x', 223 : 'offset_ann.y', 233 : 'offset_ann.z',
739 class CLeader(CEntity
):
741 CEntity
.__init
__(self
, 'LEADER', 'Mesh')
754 self
.normal
= Vector((0,0,1))
755 self
.horizon
= Vector()
756 self
.offset_ins
= Vector()
757 self
.offset_ann
= Vector()
759 def new_vertex(self
, data
):
760 self
.vertex
= Vector()
762 self
.verts
.append(self
.vertex
)
764 def build(self
, vn
=0):
767 edges
.append((vn
, vn
+1))
770 return (self
.verts
, edges
, [], vn
)
772 # class CLwPolyLine(CEntity):
773 # 10 : ['new_vertex(data)'], 20 : 'vertex.y', 30 : 'vertex.z',
774 # 38 : 'elevation', 39 : 'thickness',
775 # 40 : 'start_width', 41 : 'end_width', 42 : 'bulge', 43 : 'constant_width',
776 # 70 : 'flags', 90 : 'numverts'
779 class CLWPolyLine(CEntity
):
781 CEntity
.__init
__(self
, 'LWPOLYLINE', None)
786 self
.start_width
= 0.0
789 self
.constant_width
= 0.0
792 self
.normal
= Vector((0,0,1))
794 def new_vertex(self
, data
):
795 self
.vertex
= Vector()
797 self
.verts
.append(self
.vertex
)
799 def build(self
, vn
=0):
803 edges
.append((vn
, vn
+1))
805 if self
.flags
& PL_CLOSED
:
806 edges
[-1] = (vn
-1, v_start
)
810 if self
.normal
!=Vector((0,0,1)):
811 ma
= getOCS(self
.normal
)
814 verts
= [ma
* v
for v
in verts
]
815 return (verts
, edges
, [], vn
-1)
818 # class CLine(CEntity):
819 # 10 : 'start_point.x', 20 : 'start_point.y', 30 : 'start_point.z',
820 # 11 : 'end_point.x', 21 : 'end_point.y', 31 : 'end_point.z',
824 class CLine(CEntity
):
826 CEntity
.__init
__(self
, 'LINE', 'Mesh')
827 self
.start_point
= Vector()
828 self
.end_point
= Vector()
830 self
.normal
= Vector((0,0,1))
833 CEntity
.display(self
)
834 print(self
.start_point
)
835 print(self
.end_point
)
837 def build(self
, vn
=0):
838 points
= [self
.start_point
, self
.end_point
]
839 faces
, edges
= [], []
841 thic
= self
.thickness
842 if thic
!= 0 and (toggle
& T_ThicON
):
843 t_vector
= thic
* self
.normal
844 #print 'deb:thic_vector: ', t_vector #---------------------
845 points
.extend([v
+ t_vector
for v
in points
])
846 faces
= [[0+n
, 1+n
, 3+n
, 2+n
]]
847 self
.drawtype
= 'Mesh'
851 return((points
, edges
, faces
, vn
))
853 # class CMLine(CEntity):
854 # 10 : 'start_point.x', 20 : 'start_point.y', 30 : 'start_point.z',
855 # 11 : ['new_vertex(data)'], 21 : 'vertex.y', 31 : 'vertex.z',
856 # 12 : ['new_seg_dir(data)'], 22 : 'seg_dir.y', 32 : 'seg_dir.z',
857 # 13 : ['new_miter_dir(data)'], 23 : 'miter_dir.y', 33 : 'miter_dir.z',
858 # 40 : 'scale', 41 : 'elem_param', 42 : 'fill_param',
859 # 70 : 'justification', 71 : 'flags'
860 # 72 : 'numverts', 73 : 'numelems', 74 : 'numparam', 75 : 'numfills',
864 class CMLine(CEntity
):
866 CEntity
.__init
__(self
, 'MLINE', None)
867 self
.start_point
= Vector()
870 self
.miter_dir
= None
877 self
.justification
= 0
884 self
.normal
= Vector((0,0,1))
886 def new_vertex(self
, data
):
887 self
.vertex
= Vector()
889 self
.verts
.append(self
.vertex
)
891 def new_seg_dir(self
, data
):
892 self
.seg_dir
= Vector()
893 self
.seg_dir
.x
= data
894 self
.seg_dirs
.append(self
.seg_dir
)
896 def new_miter_dir(self
, data
):
897 self
.miter_dir
= Vector()
898 self
.miter_dir
.x
= data
899 self
.miter_dirs
.append(self
.miter_dir
)
904 # class CMText(CText):
905 # 1 : 'text', 3: 'more_text', 7 : 'style',
906 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
907 # 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
908 # 40 : 'nominal_height', 41 : 'reference_width', 42: 'width', 43 : 'height', 44 : 'line_spacing',
909 # 50 : 'rotation_angle',
910 # 71 : 'attachment_point', 72 : 'drawing_direction', 73 : 'spacing_style',
913 class CMText(CEntity
):
915 CEntity
.__init
__(self
, 'MTEXT', 'Text')
919 self
.insertion_point
= Vector()
920 self
.alignment_point
= Vector()
921 self
.nominal_height
= 1.0
922 self
.reference_width
= 1.0
925 self
.rotation_angle
= 0.0
926 self
.attachment_point
= 0
927 self
.drawing_direction
= 0
928 self
.spacing_style
= 0
929 self
.normal
= Vector((0,0,1))
932 CEntity
.display(self
)
933 print("%s %s" % (self
.text
, self
.style
))
934 print('MTEXTinsertion_point=',self
.insertion_point
)
935 print('MTEXTalignment_point=',self
.alignment_point
)
938 drawText(self
.text
, self
.insertion_point
, self
.height
, self
.width
, self
.rotation_angle
, 0.0, self
.normal
)
942 # class CPoint(CEntity):
943 # 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
944 # 39 : 'thickness', 50 : 'orientation'
947 class CPoint(CEntity
):
949 CEntity
.__init
__(self
, 'POINT', 'Mesh')
950 self
.point
= Vector()
952 self
.orientation
= 0.0
955 CEntity
.display(self
)
957 print("%.4f" % self
.orientation
)
959 def build(self
, vn
=0):
960 # draw as mesh-vertex
962 return((verts
, [], [], vn
+1))
966 # draw as empty-object
967 # loc = self.point # UNUSED
968 #bpy.ops.object.new('DXFpoint')
972 # class CPolyLine(CEntity):
973 # 1 : 'verts_follow', 2 : 'name',
974 # 10 : 'elevation.x', 20 : 'elevation.y', 30 : 'elevation.z',
975 # 40 : 'start_width', 41 : 'end_width',
976 # 66 : 'verts_follow_flag',
977 # 70 : 'flags', 71 : 'row_count', 72 : 'column_count',
978 # 73 : 'row_density', 74 : 'column_density', 75 : 'linetype',
981 class CPolyLine(CEntity
):
983 CEntity
.__init
__(self
, 'POLYLINE', 'Mesh')
985 self
.verts_follow
= 1
987 self
.elevation
= Vector()
989 self
.start_width
= 0.0
991 self
.verts_follow_flags
= 0
994 self
.column_count
= 1
995 self
.row_density
= 1.0
996 self
.column_density
= 1.0
998 self
.normal
= Vector((0,0,1))
1001 CEntity
.display(self
)
1003 for v
in self
.verts
:
1007 def build(self
, vn
=0):
1011 for vert
in self
.verts
:
1012 verts
.append(vert
.location
)
1013 lines
.append((vn
, vn
+1))
1015 if self
.flags
& PL_CLOSED
:
1016 lines
[-1] = (vn
-1, v_start
)
1019 if self
.normal
!=Vector((0,0,1)):
1020 ma
= getOCS(self
.normal
)
1022 verts
= [ma
* v
for v
in verts
]
1023 return((verts
, lines
, [], vn
-1))
1026 # class CShape(CEntity):
1028 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1030 # 40 : 'size', 41 : 'x_scale',
1031 # 50 : 'rotation_angle', 51 : 'oblique_angle',
1034 class CShape(CEntity
):
1036 CEntity
.__init
__(self
, 'SHAPE', None)
1038 self
.insertion_point
= Vector()
1039 self
.thickness
= 0.0
1042 self
.rotation_angle
= 0.0
1043 self
.oblique_angle
= 0.0
1046 CEntity
.display(self
)
1047 print("%s" % (self
.name
))
1048 print(self
.insertion_point
)
1051 # class CSpline(CEntity):
1052 # 10 : ['new_control_point(data)'], 20 : 'control_point.y', 30 : 'control_point.z',
1053 # 11 : ['new_fit_point(data)'], 21 : 'fit_point.y', 31 : 'fit_point.z',
1054 # 40 : ['new_knot_value(data)'],
1055 # 12 : 'start_tangent.x', 22 : 'start_tangent.y', 32 : 'start_tangent.z',
1056 # 13 : 'end_tangent.x', 23 : 'end_tangent.y', 33 : 'end_tangent.z',
1057 # 41 : 'weight', 42 : 'knot_tol', 43 : 'control_point_tol', 44 : 'fit_tol',
1058 # 70 : 'flag', 71 : 'degree',
1059 # 72 : 'num_knots', 73 : 'num_control_points', 74 : 'num_fit_points',
1060 # 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1063 class CSpline(CEntity
):
1065 CEntity
.__init
__(self
, 'SPLINE', 'Mesh')
1066 self
.control_points
= []
1067 self
.fit_points
= []
1068 self
.knot_values
= []
1069 self
.control_point
= None
1070 self
.fit_point
= None
1071 self
.knot_value
= None
1072 self
.start_tangent
= Vector()
1073 self
.end_tangent
= Vector()
1075 self
.knot_tol
= 1e-6
1076 self
.control_point_tol
= 1e-6
1081 self
.num_control_points
= 0
1082 self
.num_fit_points
= 0
1083 self
.thickness
= 0.0
1084 self
.normal
= Vector((0,0,1))
1086 def new_control_point(self
, data
):
1087 self
.control_point
= Vector()
1088 self
.control_point
.x
= data
1089 self
.control_points
.append(self
.control_point
)
1091 def new_fit_point(self
, data
):
1092 self
.fit_point
= Vector()
1093 self
.fit_point
.x
= data
1094 self
.fit_points
.append(self
.fit_point
)
1096 def new_knot_value(self
, data
):
1097 self
.knot_value
= data
1098 self
.knot_values
.append(self
.knot_value
)
1101 #not testet yet (migius)
1102 CEntity
.display(self
)
1104 for p
in self
.control_points
:
1107 for p
in self
.fit_points
:
1110 for v
in self
.knot_values
:
1113 def build(self
, vn
=0):
1116 for vert
in self
.control_points
:
1118 lines
.append((vn
, vn
+1))
1121 return((verts
, lines
, [], vn
))
1125 # class CSolid(CEntity):
1126 # 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1127 # 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1128 # 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1129 # 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1133 class CSolid(CEntity
):
1135 CEntity
.__init
__(self
, 'SOLID', 'Mesh')
1136 self
.point0
= Vector()
1137 self
.point1
= Vector()
1138 self
.point2
= Vector()
1139 self
.point3
= Vector()
1140 self
.normal
= Vector((0,0,1))
1141 self
.thickness
= 0.0
1144 CEntity
.display(self
)
1150 def build(self
, vn
=0):
1151 points
, edges
, faces
= [],[],[]
1152 if self
.point2
== self
.point3
:
1153 points
= [self
.point0
, self
.point1
, self
.point2
]
1155 points
= [self
.point0
, self
.point1
, self
.point2
, self
.point3
]
1159 thic
= self
.thickness
1160 t_vector
= Vector((0, 0, thic
))
1161 if thic
!= 0 and (toggle
& T_ThicON
):
1162 thic_points
= [v
+ t_vector
for v
in points
]
1164 thic_points
.extend(points
)
1165 points
= thic_points
1167 points
.extend(thic_points
)
1170 faces
= [[0,1,3,2], [4,6,7,5], [0,4,5,1],
1171 [1,5,7,3], [3,7,6,2], [2,6,4,0]]
1173 faces
= [[0,1,2], [3,5,4], [0,3,4,1], [1,4,5,2], [2,5,3,0]]
1174 elif pn
== 2: faces
= [[0,1,3,2]]
1177 if pn
== 4: faces
= [[0,2,3,1]]
1178 elif pn
== 3: faces
= [[0,2,1]]
1181 self
.drawtype
= 'Mesh'
1183 if self
.normal
!=Vector((0,0,1)):
1184 ma
= getOCS(self
.normal
)
1186 points
= [ma
* v
for v
in points
]
1187 return((points
, edges
, faces
, vn
))
1190 # class CText(CEntity):
1191 # 1 : 'text', 7 : 'style',
1192 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1193 # 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1194 # 40 : 'height', 41 : 'x_scale',
1195 # 50 : 'rotation_angle', 51 : 'oblique_angle',
1196 # 71 : 'flags', 72 : 'horizontal_justification', 73 : 'vertical_justification',
1199 class CText(CEntity
):
1201 CEntity
.__init
__(self
, 'TEXT', 'Text')
1204 self
.insertion_point
= Vector()
1205 self
.alignment_point
= Vector()
1208 self
.rotation_angle
= 0.0
1209 self
.oblique_angle
= 0.0
1211 self
.horizontal_justification
= 0.0
1212 self
.vertical_justification
= 0.0
1213 self
.thickness
= 0.0
1214 self
.normal
= Vector((0,0,1))
1217 CEntity
.display(self
)
1218 print("%s %s" % (self
.text
, self
.style
))
1219 print(self
.insertion_point
)
1220 print(self
.alignment_point
)
1223 drawText(self
.text
, self
.insertion_point
, self
.height
, self
.x_scale
, self
.rotation_angle
, self
.oblique_angle
, self
.normal
)
1227 def drawText(text
, loc
, size
, spacing
, angle
, shear
, normal
=Vector((0,0,1))):
1228 #print('angle_deg=',angle)
1229 bpy
.ops
.object.text_add(
1231 enter_editmode
=False,
1233 #rotation=(0, 0, angle), #need radians here
1235 cu
= bpy
.context
.object.data
1237 cu
.size
= size
#up 2.56
1238 cu
.space_word
= spacing
#up 2.56
1240 if angle
!=0.0 or normal
!=Vector((0,0,1)):
1241 obj
= bpy
.context
.object
1242 transform(normal
, angle
, obj
)
1246 # class CTolerance(CEntity):
1248 # 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1249 # 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1252 class CTolerance(CEntity
):
1254 CEntity
.__init
__(self
, 'TOLERANCE', None)
1256 self
.insertion_point
= Vector()
1257 self
.direction
= Vector()
1260 # class CTrace(CEntity):
1261 # 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1262 # 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1263 # 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1264 # 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1268 class CTrace(CEntity
):
1270 CEntity
.__init
__(self
, 'TRACE', 'Mesh')
1271 self
.point0
= Vector()
1272 self
.point1
= Vector()
1273 self
.point2
= Vector()
1274 self
.point3
= Vector()
1275 self
.normal
= Vector((0,0,1))
1276 self
.thickness
= 0.0
1279 CEntity
.display(self
)
1285 def build(self
, vn
=0):
1286 points
, edges
, faces
= [],[],[]
1287 if self
.point2
== self
.point3
:
1288 points
= [self
.point0
, self
.point2
, self
.point1
]
1290 points
= [self
.point0
, self
.point2
, self
.point1
, self
.point3
]
1293 thic
= self
.thickness
1294 t_vector
= Vector((0, 0, thic
))
1295 if thic
!= 0 and (toggle
& T_ThicON
):
1296 thic_points
= [v
+ t_vector
for v
in points
]
1298 thic_points
.extend(points
)
1299 points
= thic_points
1301 points
.extend(thic_points
)
1304 faces
= [[0,1,3,2], [4,6,7,5], [0,4,5,1],
1305 [1,5,7,3], [3,7,6,2], [2,6,4,0]]
1307 faces
= [[0,1,2], [3,5,4], [0,3,4,1], [1,4,5,2], [2,5,3,0]]
1308 elif pn
== 2: faces
= [[0,1,3,2]]
1311 if pn
== 4: faces
= [[0,2,3,1]]
1312 elif pn
== 3: faces
= [[0,2,1]]
1315 self
.drawtype
= 'Mesh'
1316 if self
.normal
!=Vector((0,0,1)):
1317 ma
= getOCS(self
.normal
)
1319 points
= [ma
* v
for v
in points
]
1320 return ((points
, edges
, faces
, vn
))
1323 # class CVertex(CEntity):
1324 # 10 : 'location.x', 20 : 'location.y', 30 : 'location.z',
1325 # 40 : 'start_width', 41 : 'end_width', 42 : 'bulge',
1328 # 71 : 'index1', 72 : 'index2', 73 : 'index3', 74 : 'index4',
1331 class CVertex(CEntity
):
1333 CEntity
.__init
__(self
, 'VERTEX', None)
1334 self
.location
= Vector()
1335 self
.start_width
= 0.0
1336 self
.end_width
= 0.0
1348 # class CViewPort(CEntity):
1349 # 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1350 # 12 : 'view_center.x', 22 : 'view_center.y', 32 : 'view_center.z',
1351 # 13 : 'snap_base.x', 23 : 'snap_base.y', 33 : 'snap_base.z',
1352 # 14 : 'snap_spacing.x', 24 : 'snap_spacing.y', 34 : 'snap_spacing.z',
1353 # 15 : 'grid_spacing.x', 25 : 'grid_spacing.y', 35 : 'grid_spacing.z',
1354 # 16 : 'view_direction.x', 26 : 'view_direction.y', 36 : 'view_direction.z',
1355 # 40 : 'width', 41 : 'height',
1356 # 68 : 'status', 69 : 'id',
1359 class CViewPort(CEntity
):
1361 CEntity
.__init
__(self
, 'VIEWPORT', None)
1362 self
.center
= Vector()
1363 self
.view_center
= Vector()
1364 self
.snap_base
= Vector()
1365 self
.snap_spacing
= Vector()
1366 self
.grid_spacing
= Vector()
1367 self
.view_direction
= Vector()
1378 # class CWipeOut(CEntity):
1379 # 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1380 # 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1383 class CWipeOut(CEntity
):
1385 CEntity
.__init
__(self
, 'WIPEOUT', None)
1386 self
.point
= Vector()
1387 self
.direction
= Vector()
1392 WORLDX
= Vector((1.0,0.0,0.0))
1393 WORLDY
= Vector((0.0,1.0,0.0))
1394 WORLDZ
= Vector((0.0,0.0,1.0))
1397 def getOCS(az
): #-----------------------------------------------------------------
1398 """An implimentation of the Arbitrary Axis Algorithm.
1400 #decide if we need to transform our coords
1401 #if az[0] == 0 and az[1] == 0:
1402 if abs(az
.x
) < 0.00001 and abs(az
.y
) < 0.00001:
1406 return Matrix((-WORLDX
, WORLDY
*1, -WORLDZ
)).transposed()
1408 cap
= 0.015625 # square polar cap value (1/64.0)
1409 if abs(az
.x
) < cap
and abs(az
.y
) < cap
:
1410 ax
= WORLDY
.cross(az
)
1412 ax
= WORLDZ
.cross(az
)
1416 # Matrices are now constructed from rows, transpose to make the rows into cols
1417 return Matrix((ax
, ay
, az
)).transposed()
1421 def transform(normal
, rotation
, obj
): #--------------------------------------------
1422 """Use the calculated ocs to determine the objects location/orientation in space.
1425 o
= Vector(obj
.location
)
1426 ma_new
= getOCS(normal
)
1433 rmat
= Matrix
.Rotation(radians(rotation
), 4, 'Z')
1436 obj
.matrix_world
= ma
1440 DxfEntityAttributes
= {
1442 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1443 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1444 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1445 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1450 1 : 'data', 3 : 'more', 70 : 'version',
1453 'ACAD_PROXY_ENTITY' : {
1455 90 : 'id', 91 : 'class', 92 : 'graphics_size', 93 : 'entity_size', 95: 'format',
1456 310 : 'data', 330 : 'id1', 340 : 'id2', 350 : 'id3', 360 : 'id4',
1460 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1462 50 : 'start_angle', 51 : 'end_angle',
1464 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1467 'ARCALIGNEDTEXT' : {
1468 1 : 'text', 2 : 'font', 3 : 'bigfont', 7 : 'style',
1469 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1470 40 : 'radius', 41 : 'width', 42 : 'height', 43 : 'spacing',
1471 44 : 'offset', 45 : 'right_offset', 46 : 'left_offset',
1472 50 : 'start_angle', 51 : 'end_angle',
1473 70 : 'order', 71 : 'direction', 72 : 'alignment', 73 : 'side',
1474 74 : 'bold', 75 : 'italic', 76 : 'underline',
1475 77 : 'character_set', 78 : 'pitch', 79 : 'fonttype',
1477 280 : 'wizard', 330 : 'id'
1481 1 : 'text', 2 : 'tag', 3 : 'prompt', 7 : 'style',
1482 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1483 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1484 40 : 'height', 41 : 'x_scale',
1485 50 : 'rotation_angle', 51 : 'oblique_angle',
1486 70 : 'flags', 71 : 'text_generation_flags',
1487 72 : 'horizontal_justification', 74 : 'vertical_justification',
1492 1 : 'text', 2 : 'tag', 3 : 'prompt', 7 : 'style',
1493 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1494 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1495 40 : 'height', 41 : 'x_scale',
1496 50 : 'rotation_angle', 51 : 'oblique_angle',
1497 70 : 'flags', 73 : 'length',
1498 71 : 'text_generation_flags', 72 : 'horizontal_justification', 74 : 'vertical_justification',
1502 1 : 'xref', 2 : 'name', 3 : 'also_name',
1503 10 : 'base_point.x', 20 : 'base_point.y', 30 : 'base_point.z',
1504 40 : 'size', 41 : 'x_scale',
1505 50 : 'rotation_angle', 51 : 'oblique_angle',
1510 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1513 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1517 1 : 'text', 2 : 'name', 3 : 'style',
1518 10 : 'def_point.x', 20 : 'def_point.y', 30 : 'def_point.z',
1519 11 : 'mid_point.x', 21 : 'mid_point.y', 31 : 'mid_point.z',
1520 12 : 'vector.x', 22 : 'vector.y', 32 : 'vector.z',
1521 13 : 'def_point2.x', 23 : 'def_point2.y', 33 : 'def_point2.z',
1522 14 : 'vector2.x', 24 : 'vector2.y', 34 : 'vector2.z',
1523 15 : 'vector3.x', 25 : 'vector3.y', 35 : 'vector3.z',
1524 16 : 'vector4.x', 26 : 'vector4.y', 36 : 'vector4.z',
1529 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1530 11 : 'end_point.x', 21 : 'end_point.y', 31 : 'end_point.z',
1531 40 : 'ratio', 41 : 'start', 42 : 'end',
1533 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1538 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1539 41 : 'scale', 47 : 'pixelsize', 52 : 'angle',
1540 70 : 'fill', 71 : 'associativity', 75: 'style', 77 : 'double',
1541 78 : 'numlines', 91 : 'numpaths', 98 : 'numseeds',
1542 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1546 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1547 11 : 'u_vector.x', 21 : 'u_vector.y', 31 : 'u_vector.z',
1548 12 : 'v_vector.x', 22 : 'v_vector.y', 32 : 'v_vector.z',
1549 13 : 'size.x', 23 : 'size.y', 33 : 'size.z',
1550 14 : 'clip.x', 24 : 'clip.y', 34 : 'clip.z',
1551 70 : 'display', 71 : 'cliptype',
1553 280 : 'clipstate', 281 : 'brightness', 282 : 'contrast', 283 : 'fade',
1554 340 : 'image', 360 : 'reactor',
1558 1 : 'attributes_follow', 2 : 'name',
1559 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1560 41 : 'x_scale', 42 : 'y_scale', 43 : 'z_scale',
1561 44 : 'column_spacing', 45 : 'row_spacing',
1562 50 : 'rotation_angle', 66 : 'attributes_follow',
1563 70 : 'column_count', 71 : 'row_count',
1564 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1569 10 : ['new_vertex(data)'], 20 : 'vertex.y', 30 : 'vertex.z',
1570 40 : 'height', 41 : 'width',
1571 71 : 'arrowhead', 72 : 'pathtype', 73 : 'creation',
1572 74 : 'hookdir', 75 : 'hookline', 76 : 'numverts', 77 : 'color',
1573 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1574 211 : 'horizon.x', 221 : 'horizon.y', 231 : 'horizon.z',
1575 212 : 'offset_ins.x', 222 : 'offset_ins.y', 232 : 'offset_ins.z',
1576 213 : 'offset_ann.x', 223 : 'offset_ann.y', 233 : 'offset_ann.z',
1580 10 : 'start_point.x', 20 : 'start_point.y', 30 : 'start_point.z',
1581 11 : 'end_point.x', 21 : 'end_point.y', 31 : 'end_point.z',
1583 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1587 10 : ['new_vertex(data)'], 20 : 'vertex.y', 30 : 'vertex.z',
1588 38 : 'elevation', 39 : 'thickness',
1589 40 : 'start_width', 41 : 'end_width', 42 : 'bulge', 43 : 'constant_width',
1590 70 : 'flags', 90 : 'numverts',
1591 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1595 10 : 'start_point.x', 20 : 'start_point.y', 30 : 'start_point.z',
1596 11 : ['new_vertex(data)'], 21 : 'vertex.y', 31 : 'vertex.z',
1597 12 : ['new_seg_dir(data)'], 22 : 'seg_dir.y', 32 : 'seg_dir.z',
1598 13 : ['new_miter_dir(data)'], 23 : 'miter_dir.y', 33 : 'miter_dir.z',
1600 40 : 'scale', 41 : 'elem_param', 42 : 'fill_param',
1601 70 : 'justification', 71 : 'flags',
1602 72 : 'numverts', 73 : 'numelems', 74 : 'numparam', 75 : 'numfills',
1604 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1608 1 : 'text', 3: 'more_text', 7 : 'style',
1609 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1610 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1611 40 : 'nominal_height', 41 : 'reference_width', 42: 'width', 43 : 'height', 44 : 'line_spacing',
1612 50 : 'rotation_angle',
1613 71 : 'attachment_point', 72 : 'drawing_direction', 73 : 'spacing_style',
1614 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1618 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1619 39 : 'thickness', 50 : 'orientation',
1623 1 : 'verts_follow', 2 : 'name',
1624 10 : 'elevation.x', 20 : 'elevation.y', 30 : 'elevation.z',
1626 40 : 'start_width', 41 : 'end_width',
1627 66 : 'verts_follow_flag',
1628 70 : 'flags', 71 : 'row_count', 72 : 'column_count',
1629 73 : 'row_density', 74 : 'column_density', 75 : 'linetype',
1630 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1634 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1635 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1639 1 : 'text', 7 : 'style',
1640 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1643 50 : 'rotation_angle',
1645 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1650 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1652 40 : 'size', 41 : 'x_scale',
1653 50 : 'rotation_angle', 51 : 'oblique_angle',
1658 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1659 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1660 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1661 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1663 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1667 10 : ['new_control_point(data)'], 20 : 'control_point.y', 30 : 'control_point.z',
1668 11 : ['new_fit_point(data)'], 21 : 'fit_point.y', 31 : 'fit_point.z',
1669 40 : ['new_knot_value(data)'],
1670 12 : 'start_tangent.x', 22 : 'start_tangent.y', 32 : 'start_tangent.z',
1671 13 : 'end_tangent.x', 23 : 'end_tangent.y', 33 : 'end_tangent.z',
1673 41 : 'weight', 42 : 'knot_tol', 43 : 'control_point_tol', 44 : 'fit_tol',
1674 70 : 'flag', 71 : 'degree',
1675 72 : 'num_knots', 73 : 'num_control_points', 74 : 'num_fit_points',
1676 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1680 1 : 'text', 7 : 'style',
1681 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1682 11 : 'alignment_point.x', 21 : 'alignment_point.y', 31 : 'alignment_point.z',
1683 40 : 'height', 41 : 'x_scale',
1684 50 : 'rotation_angle', 51 : 'oblique_angle',
1685 71 : 'flags', 72 : 'horizontal_justification', 73 : 'vertical_justification',
1686 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1691 10 : 'insertion_point.x', 20 : 'insertion_point.y', 30 : 'insertion_point.z',
1692 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1696 10 : 'point0.x', 20 : 'point0.y', 30 : 'point0.z',
1697 11 : 'point1.x', 21 : 'point1.y', 31 : 'point1.z',
1698 12 : 'point2.x', 22 : 'point2.y', 32 : 'point2.z',
1699 13 : 'point3.x', 23 : 'point3.y', 33 : 'point3.z',
1701 210 : 'normal.x', 220 : 'normal.y', 230 : 'normal.z',
1705 10 : 'location.x', 20 : 'location.y', 30 : 'location.z',
1706 40 : 'start_width', 41 : 'end_width', 42 : 'bulge',
1709 71 : 'index1', 72 : 'index2', 73 : 'index3', 74 : 'index4',
1713 10 : 'center.x', 20 : 'center.y', 30 : 'center.z',
1714 12 : 'view_center.x', 22 : 'view_center.y', 32 : 'view_center.z',
1715 13 : 'snap_base.x', 23 : 'snap_base.y', 33 : 'snap_base.z',
1716 14 : 'snap_spacing.x', 24 : 'snap_spacing.y', 34 : 'snap_spacing.z',
1717 15 : 'grid_spacing.x', 25 : 'grid_spacing.y', 35 : 'grid_spacing.z',
1718 16 : 'view_direction.x', 26 : 'view_direction.y', 36 : 'view_direction.z',
1719 40 : 'width', 41 : 'height',
1720 68 : 'status', 69 : 'id',
1724 10 : 'point.x', 20 : 'point.y', 30 : 'point.z',
1725 11 : 'direction.x', 21 : 'direction.y', 31 : 'direction.z',
1737 PL_CURVE_FIT_VERTS
= 0x02
1738 PL_SPLINE_FIT_VERTS
= 0x04
1739 PL_3D_POLYLINE
= 0x08
1740 PL_3D_POLYGON_MESH
= 0x10
1741 PL_CLOSED_IN_N_DIR
= 0x20
1742 PL_POLYFACE_MESH
= 0x40
1743 PL_CONTINUOUS
= 0x80
1747 VX_EXTRA_FLAG_CREATED
= 0x01
1748 VX_CURVE_FIT_TANGENT_DEFINED
= 0x02
1749 VX_SPLINE_VERTEX_CREATED
= 0x08
1750 VX_SPLINE_FRAME_CONTROL_POINT
= 0x10
1751 VX_3D_POLYLINE_VERTEX
= 0x20
1752 VX_3D_POLYGON_MESH_VERTEX
= 0x40
1753 VX_POLYFACE_MESH_VERTEX
= 0x80
1757 F3D_EDGE0_INVISIBLE
= 0x01
1758 F3D_EDGE1_INVISIBLE
= 0x02
1759 F3D_EDGE2_INVISIBLE
= 0x04
1760 F3D_EDGE3_INVISIBLE
= 0x08
1763 # readDxfFile(filePath):
1766 def readDxfFile(fileName
):
1767 global toggle
, theCodec
1769 print( "Opening DXF file "+ fileName
)
1771 # fp= open(fileName, "rU")
1772 fp
= codecs
.open(fileName
, "r", encoding
=theCodec
)
1784 if toggle
& T_Verbose
:
1785 print("%4d: %4d %s" % (no
, code
, word
))
1815 statements
.append((code
,data
))
1819 statements
.reverse()
1823 (code
,data
) = statements
.pop()
1825 if data
== 'SECTION':
1826 section
= CSection()
1829 if data
== 'HEADER':
1830 parseHeader(section
, statements
, handles
)
1832 elif data
== 'CLASSES':
1833 parseClasses(section
, statements
, handles
)
1835 elif data
== 'TABLES':
1836 parseTables(section
, statements
, handles
)
1838 elif data
== 'BLOCKS':
1839 parseBlocks(section
, statements
, handles
)
1841 elif data
== 'ENTITIES':
1842 parseEntities(section
, statements
, handles
)
1844 elif data
== 'OBJECTS':
1845 parseObjects(section
, statements
, handles
)
1846 elif data
== 'THUMBNAILIMAGE':
1847 parseThumbnail(section
, statements
, handles
)
1848 sections
[data
] = section
1852 raise NameError("Unexpected code in SECTION context: %d %s" % (code
,data
))
1854 if toggle
& T_Verbose
:
1855 for (typ
,section
) in sections
.items():
1875 def parseHeader(section
, statements
, handles
):
1877 (code
,data
) = statements
.pop()
1879 if data
== 'ENDSEC':
1893 # <class dxf record>
1908 def parseClasses(section
, statements
, handles
):
1910 (code
,data
) = statements
.pop()
1912 if data
== 'ENDSEC':
1939 # AcDbSymbolTableRecord
1951 # APPID (application identification table)
1953 # BLOCK_RECORD (block reference table)
1955 # DIMSTYLE (dimension style table)
1957 # LAYER (layer table)
1959 # LTYPE (linetype table)
1961 # STYLE (text style table)
1963 # UCS (User Coordinate System table)
1967 # VPORT (viewport configuration table)
1970 def parseTables(section
, statements
, handles
):
1972 section
.data
= tables
1974 (code
,data
) = statements
.pop()
1976 if data
== 'ENDSEC':
1980 elif data == 'TABLE':
1982 tables.append(table)
1984 elif data == 'ENDTAB':
1987 elif data == table.type:
1990 tables.append(table)
1996 handles[word] = table
2000 table.subclass = word
2002 table.nEntries = int(word)
2052 def parseBlocks(section
, statements
, handles
):
2054 (code
,data
) = statements
.pop()
2056 if data
== 'ENDSEC':
2071 # <pointer to owner>
2085 Ignorables
= ['DIMENSION', 'TEXT', 'VIEWPORT']
2088 '3DFACE': 'C3dFace()',
2089 '3DSOLID': 'C3dSolid()',
2090 'ACAD_PROXY_ENTITY': 'CAcadProxyEntity()',
2091 'ACAD_ZOMBIE_ENTITY': 0,
2093 'ARCALIGNEDTEXT': 'CArcAlignedText()',
2094 'ATTDEF': 'CAttdef()',
2095 'ATTRIB': 'CAttrib()',
2097 'CIRCLE': 'CCircle()',
2098 'DIMENSION': 'CDimension()',
2099 'ELLIPSE': 'CEllipse()',
2100 'HATCH': 'CHatch()',
2101 'IMAGE': 'CImage()',
2102 'INSERT': 'CInsert()',
2103 'LEADER': 'CLeader()',
2105 'LWPOLYLINE': 'CLWPolyLine()',
2106 'MLINE': 'CMLine()',
2107 'MTEXT': 'CMText()',
2110 'POINT': 'CPoint()',
2111 'POLYLINE': 'CPolyLine()',
2116 'SHAPE': 'CShape()',
2117 'SOLID': 'CSolid()',
2118 'SPLINE': 'CSpline()',
2120 'TOLERANCE': 'CTolerance()',
2121 'TRACE': 'CTrace()',
2122 'VERTEX': 'CVertex()',
2123 'VIEWPORT': 'CViewPort()',
2124 'WIPEOUT': 'CWipeOut()',
2125 'XLINE': 'CXLine()',
2128 def parseEntities(section
, statements
, handles
):
2130 section
.data
= entities
2132 (code
,data
) = statements
.pop()
2133 if toggle
& T_Verbose
:
2134 print("ent", code
,data
)
2137 if data
in Ignorables
:
2143 creator
= ClassCreators
[data
]
2148 entity
= eval(creator
)
2149 elif data
== 'ENDSEC':
2154 if data
== 'POLYLINE':
2155 verts
= entity
.verts
2156 elif data
== 'VERTEX':
2157 verts
.append(entity
)
2159 if data
== 'SEQEND':
2165 entities
.append(entity
)
2166 attributes
= DxfEntityAttributes
[data
]
2168 raise NameError("Unknown data %s" % data
)
2173 expr
= getAttribute(attributes
, code
)
2177 expr
= getAttribute(DxfCommonAttributes
, code
)
2180 elif code
>= 1000 or ignore
:
2182 elif toggle
& T_Debug
:
2183 raise NameError("Unknown code %d for %s" % (code
, entity
.type))
2187 def getAttribute(attributes
, code
):
2189 ext
= attributes
[code
]
2190 if type(ext
) == str:
2191 expr
= "entity.%s = data" % ext
2194 expr
= "entity.%s" % name
2226 def parseObjects(data
, statements
, handles
):
2228 (code
,data
) = statements
.pop()
2230 if data
== 'ENDSEC':
2240 # 28000000B40000005500000001001800000000000000000000000000000000000000000000000000FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
2242 # FFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
2248 def parseThumbnail(section
, statements
, handles
):
2249 """ Just skip these """
2251 (code
,data
) = statements
.pop()
2253 if data
== 'ENDSEC':
2259 # buildGeometry(entities):
2260 # addMesh(name, verts, edges, faces):
2263 def buildGeometry(entities
):
2264 try: bpy
.ops
.object.mode_set(mode
='OBJECT')
2275 for ent
in entities
:
2276 if ent
.drawtype
in {'Mesh', 'Curve'}:
2277 (verts
, edges
, faces
, vn
) = ent
.build()
2278 if not toggle
& T_DrawOne
:
2279 drawGeometry(verts
, edges
, faces
)
2283 for i
,f
in enumerate(faces
):
2285 faces
[i
] = tuple(it
+f_vn
for it
in f
)
2286 for i
,e
in enumerate(edges
):
2287 edges
[i
] = tuple(it
+f_vn
for it
in e
)
2288 f_verts
.extend(verts
)
2289 f_edges
.extend(edges
)
2290 f_faces
.extend(faces
)
2293 for i
,e
in enumerate(edges
):
2294 edges
[i
] = tuple(it
+e_vn
for it
in e
)
2295 e_verts
.extend(verts
)
2296 e_edges
.extend(edges
)
2299 v_verts
.extend(verts
)
2304 if toggle
& T_DrawOne
:
2305 drawGeometry(f_verts
, f_edges
, f_faces
)
2306 drawGeometry(e_verts
, e_edges
)
2307 drawGeometry(v_verts
)
2311 def drawGeometry(verts
, edges
=[], faces
=[]):
2313 if edges
and (toggle
& T_Curves
):
2314 print ('draw Curve')
2315 cu
= bpy
.data
.curves
.new('DXFlines', 'CURVE')
2316 cu
.dimensions
= '3D'
2317 buildSplines(cu
, verts
, edges
)
2318 ob
= addObject('DXFlines', cu
)
2320 #for v in verts: print(v)
2321 #print ('draw Mesh with %s vertices' %(len(verts)))
2322 #for e in edges: print(e)
2323 #print ('draw Mesh with %s edges' %(len(edges)))
2324 #for f in faces: print(f)
2325 #print ('draw Mesh with %s faces' %(len(faces)))
2326 me
= bpy
.data
.meshes
.new('DXFmesh')
2327 me
.from_pydata(verts
, edges
, faces
)
2328 ob
= addObject('DXFmesh', me
)
2334 def buildSplines(cu
, verts
, edges
):
2337 (v0
,v1
) = edges
.pop()
2339 newPoints
= [tuple(verts
[v0
]),tuple(verts
[v1
])]
2340 for (v0
,v1
) in edges
:
2342 newPoints
.append(tuple(verts
[v1
]))
2344 #print ('newPoints=', newPoints)
2345 point_list
.append(newPoints
)
2346 newPoints
= [tuple(verts
[v0
]),tuple(verts
[v1
])]
2348 point_list
.append(newPoints
)
2349 for points
in point_list
:
2350 spline
= cu
.splines
.new('POLY')
2351 #spline = cu.splines.new('BEZIER')
2352 #spline.use_endpoint_u = True
2354 #spline.resolution_u = 1
2355 #spline.bezier_points.add(2)
2357 spline
.points
.add(len(points
)-1)
2358 #spline.points.foreach_set('co', points)
2359 for i
,p
in enumerate(points
):
2360 spline
.points
[i
].co
= (p
[0],p
[1],p
[2],0)
2362 #print ('spline.type=', spline.type)
2363 #print ('spline number=', len(cu.splines))
2366 def addObject(name
, data
):
2367 ob
= bpy
.data
.objects
.new(name
, data
)
2368 scn
= bpy
.context
.scene
2369 scn
.objects
.link(ob
)
2373 def removeDoubles(ob
):
2374 global theMergeLimit
2375 if toggle
& T_Merge
:
2376 scn
= bpy
.context
.scene
2377 scn
.objects
.active
= ob
2378 bpy
.ops
.object.mode_set(mode
='EDIT')
2379 bpy
.ops
.mesh
.remove_doubles(threshold
=theMergeLimit
)
2380 bpy
.ops
.object.mode_set(mode
='OBJECT')
2385 # clearScene(context):
2390 scn
= bpy
.context
.scene
2391 print("clearScene %s %s" % (toggle
& T_NewScene
, scn
))
2392 if not toggle
& T_NewScene
:
2395 for ob
in scn
.objects
:
2396 if ob
.type in ["MESH", "CURVE", "TEXT"]:
2397 scn
.objects
.active
= ob
2398 bpy
.ops
.object.mode_set(mode
='OBJECT')
2399 scn
.objects
.unlink(ob
)
2404 # readAndBuildDxfFile(filepath):
2407 def readAndBuildDxfFile(filepath
):
2408 fileName
= os
.path
.expanduser(filepath
)
2410 (shortName
, ext
) = os
.path
.splitext(fileName
)
2411 #print("filepath: ", filepath)
2412 #print("fileName: ", fileName)
2413 #print("shortName: ", shortName)
2414 if ext
.lower() != ".dxf":
2415 print("Error: Not a dxf file: " + fileName
)
2417 if toggle
& T_NewScene
:
2419 if 0: # how to switch to the new scene?? (migius)
2420 new_scn
= bpy
.data
.scenes
.new(shortName
[-20:])
2421 #new_scn.layers = (1<<20) -1
2422 #new_scn_name = new_scn.name # UNUSED
2423 bpy
.data
.screens
.scene
= new_scn
2424 #print("newScene: %s" % (new_scn))
2425 sections
= readDxfFile(fileName
)
2426 print("Building geometry")
2427 buildGeometry(sections
['ENTITIES'].data
)
2430 print("Error: Not a dxf file: " + filepath
)
2438 from bpy
.props
import *
2440 def tripleList(list1
):
2443 list3
.append((elt
,elt
,elt
))
2446 class IMPORT_OT_autocad_dxf(bpy
.types
.Operator
):
2447 """Import from DXF file format (.dxf)"""
2448 bl_idname
= "import_scene.autocad_dxf"
2449 bl_description
= 'Import from DXF file format (.dxf)'
2450 bl_label
= "Import DXF" +' v.'+ __version__
2451 bl_space_type
= "PROPERTIES"
2452 bl_region_type
= "WINDOW"
2453 bl_options
= {'UNDO'}
2455 filepath
= StringProperty(
2456 subtype
='FILE_PATH',
2458 new_scene
= BoolProperty(
2459 name
="Replace scene",
2460 description
="Replace scene",
2461 default
=toggle
& T_NewScene
,
2463 #~ new_scene = BoolProperty(
2464 #~ name="New scene",
2465 #~ description="Create new scene",
2466 #~ default=toggle & T_NewScene,
2468 curves
= BoolProperty(
2470 description
="Draw entities as curves",
2471 default
=toggle
& T_Curves
,
2473 thic_on
= BoolProperty(
2475 description
="Support THICKNESS",
2476 default
=toggle
& T_ThicON
,
2478 merge
= BoolProperty(
2479 name
="Remove doubles",
2480 description
="Merge coincident vertices",
2481 default
=toggle
& T_Merge
,
2483 mergeLimit
= FloatProperty(
2485 description
="Merge limit * 0.0001",
2486 default
=theMergeLimit
* 1e4
,
2492 draw_one
= BoolProperty(
2494 description
="Draw all into one mesh object",
2495 default
=toggle
& T_DrawOne
,
2497 circleResolution
= IntProperty(
2498 name
="Circle resolution",
2499 description
="Circle/Arc are approximated with this factor",
2500 default
=theCircleRes
,
2506 codecs
= tripleList(['iso-8859-15', 'utf-8', 'ascii'])
2507 codec
= EnumProperty(name
="Codec",
2508 description
="Codec",
2512 debug
= BoolProperty(
2514 description
="Unknown DXF-codes generate errors",
2515 default
=toggle
& T_Debug
,
2517 verbose
= BoolProperty(
2519 description
="Print debug info",
2520 default
=toggle
& T_Verbose
,
2524 def draw(self
, context
):
2525 layout0
= self
.layout
2526 #layout0.enabled = False
2528 #col = layout0.column_flow(2,align=True)
2529 layout
= layout0
.box()
2530 col
= layout
.column()
2531 #col.prop(self, 'KnotType') waits for more knottypes
2532 #col.label(text="import Parameters")
2533 #col.prop(self, 'replace')
2534 col
.prop(self
, 'new_scene')
2536 row
= layout
.row(align
=True)
2537 row
.prop(self
, 'curves')
2538 row
.prop(self
, 'circleResolution')
2540 row
= layout
.row(align
=True)
2541 row
.prop(self
, 'merge')
2543 row
.prop(self
, 'mergeLimit')
2545 row
= layout
.row(align
=True)
2547 row
.prop(self
, 'draw_one')
2548 row
.prop(self
, 'thic_on')
2550 col
= layout
.column()
2551 col
.prop(self
, 'codec')
2553 row
= layout
.row(align
=True)
2554 row
.prop(self
, 'debug')
2556 row
.prop(self
, 'verbose')
2558 def execute(self
, context
):
2559 global toggle
, theMergeLimit
, theCodec
, theCircleRes
2560 O_Merge
= T_Merge
if self
.merge
else 0
2561 #O_Replace = T_Replace if self.replace else 0
2562 O_NewScene
= T_NewScene
if self
.new_scene
else 0
2563 O_Curves
= T_Curves
if self
.curves
else 0
2564 O_ThicON
= T_ThicON
if self
.thic_on
else 0
2565 O_DrawOne
= T_DrawOne
if self
.draw_one
else 0
2566 O_Debug
= T_Debug
if self
.debug
else 0
2567 O_Verbose
= T_Verbose
if self
.verbose
else 0
2569 toggle
= O_Merge | O_DrawOne | O_NewScene | O_Curves | O_ThicON | O_Debug | O_Verbose
2570 theMergeLimit
= self
.mergeLimit
*1e-4
2571 theCircleRes
= self
.circleResolution
2572 theCodec
= self
.codec
2574 readAndBuildDxfFile(self
.filepath
)
2577 def invoke(self
, context
, event
):
2578 wm
= context
.window_manager
2579 wm
.fileselect_add(self
)
2580 return {'RUNNING_MODAL'}
2583 def menu_func(self
, context
):
2584 self
.layout
.operator(IMPORT_OT_autocad_dxf
.bl_idname
, text
="Autocad (.dxf)")
2588 bpy
.utils
.register_module(__name__
)
2590 bpy
.types
.INFO_MT_file_import
.append(menu_func
)
2594 bpy
.utils
.unregister_module(__name__
)
2596 bpy
.types
.INFO_MT_file_import
.remove(menu_func
)
2599 if __name__
== "__main__":